Esempio n. 1
0
        private void PrepareForGenerateTarget(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new ClearTarget()));

            if (settings.CopyToTarget)
            {
                multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new CopySourceToTarget()));
            }
        }
Esempio n. 2
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            Contract.Assume(settings != null);

            tempCounter = new SegmentWordCounter(projectFile.Name, settings, GetWordCounter(projectFile));
            multiFileConverter.AddBilingualProcessor(tempCounter);
        }
Esempio n. 3
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            var projectController = SdlTradosStudio.Application.GetController <ProjectsController>();

            ProjectBackup.CreateProjectBackup(projectController.CurrentProject.FilePath);
            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new AnonymizerPreProcessor()));
        }
        public IEnumerable <string> ExtractWords()
        {
            ProjectFile[] files = Project.GetSourceLanguageFiles();
            int           i     = 0;

            foreach (ProjectFile file in files)
            {
                if (file.Role != FileRole.Translatable)
                {
                    continue;
                }
                FileTypeManager.SettingsBundle = Sdl.Core.Settings.SettingsUtil.CreateSettingsBundle(null);

                // disable xliff validation to speed up things
                FileTypeManager.SettingsBundle.GetSettingsGroup("SDL XLIFF 1.0 v 1.0.0.0").GetSetting <bool>("ValidateXliff").Value = false;

                IMultiFileConverter converter = FileTypeManager.GetConverter(file.LocalFilePath, (sender, e) => { });
                TextExtractionBilingualContentHandler extractor = new TextExtractionBilingualContentHandler();
                converter.AddBilingualProcessor(new Sdl.FileTypeSupport.Framework.Core.Utilities.BilingualApi.BilingualContentHandlerAdapter(extractor));
                converter.Parse();
                foreach (string text in extractor.Text)
                {
                    foreach (string word in GetWords(text))
                    {
                        yield return(word);
                    }
                }

                i++;
                OnProgress((int)(100.0 * i / (double)files.Length));
            }
        }
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            //Get instances of the translation memories included in the project.

            var        languageDirection    = projectFile.GetLanguageDirection();
            var        targetLanguage       = languageDirection.TargetLanguage;
            var        tmLanguageDirections = tms[targetLanguage].Select(x => x.GetLanguageDirection(new Sdl.LanguagePlatform.Core.LanguagePair(languageDirection.SourceLanguage.CultureInfo, languageDirection.TargetLanguage.CultureInfo)));
            FileReader _task = new FileReader(tmLanguageDirections, settings, this.collectedSentencePairCount);

            multiFileConverter.AddBilingualProcessor(_task);
            multiFileConverter.Parse();
            this.collectedSentencePairCount = _task.CollectedSentencePairCount;

            var targetLang = projectFile.GetLanguageDirection().TargetLanguage;

            if (this.ProjectTranslations.ContainsKey(targetLang))
            {
                this.ProjectTranslations[targetLang].AddRange(_task.FileTranslations);
                this.ProjectNewSegments[targetLang].AddRange(_task.FileNewSegments);
                if (this.settings.ExtractFuzzies)
                {
                    this.ProjectFuzzies[targetLang].AddRange(_task.TmFuzzies);
                }
            }
            else
            {
                this.ProjectTranslations[targetLang] = _task.FileTranslations;
                this.ProjectNewSegments[targetLang]  = _task.FileNewSegments;
                if (this.settings.ExtractFuzzies)
                {
                    this.ProjectFuzzies[targetLang] = _task.TmFuzzies;
                }
            }
        }
Esempio n. 6
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            var usernameService        = new UserNameService();
            var resourceOriginsService = new ResourceOriginsService();

            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new AnonymizerProcessor(_settings, usernameService, resourceOriginsService)));
        }
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            var phCreator = new PlaceholderCreator(settings);
            var handler   = new BilingualContentHandlerAdapter(phCreator);

            multiFileConverter.AddBilingualProcessor(handler);
        }
Esempio n. 8
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            if (!AgreementMethods.UserAgreed())
            {
                CancelHelper.CancelTaskIfRequested(true);
            }

            if (!_settings.ShouldAnonymize ?? false)
            {
                return;
            }

            var projectController        = SdlTradosStudio.Application.GetController <ProjectsController>();
            var selectedPatternsFromGrid = _settings.RegexPatterns.Where(e => e.ShouldEnable).ToList();

            if (projectController.CurrentProject != null)
            {
                ProjectBackup.CreateProjectBackup(projectController.CurrentProject.FilePath);
            }

            var key = _settings.EncryptionKey == "<dummy-encryption-key>" ? "" : AnonymizeData.DecryptData(_settings.EncryptionKey, Constants.Key);

            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new AnonymizerPreProcessor(selectedPatternsFromGrid, key, _settings.EncryptionState.HasFlag(State.PatternsEncrypted))));

            ParseRestOfFiles(projectController, selectedPatternsFromGrid, key);
        }
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            var segmentsToLock = GetSegmentListFromSettings();

            //In here you should add your custom bilingual processor to the file converter
            multiFileConverter.AddBilingualProcessor(
                new Sdl.FileTypeSupport.Framework.Core.Utilities.BilingualApi.BilingualContentHandlerAdapter(new SegmentLockerPreProcessor(segmentsToLock, _settings.OtherTextbox, _settings.ClearCheck)));
        }
