Beispiel #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Removes the specified translation unit variant.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public void RemoveVariant(XLiffTransUnitVariant tuv)
 {
     if (tuv != null)
     {
         RemoveVariant(tuv.Lang);
     }
 }
Beispiel #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds a translation unit variant having the specified language id and value.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool AddOrReplaceVariant(string langId, string value)
        {
            var tuv = new XLiffTransUnitVariant();

            tuv.Lang  = langId;
            tuv.Value = value;
            return(AddOrReplaceVariant(tuv));
        }
Beispiel #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Removes the variant for the specified language.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void RemoveVariant(string langId)
        {
            XLiffTransUnitVariant tuv = GetVariantForLang(langId);

            if (tuv != null)
            {
                if (langId == kDefaultLangId)
                {
                    Source = new XLiffTransUnitVariant();
                }
                else
                {
                    Target = new XLiffTransUnitVariant();
                }
            }
        }
Beispiel #4
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));
        }
Beispiel #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the specified variant.
        /// </summary>
        /// <param name="tuv">The variant.</param>
        /// <returns>true if the variant was successfully added. Otherwise, false.</returns>
        /// ------------------------------------------------------------------------------------
        public bool AddOrReplaceVariant(XLiffTransUnitVariant tuv)
        {
            if (tuv == null)
            {
                return(false);
            }

            // If a variant exists for the specified language, then remove it first.
            RemoveVariant(tuv.Lang);
            if (tuv.Lang == kDefaultLangId)
            {
                Source = tuv;
            }
            else
            {
                Target = tuv;
            }
            return(true);
        }
Beispiel #6
0
 /// ------------------------------------------------------------------------------------
 public XLiffTransUnit()
 {
     Source            = new XLiffTransUnitVariant();
     Target            = null;
     TranslationStatus = TranslationStatus.Unapproved;
 }