Beispiel #1
0
        internal List <SegmentInfo> ReadFile(string filePath, ProcessorOptions options)
        {
            var converter = _fileTypeManager.GetConverterToDefaultBilingual(filePath, filePath + ".out", null);

            var contentProcessor = new ParagraphProcessor
            {
                Segments = new List <SegmentInfo>()
            };

            if (options.SourceToTargetCopier.CopySourceToTaret)
            {
                converter.AddBilingualProcessor(new SourceToTargetCopier(
                                                    options.SourceToTargetCopier.Preserve
                        ? ExistingContentHandling.Preserve
                        : ExistingContentHandling.Replace));
            }

            converter.AddBilingualProcessor(contentProcessor);

            try
            {
                converter.Progress += ConverterProgress;

                converter.Parse();
            }
            finally
            {
                converter.Progress -= ConverterProgress;
            }

            return(contentProcessor.Segments);
        }
Beispiel #2
0
        public bool UpdateFile(Xliff xliff, string filePathInput, string filePathOutput)
        {
            var converter     = _fileTypeManager.GetConverterToDefaultBilingual(filePathInput, filePathOutput, null);
            var contentWriter = new ContentWriter(xliff, _segmentBuilder, _importOptions, _analysisBands);

            converter.AddBilingualProcessor(contentWriter);
            converter.SynchronizeDocumentProperties();

            converter.Parse();

            ConfirmationStatistics      = contentWriter.ConfirmationStatistics;
            TranslationOriginStatistics = contentWriter.TranslationOriginStatistics;

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// Create temporary bilingual file (sdlxliff) used to import the information
        /// in Studio translation memories
        /// </summary>
        /// <param name="starTransitTM"></param>
        /// <param name="pathToExtractFolder"></param>
        /// <returns></returns>
        private string CreateTemporarySdlXliff(string starTransitTM)
        {
            var pathToExtractFolder = CreateFolderToExtract(Path.GetDirectoryName(starTransitTM));

            var generatedXliffName = string.Format("{0}{1}",
                                                   Path.GetFileNameWithoutExtension(starTransitTM), ".sdlxliff");

            var sdlXliffFullPath = Path.Combine(pathToExtractFolder, generatedXliffName);

            var converter = _fileTypeManager.GetConverterToDefaultBilingual(starTransitTM,
                                                                            sdlXliffFullPath,
                                                                            null);

            converter.Parse();
            return(sdlXliffFullPath);
        }
Beispiel #4
0
        /// <summary>
        /// Imports updated DOCX file into the SDLXLIFF file
        /// </summary>
        /// <param name="filePathInput">Original SDLXLIFF file</param>
        /// <param name="filePathOutput">Output SDLXLIFF file</param>
        /// <param name="filePathUpdated">Updated DOCX file</param>
        public bool ImportUpdatedFile(string filePathInput, string filePathOutput, string filePathUpdated, string targetLanguage)
        {
            var contentWriter = new ContentWriter(_settings, _analysisBands, filePathUpdated, targetLanguage, _segmentBuilder);
            var converter     = _fileTypeManager.GetConverterToDefaultBilingual(filePathInput, filePathOutput, null);

            converter.AddBilingualProcessor(contentWriter);

            converter.Parse();

            SourceLanguage = contentWriter.SourceLanguage;
            TargetLanguage = contentWriter.TargetLanguage;

            ConfirmationStatistics      = contentWriter.ConfirmationStatistics;
            TranslationOriginStatistics = contentWriter.TranslationOriginStatistics;

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Run export on SDLXLIFF path
        /// </summary>
        public bool ExportFile(string filePath, string outputFilePath, string targetLanguage)
        {
            var contentReader = new ContentReader(_projectId, _tokenVisitor, _settings, _analysisBands, filePath, outputFilePath, targetLanguage);
            var converter     = _fileTypeManager.GetConverterToDefaultBilingual(filePath, null, null);

            converter.AddBilingualProcessor(contentReader);

            converter.Parse();

            SourceLanguage = contentReader.SourceLanguage;
            TargetLanguage = contentReader.TargetLanguage;

            ConfirmationStatistics      = contentReader.ConfirmationStatistics;
            TranslationOriginStatistics = contentReader.TranslationOriginStatistics;

            return(true);
        }
        /// <summary>
        /// Create temporary bilingual file (sdlxliff) used to import the information
        /// in Studio translation memories
        /// </summary>
        /// <param name="starTransitTM"></param>
        /// <param name="pathToExtractFolder"></param>
        /// <returns></returns>
        private string CreateTemporarySdlXliff(string starTransitTM)
        {
            try
            {
                var pathToExtractFolder = CreateFolderToExtract(Path.GetDirectoryName(starTransitTM));
                var generatedXliffName  = string.Format("{0}{1}", Path.GetFileNameWithoutExtension(starTransitTM), ".sdlxliff");

                var sdlXliffFullPath = Path.Combine(pathToExtractFolder, generatedXliffName);
                var converter        = _fileTypeManager.GetConverterToDefaultBilingual(starTransitTM, sdlXliffFullPath, null);

                converter.Parse();
                return(sdlXliffFullPath);
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"CreateTemporarySdlXliff method: {ex.Message}\n {ex.StackTrace}");
            }
            return(string.Empty);
        }