コード例 #1
0
        /// ------------------------------------------------------------------------------------
        private void SaveFileForLangId(string langId, bool forceCreation)
        {
            var tmxDoc = CreateEmptyStringFile();

            tmxDoc.Header.SourceLang = langId;
            tmxDoc.Header.SetPropValue(LocalizationManager.kAppVersionPropTag, OwningManager.AppVersion);

            foreach (var tu in TmxDocument.Body.TransUnits)
            {
                var tuv = tu.GetVariantForLang(langId);
                if (tuv == null)
                {
                    continue;
                }

                var newTu = new TMXTransUnit {
                    Id = tu.Id
                };
                tmxDoc.AddTransUnit(newTu);
                newTu.AddOrReplaceVariant(tu.GetVariantForLang(LocalizationManager.kDefaultLang));
                newTu.AddOrReplaceVariant(tuv);
                newTu.Notes = tu.CopyNotes();
                newTu.Props = tu.CopyProps();
            }

            tmxDoc.Body.TransUnits.Sort(TuComparer);

            if (forceCreation || OwningManager.DoesCustomizedTranslationExistForLanguage(langId))
            {
                tmxDoc.Save(OwningManager.GetTmxPathForLanguage(langId, true));
            }
        }
コード例 #2
0
        /// ------------------------------------------------------------------------------------
        private void SaveFileForLangId(string langId, bool forceCreation, XLiffDocument xliffOriginal)
        {
            if (!forceCreation && !OwningManager.DoesCustomizedTranslationExistForLanguage(langId))
            {
                return;
            }

            var xliffOutput = CreateEmptyStringFile();

            if (langId != LocalizationManager.kDefaultLang)
            {
                xliffOutput.File.TargetLang = langId;
            }
            xliffOutput.File.ProductVersion           = OwningManager.AppVersion;
            xliffOutput.File.HardLineBreakReplacement = s_literalNewline;
            xliffOutput.File.AmpersandReplacement     = _ampersandReplacement;
            if (OwningManager != null && OwningManager.Name != null)
            {
                xliffOutput.File.Original = OwningManager.Name + ".dll";
            }

            foreach (var tu in DefaultXliffDocument.File.Body.TransUnits)
            {
                var tuTarget = xliffOriginal.File.Body.GetTransUnitForId(tu.Id);
                XLiffTransUnitVariant tuv = null;
                if (tuTarget != null)
                {
                    tuv = tuTarget.GetVariantForLang(langId);
                }
                // REVIEW: should we write units with no translation (target)?
                var newTu = new XLiffTransUnit {
                    Id = tu.Id, Dynamic = tu.Dynamic
                };
                newTu.AddOrReplaceVariant(tu.GetVariantForLang(LocalizationManager.kDefaultLang));
                if (tuv != null)
                {
                    newTu.AddOrReplaceVariant(tuv);
                }
                newTu.Notes = tu.CopyNotes();
                xliffOutput.AddTransUnit(newTu);
            }
            xliffOutput.File.Body.TransUnits.Sort(TuComparer);
            xliffOutput.Save(OwningManager.GetPathForLanguage(langId, true));
        }