Example #1
0
        private static void UpdateEntryWithLocalizedGloss(TmxFormat newTmx, Tu tmxTermEntry, Tuv newTuv)
        {
            var existingTranslationUnit = newTmx.Body.Tus.FirstOrDefault(t => t.Tuid == tmxTermEntry.Tuid);
            Tuv existingtuv             = null;

            if (existingTranslationUnit != null)
            {
                existingtuv = existingTranslationUnit.Tuvs.FirstOrDefault(t => t.Lang == newTuv.Lang);
            }
            if (existingtuv != null)
            {
                if (s_processingUpdatedBiblicalTermsFiles && existingtuv.LocalizedTerm != newTuv.LocalizedTerm)
                {
                    // Unless we're processing new updates to the Paratext Biblical Terms, any conflicts must come
                    // from previous human localization work, so we'll just leave them as they are and not even bother
                    // reporting them.
                    TmxFormat paratextTmxFormat;
                    if (!s_conflictingLocalizations.TryGetValue(newTuv.Lang, out paratextTmxFormat))
                    {
                        s_conflictingLocalizations[newTuv.Lang] = paratextTmxFormat = new TmxFormat(newTmx);
                    }
                    paratextTmxFormat.Body.Tus.First((t => t.Tuid == tmxTermEntry.Tuid))
                    .Tuvs.First(t => t.Lang == newTuv.Lang)
                    .LocalizedTerm = newTuv.LocalizedTerm;
                }
            }
            else
            {
                AddEntryWithLocalizedGloss(newTmx, tmxTermEntry, newTuv);

                TmxFormat conflictingTmx;
                if (s_processingUpdatedBiblicalTermsFiles && s_conflictingLocalizations.TryGetValue(newTuv.Lang, out conflictingTmx))
                {
                    conflictingTmx.Body.Tus.Add(tmxTermEntry.Clone());
                }
            }
        }
Example #2
0
 private static void AddEntryWithLocalizedGloss(TmxFormat newTmx, Tu tmxTermEntry, Tuv newTuv)
 {
     tmxTermEntry.Tuvs.Add(newTuv);
     newTmx.Body.Tus.Add(tmxTermEntry);
 }
Example #3
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);
                    }
                }
            }
        }