public string Process(string text, CultureInfo nativeCulture, CultureInfo romanizedCulture) { if (nativeCulture.TwoLetterISOLanguageName.ToLowerInvariant() != "el") { throw new IrrelevantCultureException(nativeCulture.DisplayName, nameof(nativeCulture)); } return(CulturalOperations.RunWithCulture(nativeCulture, () => { text = text // General preparation, normalization .LanguageWidePreparation() // Remove diacritics that this system ignores .WithoutChars("\u0300\u0340" + // Grave accent "\u0301\u0341" + // Acute accent "\u0313\u0343" + // Smooth breathing/koronis "\u0303\u0342" + // Tilde "\u0311" + // Inverted breve "\u0345") // Iota subscript .ReplaceFromChartWithSameCase(PunctuationTable); // Convert numerals text = OutputNumeralType == OutputNumeralType.Roman ? NumeralsSystem.ProcessNumeralsInText(text, value => value.Value.ToRomanNumerals()) : NumeralsSystem.ProcessNumeralsInText(text, value => value.Value.ToArabicNumerals(romanizedCulture)); // Actual romanization of text return text // Do special provisions .ReplaceMany(RhoAspiratedSub, RoughBreathingVowelSub) .ReplaceFromChartWithSameCase(DiphthongTable) .ReplaceFromChartWithSameCase(SpecificCombinationTable) // Do regular character replacement .ReplaceFromChartWithSameCase(RomanizationTable); })); }
public string Process(string text, bool useDigraphs, CultureInfo culture) { if (culture.TwoLetterISOLanguageName.ToLowerInvariant() != "ru") { throw new IrrelevantCultureException(culture.DisplayName, nameof(culture)); } return(CulturalOperations.RunWithCulture(culture, () => { text = text.LanguageWidePreparation(); // Digraphs first, if they're to be inserted if (useDigraphs) { text = text.ReplaceFromChartWithSameCase(DigraphTable) .ReplaceMany(IDigraphSub, YeryExceptionDigraphSub, YeryVowelsDigraphSub, EConsonantsDigraphSub); } // Then single characters return text .ReplaceMany(YeProvisionSub, YoProvisionSub) .ReplaceFromChartWithSameCase(RomanizationTable); })); }
public string Process(string text, CultureInfo nativeCulture) { if (nativeCulture.TwoLetterISOLanguageName.ToLowerInvariant() != "ru") { throw new IrrelevantCultureException(nativeCulture.DisplayName, nameof(nativeCulture)); } return(CulturalOperations.RunWithCulture(nativeCulture, () => text.LanguageWidePreparation().ReplaceFromChartWithSameCase(RomanizationTable))); }
public string Process(string text, CultureInfo nativeCulture) { if (nativeCulture.TwoLetterISOLanguageName.ToLowerInvariant() != "ru") { throw new IrrelevantCultureException(nativeCulture.DisplayName, nameof(nativeCulture)); } return(CulturalOperations.RunWithCulture(nativeCulture, () => text.LanguageWidePreparation() // Render ye (Е) and yo (Ё) in different forms depending on what preceeds them .ReplaceMany(YeVowelsSub, YoVowelsSub, YoExceptionsSub) // Do remaining romanization replacements .ReplaceFromChartWithSameCase(RomanizationTable))); }
public string Process(string text, CultureInfo nativeCulture) { if (nativeCulture.TwoLetterISOLanguageName.ToLowerInvariant() != "el") { throw new IrrelevantCultureException(nativeCulture.DisplayName, nameof(nativeCulture)); } return(CulturalOperations.RunWithCulture(nativeCulture, () => text // General preparation, normalization .LanguageWidePreparation() // Do common replacements .ReplaceFromChart(DiacriticsTable, StringComparison.Ordinal) .ReplaceFromChart(PunctuationTable, StringComparison.Ordinal) .ReplaceFromChart(CommonReplacementTable))); }
public string Process(string text, CultureInfo nativeCulture) { if (nativeCulture.TwoLetterISOLanguageName.ToLowerInvariant() != "ru") { throw new IrrelevantCultureException(nativeCulture.DisplayName, nameof(nativeCulture)); } return(CulturalOperations.RunWithCulture(nativeCulture, () => text.LanguageWidePreparation() // Do romanization replacements .ReplaceFromChartWithSameCase(RomanizationTable) // Do cased romanization replacements .ReplaceFromChartWithSameCase(CasedTable, StringComparison.CurrentCulture) // Render tse (Ц/ц) as "c" if in front of e, i, j, or y, and as "cz" otherwise .ReplaceMany(TseVowelsSub, TseConsonantsSub))); }
public string Process(string text) => CulturalOperations.RunWithCulture(CultureInfo.GetCultureInfo("ja-JP"), () => text // Replace common alternate characters .ReplaceCommonAlternates() // Insert spaces at boundaries between Latin characters and Japanese ones (ie. ニンテンドーDSiブラウザー) .SeparateLanguageBoundaries() // Do multi-char combinations first (Yōon) .ReplaceFromChartWithSameCase(YoonChart, StringComparison.CurrentCulture) // Then single-char replacements (Gojūon) .ReplaceFromChartWithSameCase(GojuonChart, StringComparison.CurrentCulture) // Do special subsitutions .ReplaceMany( // Convert chōonpu usage in original text into macrons to mark long vowels in a romanized manner LongASub, LongESub, LongISub, LongOSub, LongUSub, // Render syllabic n as either "n'" or "n" based on whether or not it preceeds a vowel or consonant, respectively SyllabicNVowelsSub, SyllabicNConsonantsSub, // Take sokuon usage into account (repeating the following consonant to mark long consonants) SokuonChCaseSub, SokuonGeneralCaseSub));