public static String Convert(String text, bool toCyrillic) { //1. Add reference to MSTranslitTools.DLL (it can be found in %programfiles%\Microsoft Transliteration Utility) //2. Add Current translation files (.tms) can be found in %CommonProgramFiles%\Transliteration\Modules\Microsoft\ //3. using System.NaturalLanguage.Tools; String directionExe = System.Reflection.Assembly.GetExecutingAssembly().Location; String direction; if (toCyrillic) { direction = directionExe.Replace("Codaxy.Dextop.Localizer.Windows.exe", "SerbianLatintoCyrillic.tms"); } else { direction = directionExe.Replace("Codaxy.Dextop.Localizer.Windows.exe", "SerbianCyrillictoLatin.tms"); } TransliteratorSpecification specification = TransliteratorSpecification.FromSpecificationFile(direction); Transliterator transliterator = Transliterator.FromSpecification(specification); String converted = transliterator.Transliterate(text); return(converted); }
private TransliteratorSpecification GetSpecification(TransliterationSpecificationRecord record) { using (TextReader specificationReader = new StringReader(record.Rules)) { return(TransliteratorSpecification.FromSpecificationFile(specificationReader, fOnlyMetadata)); } }
public FileTypeBase() { TransliteratorSpecification _c2lSpecs = TransliteratorSpecification.FromSpecificationFile("C2L.tms"); m_c2lTransliter = Transliterator.FromSpecification(_c2lSpecs); }