Пример #1
0
        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;
                }
            }
        }
        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));
            }
        }
Пример #3
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);
        }
Пример #4
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;
        }
Пример #5
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();
        }
Пример #6
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;
            }
        }