public void TranslatePagiTest() { JawiTranslator target = new JawiTranslator(); string rumi = "pagi"; string expected = "ڤاݢي"; string actual = target.Translate(rumi); Assert.AreEqual(expected, actual); }
public void TranslateMohdTest() { JawiTranslator target = new JawiTranslator(); string rumi = "mohd"; string expected = "محمد"; string actual = target.Translate(rumi); Assert.AreEqual(expected, actual); }
public ActionResult Translate(string rumi) { string result = string.Empty; JawiTranslator translator = new JawiTranslator(); if (!String.IsNullOrEmpty(rumi)) { string[] words = rumi.Split(new char[] { ' ' }); foreach (string word in words) result += translator.Translate(word) + " "; } ViewBag.Jawi = result.Trim(); return View(); }
/// <summary> /// Automate convert to jawi when provide rumi name. /// </summary> /// <param name="rumi">Rumi word.</param> public string ConvertToJawi(string rumi) { // Translate word by word string output = string.Empty; JawiLookup localTranslator = new JawiLookup(); JawiTranslator webTranslator = new JawiTranslator(); string[] words = rumi.Split(new char[] { ' ' }); foreach (string word in words) { string jawi = localTranslator.Lookup(word); if (string.IsNullOrEmpty(jawi)) jawi = webTranslator.Translate(word); if (output.Length > 0) output += " "; output += jawi; } this.jawiField = output; this.OnPropertyChanged("jawi"); return output; }