Esempio n. 10
0
        /// <summary>
        /// Run export on SDLXLIFF path
        /// </summary>
        /// <param name="filePath">SDLXLIFF file for export</param>
        public bool GeneratePreviewFiles(string filePath, IMultiFileConverter multiFileConverter)
        {
            multiFileConverter.SynchronizeDocumentProperties();
            multiFileConverter.AddBilingualProcessor(new FileReader(DataExtractorObj, _settings, filePath));
            multiFileConverter.Parse();

            return true;
        }
Esempio n. 11
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            var projectController        = SdlTradosStudio.Application.GetController <ProjectsController>();
            var selectedPatternsFromGrid = _settings.RegexPatterns.Where(e => e.ShouldEnable).ToList();

            ProjectBackup.CreateProjectBackup(projectController.CurrentProject.FilePath);
            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new AnonymizerPreProcessor(selectedPatternsFromGrid)));
        }
Esempio n. 12
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            var generalSettings = GetSetting <BatchAnonymizerSettings>();

            _settings = generalSettings.UseGeneral ? generalSettings : GetAnonymizationSettings(projectFile.Language);

            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new AnonymizerProcessor(_settings, _userNameService, _resourceOriginsService)));
        }
Esempio n. 13
0
        /// <summary>
        /// Run export on SDLXLIFF path
        /// </summary>
        /// <param name="filePath">SDLXLIFF file for export</param>
        public bool GeneratePreviewFiles(string filePath, IMultiFileConverter multiFileConverter)
        {
            multiFileConverter.SynchronizeDocumentProperties();
            multiFileConverter.AddBilingualProcessor(new FileReader(DataExtractorObj, _settings, filePath));
            multiFileConverter.Parse();

            return(true);
        }
Esempio n. 14
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            if (!_settings.ShouldDeanonymize ?? false)
            {
                return;
            }

            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new DecryptDataProcessor(_settings)));
        }
Esempio n. 15
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            var encryptSettings = GetSetting <AnonymizerSettings>();

            //process only if the decryption key matches encryption key
            if (encryptSettings.EncryptionKey.Equals(_settings.EncryptionKey))
            {
                multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new DecryptDataProcessor(_settings)));
            }
        }
Esempio n. 16
0
 protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
 {
     if (_processor == null)
     {
         _processor = new SimplePsedoTranslateProcessor();
         var settings = GetSetting <SimplePseudoTranslateSettings>();
         _processor.Settings = settings;
     }
     multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(_processor));
 }
Esempio n. 17
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            // Creating a new FileReader and giving it access to the settings (unneeded currently) and the file; parsing text afterwards
            // The FileReader handles the task logic of searching the reference numbers, creating and populating the translation memory
            // And providing the reference numbers back

            logger = new BatchTaskLogger(Path.GetDirectoryName(projectFile.LocalFilePath), LoggingLevels.DEBUG);

            task = new FileReader(_settings, projectFile, ref logger);
            multiFileConverter.AddBilingualProcessor(task);
            multiFileConverter.Parse();
        }
Esempio n. 18
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            if (!AgreementMethods.UserAgreed())
            {
                CancelHelper.CancelTaskIfRequested(true);
            }

            if (!_settings.ShouldDeanonymize ?? false)
            {
                return;
            }

            var projectController = SdlTradosStudio.Application.GetController <ProjectsController>();

            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new DecryptDataProcessor(_settings)));

            var project              = projectController.CurrentProject ?? projectController.SelectedProjects.ToList()[0];
            var projectFiles         = project.GetTargetLanguageFiles();
            var unParsedProjectFiles = new List <ProjectFile>();

            foreach (var file in projectFiles)
            {
                if (TaskFiles.GetIds().Contains(file.Id))
                {
                    continue;
                }

                unParsedProjectFiles.Add(file);
            }

            var editor     = SdlTradosStudio.Application.GetController <EditorController>();
            var activeDocs = editor.GetDocuments().ToList();

            foreach (var activeDoc in activeDocs)
            {
                Application.Current.Dispatcher.Invoke(() => { editor.Close(activeDoc); });
            }

            foreach (var file in unParsedProjectFiles)
            {
                var converter        = DefaultFileTypeManager.CreateInstance(true).GetConverterToDefaultBilingual(file.LocalFilePath, file.LocalFilePath, null);
                var contentProcessor = new DecryptDataProcessor(_settings);
                converter.AddBilingualProcessor(new BilingualContentHandlerAdapter(contentProcessor));
                converter.Parse();
            }
        }
