Exemple #1
0
        public static void Process()
        {
            foreach (var cv in ControlCharacterVerseData.Singleton.GetAllQuoteInfo())
            {
                var s = cv.LocalizedAlias;
                AddNames(cv.Character);
                if (!string.IsNullOrEmpty(cv.Alias))
                {
                    AddNames(cv.Alias);
                }
                if (!string.IsNullOrEmpty(cv.DefaultCharacter))
                {
                    AddNames(cv.DefaultCharacter);
                }
            }

            s_englishTermsList = DeserializeBiblicalTermsForLanguage("En");

            s_englishTranslationUnits = ProcessLanguage("en", AddEnglishTerm);

            foreach (string langAbbr in s_languagesToProcess)
            {
                BiblicalTermsLocalizations localTermsList = DeserializeBiblicalTermsForLanguage(langAbbr);
                var modifiedLangAbbr = Char.ToLowerInvariant(langAbbr[0]) + langAbbr.Substring(1);
                Action <TmxFormat, Tu, Tuv> processLocalizedGloss = s_languagesWithCustomizedTranslations.Contains(modifiedLangAbbr)
                                        ? (Action <TmxFormat, Tu, Tuv>)UpdateEntryWithLocalizedGloss : AddEntryWithLocalizedGloss;
                ProcessLanguage(modifiedLangAbbr,
                                (tmx, tu, name) => { AddLocalizedTerm(tmx, modifiedLangAbbr, localTermsList, tu, name, processLocalizedGloss); });
            }

            foreach (var conflictingLocalization in s_conflictingLocalizations)
            {
                var path = Path.Combine(kLocalizationFolder, "LocalizationsFromParatextBiblicalTerms." + conflictingLocalization.Key + ".tmx");
                XmlSerializationHelper.SerializeToFile(path, conflictingLocalization.Value);
            }
        }
Exemple #2
0
        private static void AddLocalizedTerm(TmxFormat newTmx, string modifiedLangAbbr, BiblicalTermsLocalizations localTermsList,
                                             Tu tmxTermEntry, string name, Action <TmxFormat, Tu, Tuv> processLocalizedGloss)
        {
            // We only want to break a character ID into separate words for individual localization if it begins with a
            // proper name.
            int maxParts = Char.IsUpper(name[0]) ? Int32.MaxValue : 1;

            string[] parts = name.Split(new[] { ' ' }, maxParts, StringSplitOptions.RemoveEmptyEntries);

            string englishGloss = parts[0];
            string endingPunct;

            if (Char.IsPunctuation(englishGloss.Last()))
            {
                endingPunct  = englishGloss.Last().ToString();
                englishGloss = englishGloss.Remove(englishGloss.Length - 1);
            }
            else
            {
                endingPunct = null;
            }

            Localization term = s_englishTermsList.Terms.Locals.Find(t => t.Gloss == englishGloss);

            if (term != null)
            {
                Localization localTerm = localTermsList.Terms.Locals.Find(t => t.Id == term.Id);

                if (localTerm != null)
                {
                    string localGloss = s_partOfChineseOrFrenchGlossThatIsNotTheGloss.Replace(localTerm.Gloss, "");

                    if (localGloss != "")
                    {
                        if (endingPunct != null)
                        {
                            localGloss += endingPunct;
                        }
                        parts[0] = localGloss;

                        if (parts.Length > 1)
                        {
                            for (int i = 1; i < parts.Length; i++)
                            {
                                englishGloss = parts[i];
                                bool openingParenthesis = false;
                                if (englishGloss.StartsWith("("))
                                {
                                    englishGloss       = englishGloss.Substring(1);
                                    openingParenthesis = true;
                                }
                                if (Char.IsPunctuation(englishGloss.Last()))
                                {
                                    endingPunct  = englishGloss.Last().ToString();
                                    englishGloss = englishGloss.Remove(englishGloss.Length - 1);
                                }
                                else
                                {
                                    endingPunct = null;
                                }
                                term = s_englishTermsList.Terms.Locals.Find(t => t.Gloss == englishGloss);
                                if (term != null)
                                {
                                    localTerm = localTermsList.Terms.Locals.Find(t => t.Id == term.Id);

                                    if (localTerm != null)
                                    {
                                        localGloss = s_partOfChineseOrFrenchGlossThatIsNotTheGloss.Replace(localTerm.Gloss, "");
                                        if (localGloss != "")
                                        {
                                            if (openingParenthesis)
                                            {
                                                localGloss = "(" + localGloss;
                                            }
                                            if (endingPunct != null)
                                            {
                                                localGloss += endingPunct;
                                            }
                                            parts[i] = localGloss;
                                            continue;
                                        }
                                    }
                                }
                                parts[i] = "***" + parts[i] + "***";
                            }
                        }

                        var newTuv = new Tuv(modifiedLangAbbr, String.Join(" ", parts));
                        processLocalizedGloss(newTmx, tmxTermEntry, newTuv);
                    }
                }
            }
        }