Пример #1
0
        //Whenever doc changes, start translating the segments and caching translations
        private static void DocChanged(object sender, DocumentEventArgs e)
        {
            if (e.Document == null)
            {
                return;
            }

            OpusCatProvider.UpdateSegmentHandler(e.Document);
        }
Пример #2
0
        internal static void UpdateSegmentHandler()
        {
            EditorController editorController = SdlTradosStudio.Application.GetController <EditorController>();
            var activeDoc = editorController.ActiveDocument;

            if (activeDoc != null)
            {
                OpusCatProvider.UpdateSegmentHandler(activeDoc);
            }
        }
Пример #3
0
        public OpusCatProvider(OpusCatOptions options)
        {
            //TODO: add some kind of throttling here or to Helper to prevent the service being overwhelmed by requests.
            //Just keep a count of open connections and prevent connections when there are more than 100 or so.
            Options = options;

            //If we create a provider with the pregenerate on, add a doc change handler to start preordering
            //MT when doc is changed
            if (options.pregenerateMt)
            {
                EditorController editorController = SdlTradosStudio.Application.GetController <EditorController>();
                //This should ensure the handler is only attached once, by always removing a possible previously
                //added handler before adding the new one
                editorController.ActiveDocumentChanged -= OpusCatProvider.DocChanged;
                editorController.ActiveDocumentChanged += OpusCatProvider.DocChanged;

                //If a document is open, check if the segment change handler should be added
                OpusCatProvider.UpdateSegmentHandler();
            }
        }
Пример #4
0
        public OpusCatProvider(OpusCatOptions options, ITranslationProviderCredentialStore credentialStore)
        {
            Options = options;

            //If we create a provider with the pregenerate on, add a doc change handler to start preordering
            //MT when doc is changed
            if (options.pregenerateMt && options.opusCatSource == OpusCatOptions.OpusCatSource.OpusCatMtEngine)
            {
                EditorController editorController = SdlTradosStudio.Application.GetController <EditorController>();
                //This should ensure the handler is only attached once, by always removing a possible previously
                //added handler before adding the new one
                editorController.ActiveDocumentChanged -= OpusCatProvider.DocChanged;
                editorController.ActiveDocumentChanged += OpusCatProvider.DocChanged;

                //If a document is open, check if the segment change handler should be added
                OpusCatProvider.UpdateSegmentHandler();
            }

            if (this.Options.opusCatSource == OpusCatOptions.OpusCatSource.Elg)
            {
                OpusCatProvider.ElgConnection = new ElgServiceConnection(new TradosElgCredentialWrapper(credentialStore));
            }
        }