コード例 #1
0
        public List <TmDetails> LoadLocalUserTms()
        {
            var localTms    = new List <TmDetails>();
            var xmlDocument = new XmlDocument();

            xmlDocument.Load(_tmsConfigPath);
            if (xmlDocument.DocumentElement == null)
            {
                return(null);
            }
            var tmNodes = xmlDocument.SelectNodes("/TranslationMemoryRepository/TranslationMemories/TranslationMemory");

            if (tmNodes != null)
            {
                foreach (XmlElement tmNode in tmNodes)
                {
                    var tmPath = tmNode.GetAttribute("path");
                    if (!string.IsNullOrEmpty(tmPath))
                    {
                        var tm        = new FileBasedTranslationMemory(tmPath);
                        var tmDetails = new TmDetails
                        {
                            TmPath     = tmPath,
                            Name       = tm.Name,
                            SourceFlag = new Language(tm.LanguageDirection.SourceLanguage.Name).GetFlagImage(),
                            TargetFlag = new Language(tm.LanguageDirection.TargetLanguage.Name).GetFlagImage(),
                            FileBasedTranslationMemory = tm
                        };
                        localTms.Add(tmDetails);
                    }
                }
            }
            return(localTms);
        }
コード例 #2
0
        public void AddTu(TmDetails tmDetails, string sourceText, string targetText)
        {
            var tu = new TranslationUnit
            {
                SourceSegment = new Segment(tmDetails.FileBasedTranslationMemory.LanguageDirection.SourceLanguage),
                TargetSegment = new Segment(tmDetails.FileBasedTranslationMemory.LanguageDirection.TargetLanguage)
            };

            tu.SourceSegment.Add(sourceText);
            tu.TargetSegment.Add(targetText);

            tmDetails.FileBasedTranslationMemory.LanguageDirection.AddTranslationUnit(tu, GetImportSettings());
            tmDetails.FileBasedTranslationMemory.Save();
        }