Esempio n. 19
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            if (!AgreementMethods.UserAgreed())
            {
                CancelHelper.CancelTaskIfRequested(true);
            }

            if (!_settings.ShouldDeanonymize ?? false)
            {
                return;
            }

            var projectController = SdlTradosStudio.Application.GetController <ProjectsController>();

            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new DecryptDataProcessor(_settings)));

            _restOfFilesParser.ParseRestOfFiles(projectController, TaskFiles, new DecryptDataProcessor(_settings), out _ignoredFiles);
        }
Esempio n. 20
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            //In here you should add your custom bilingual processor to the file converter
            // We initialize the class that performs the actual work
            //FileReader _task = new FileReader(_settings, projectFile.LocalFilePath);    //AbstractBilingualContentProcessor
            //multiFileConverter.AddBilingualProcessor(_task);
            //multiFileConverter.Parse();



            //var regExPatterns = new List<string>(_settings.LockerRegEx.Split(
            //                                                                    new[] { Environment.NewLine },
            //                                                                    StringSplitOptions.None
            //                                                                ));

            var patternsFromGrid = _settings.RegexPatterns.ToList();

            multiFileConverter.AddBilingualProcessor(new Sdl.FileTypeSupport.Framework.Core.Utilities.BilingualApi.BilingualContentHandlerAdapter(new SegmentLockerPreProcessor(patternsFromGrid, _settings.IncludeTagContent)));
        }
Esempio n. 21
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            if (!AgreementMethods.UserAgreed())
            {
                CancelHelper.CancelTaskIfRequested(true);
            }

            if (!_settings.ShouldAnonymize ?? false)
            {
                return;
            }

            var selectedPatternsFromGrid = _settings.RegexPatterns.Where(e => e.ShouldEnable).ToList();

            var key = _settings.EncryptionKey == "<dummy-encryption-key>" ? "" : AnonymizeData.DecryptData(_settings.EncryptionKey, Constants.Key);

            multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new AnonymizerPreProcessor(selectedPatternsFromGrid, key, _settings.EncryptionState.HasFlag(State.PatternsEncrypted))));

            _restOfFilesParser.ParseRestOfFiles(_projectController, TaskFiles,
                                                new AnonymizerPreProcessor(selectedPatternsFromGrid, key, _settings.EncryptionState.HasFlag(State.PatternsEncrypted)),
                                                out _ignoredFiles);
        }
Esempio n. 22
0
        protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
        {
            //This collects existing translations and segments without full matches from the project files
            var        languageDirection = projectFile.GetLanguageDirection();
            var        targetLanguage    = languageDirection.TargetLanguage;
            FileReader _task             = new FileReader(settings);

            multiFileConverter.AddBilingualProcessor(_task);
            multiFileConverter.Parse();

            var targetLang = projectFile.GetLanguageDirection().TargetLanguage;

            if (this.ProjectTranslations.ContainsKey(targetLang))
            {
                this.ProjectTranslations[targetLang].AddRange(_task.FileTranslations);
                this.ProjectNewSegments[targetLang].AddRange(_task.FileNewSegments);
            }
            else
            {
                this.ProjectTranslations[targetLang] = _task.FileTranslations;
                this.ProjectNewSegments[targetLang]  = _task.FileNewSegments;
            }
        }
Esempio n. 23
0
 protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
 {
     multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(errorMsgReporter));
     PrepareForGenerateTarget(projectFile, multiFileConverter);
 }
Esempio n. 24
0
 protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
 {
     //In here you should add your custom bilingual processor to the file converter
     multiFileConverter.AddBilingualProcessor(new ContentProcessor());
 }
Esempio n. 25
0
 protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
 {
     reportGenerator.AddFile(projectFile.LocalFilePath);
     multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new SaveToTargetPreProcessor(sourceSettings, targetSettings, reportGenerator)));
 }
Esempio n. 26
0
 public void Run(IMultiFileConverter multiFileConverter, IProject project, ProjectFile projectFile, IXmlReportGenerator reportGenerator)
 {
     reportGenerator.AddFile(projectFile.LocalFilePath);
     multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new SegmentContentHandler(_settings, project, reportGenerator)));
 }
 protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
 {
     wordCounter.Words       = 0;
     wordCounter.WordCounter = GetWordCounter(projectFile);
     multiFileConverter.AddBilingualProcessor(wordCounter);
 }
Esempio n. 28
0
 protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter)
 {
     multiFileConverter.AddBilingualProcessor(new BilingualContentHandlerAdapter(new AnonymizerProcessor(_settings)));
 }