Created
May 28, 2015 09:37
-
-
Save cromica/4676c94c596aa174c4f4 to your computer and use it in GitHub Desktop.
sample code for translating a segment on demand
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Action("SDL.Community.ManageMT.Translate", Name = "Translate", Icon = "icon", Description = "Translate current segment in the editor")] | |
[ActionLayout(typeof(ControlledMTProvidersRibbon), 60, DisplayType.Normal)] | |
[Shortcut(Keys.Alt | Keys.T)] | |
class ControlledMtTranslateViewPartAction : AbstractAction | |
{ | |
private EditorController _editorController; | |
private bool _disableMt = CascadeLanguageDirection.DisableMt; | |
public ControlledMtTranslateViewPartAction() | |
{ | |
} | |
public override void Initialize() | |
{ | |
_editorController = SdlTradosStudio.Application.GetController<EditorController>(); | |
} | |
protected override void Execute() | |
{ | |
if (_editorController.ActiveDocument != null) | |
{ | |
CascadeLanguageDirection.TranslationFinished += CascadeLanguageDirection_TranslationFinished; | |
_disableMt = CascadeLanguageDirection.DisableMt; | |
CascadeLanguageDirection.DisableMt = false; | |
_editorController.ActiveDocument.TryTranslateActiveSegment(); | |
} | |
} | |
void CascadeLanguageDirection_TranslationFinished(object sender, EventArgs e) | |
{ | |
CascadeLanguageDirection.DisableMt = _disableMt; | |
CascadeLanguageDirection.TranslationFinished -= CascadeLanguageDirection_TranslationFinished; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment