private static void AddFrenchTmx(string folderPath)
        {
            var doc = new TMXDocument {
                Header = { SourceLang = "fr" }
            };

            // first unit
            var variants = new List <TransUnitVariant>
            {
                new TransUnitVariant {
                    Lang = "en", Value = "blah"
                },
                new TransUnitVariant {
                    Lang = "fr", Value = "blahInFrench"
                }
            };
            var tu = new TransUnit
            {
                Id       = "blahId",
                Variants = variants
            };

            tu.AddProp("ar", LocalizedStringCache.kDiscoveredDyanmically, "true");
            tu.AddProp("en", LocalizedStringCache.kDiscoveredDyanmically, "true");
            doc.AddTransUnit(tu);
            doc.Save(Path.Combine(folderPath, LocalizationManager.GetTmxFileNameForLanguage(AppId, "fr")));
        }
        static TransUnit MakeTransUnit(string lang, string englishVal, string val, string id, bool dynamic)
        {
            var variants = new List <TransUnitVariant> {
                new TransUnitVariant {
                    Lang = lang, Value = val
                }
            };

            if (englishVal != null)
            {
                variants.Add(new TransUnitVariant {
                    Lang = "en", Value = englishVal
                });
            }
            var tu = new TransUnit
            {
                Id       = id,
                Variants = variants
            };

            if (dynamic)
            {
                tu.AddProp(lang, LocalizedStringCache.kDiscoveredDyanmically, "true");
            }
            return(tu);
        }
예제 #3
0
        private void UpdateTransUnitComment(TransUnit tu, LocalizingInfo locInfo)
        {
            if (locInfo.DiscoveredDynamically && (tu.GetPropValue(LocalizedStringCache.kDiscoveredDyanmically) != "true"))
            {
                tu.AddProp(LocalizedStringCache.kDiscoveredDyanmically, "true");
                _updated = true;
            }

            if ((locInfo.UpdateFields & UpdateFields.Comment) != UpdateFields.Comment)
            {
                return;
            }

            if ((tu.Notes.Count > 0) && (tu.Notes[0].Text == locInfo.Comment))
            {
                return;
            }

            tu.Notes.Clear();
            _updated = true;

            if (!string.IsNullOrEmpty(locInfo.Comment))
            {
                tu.AddNote(locInfo.Comment);
            }
        }
        private static void AddArabicTmx(string folderPath)
        {
            var arabicDoc = new TMXDocument {
                Header = { SourceLang = "ar" }
            };

            // first unit
            var variants = new List <TransUnitVariant>
            {
                new TransUnitVariant {
                    Lang = "en", Value = "wrong"
                },
                new TransUnitVariant {
                    Lang = "ar", Value = "inArabic"
                }
            };
            var tu = new TransUnit
            {
                Id       = "theId",
                Variants = variants
            };

            tu.AddProp("ar", LocalizedStringCache.kDiscoveredDyanmically, "true");
            tu.AddProp("en", LocalizedStringCache.kDiscoveredDyanmically, "true");
            arabicDoc.AddTransUnit(tu);
            // second unit
            var variants2 = new List <TransUnitVariant>
            {
                new TransUnitVariant {
                    Lang = "en", Value = "inEnglishpartofArabicTMX"
                },
                new TransUnitVariant {
                    Lang = "ar", Value = "inArabic"
                }
            };
            var tu2 = new TransUnit
            {
                Id       = "notUsedId",
                Variants = variants2
            };

            tu2.AddProp("ar", LocalizedStringCache.kDiscoveredDyanmically, "true");
            tu2.AddProp("en", LocalizedStringCache.kDiscoveredDyanmically, "true");
            // Note: we are NOT adding a NoLongerUsed property to the Arabic TMX
            arabicDoc.AddTransUnit(tu2);
            arabicDoc.Save(Path.Combine(folderPath, LocalizationManager.GetTmxFileNameForLanguage(AppId, "ar")));
        }
        private static void AddEnglishTmx(string folderPath, string appVersion)
        {
            var englishDoc = new TMXDocument {
                Header = { SourceLang = "en" }
            };

            if (!String.IsNullOrEmpty(appVersion))
            {
                englishDoc.Header.SetPropValue(LocalizationManager.kAppVersionPropTag, appVersion);
            }
            // first unit
            var variants = new List <TransUnitVariant> {
                new TransUnitVariant {
                    Lang = "en", Value = "from English TMX"
                }
            };
            var tu = new TransUnit
            {
                Id       = "theId",
                Variants = variants
            };

            tu.AddProp("en", LocalizedStringCache.kDiscoveredDyanmically, "true");
            englishDoc.AddTransUnit(tu);
            // second unit
            var variants2 = new List <TransUnitVariant> {
                new TransUnitVariant {
                    Lang = "en", Value = "no longer used English text"
                }
            };
            var prop = new TMXProp();

            prop.Type  = LocalizedStringCache.kNoLongerUsedPropTag;
            prop.Value = "true";
            var tu2 = new TransUnit
            {
                Id       = "notUsedId",
                Variants = variants2,
                Props    = { prop }
            };

            englishDoc.AddTransUnit(tu2);
            // third unit
            var variants3 = new List <TransUnitVariant> {
                new TransUnitVariant {
                    Lang = "en", Value = "blah"
                }
            };
            var tu3 = new TransUnit
            {
                Id       = "blahId",
                Variants = variants3
            };

            englishDoc.AddTransUnit(tu3);
            englishDoc.Save(Path.Combine(folderPath, LocalizationManager.GetTmxFileNameForLanguage(AppId, "en")));
        }