Exemplo n.º 1
0
        private File GetFileContainer(IParagraphUnit paragraphUnit)
        {
            var contextType = GetContextType(paragraphUnit);
            var file        = Xliff.Files[Xliff.Files.Count - 1];

            if (contextType != null)
            {
                if (contextType != "Recommended")
                {
                    var alternativeFile = Xliff.Files.FirstOrDefault(a => a.Original == contextType);
                    if (alternativeFile != null)
                    {
                        file = alternativeFile;
                    }
                    else
                    {
                        file = new File
                        {
                            Original       = contextType,
                            SourceLanguage = SourceLanguage.Name,
                            TargetLanguage = TargetLanguage.Name,
                            DataType       = "xml"
                        };
                        Xliff.Files.Add(file);
                    }
                }
                else
                {
                    file.Original = "Recommended";
                }
            }

            return(file);
        }
Exemplo n.º 2
0
        public override void SetFileProperties(IFileProperties fileInfo)
        {
            _fileProperties = fileInfo;

            var file = new File
            {
                SourceLanguage = SourceLanguage.Name,
                TargetLanguage = TargetLanguage.Name
            };

            file.Original = fileInfo.FileConversionProperties.OriginalFilePath;
            file.DataType = fileInfo.FileConversionProperties.FileTypeDefinitionId.Id;

            Xliff.Files.Add(file);

            CreateDummyOutputFiles(fileInfo);
        }
Exemplo n.º 3
0
        private void UpdateContexts(File file, IParagraphUnit paragraphUnit, TransUnit transUnit)
        {
            if (paragraphUnit.Properties.Contexts?.Contexts != null)
            {
                foreach (var context in paragraphUnit.Properties.Contexts.Contexts)
                {
                    var existingContext = file.Header.Contexts.FirstOrDefault(a =>
                                                                              string.Compare(a.ContextType, context.ContextType, StringComparison.CurrentCultureIgnoreCase) == 0 &&
                                                                              string.Compare(a.DisplayCode, context.DisplayCode, StringComparison.CurrentCultureIgnoreCase) == 0 &&
                                                                              string.Compare(a.DisplayName, context.DisplayName, StringComparison.CurrentCultureIgnoreCase) == 0 &&
                                                                              string.Compare(a.Description, context.Description, StringComparison.CurrentCultureIgnoreCase) == 0);

                    if (existingContext != null)
                    {
                        transUnit.Contexts.Add(existingContext);
                    }
                    else
                    {
                        _contextIndex++;

                        var newContext = new Context
                        {
                            Id          = _contextIndex.ToString(),
                            ContextType = context.ContextType,
                            Description = context.Description,
                            DisplayCode = context.DisplayCode,
                            DisplayName = context.DisplayName
                        };

                        if (context.MetaData != null)
                        {
                            foreach (var metaData in context.MetaData)
                            {
                                newContext.MetaData.Add(metaData.Key, metaData.Value);
                            }
                        }

                        transUnit.Contexts.Add(newContext);
                        file.Header.Contexts.Add(newContext);
                    }
                }
            }
        }