예제 #1
0
 public void TranslatePagiTest()
 {
     JawiTranslator target = new JawiTranslator();
     string rumi = "pagi";
     string expected = "ڤاݢي";
     string actual = target.Translate(rumi);
     Assert.AreEqual(expected, actual);
 }
예제 #2
0
 public void TranslateMohdTest()
 {
     JawiTranslator target = new JawiTranslator();
     string rumi = "mohd";
     string expected = "محمد";
     string actual = target.Translate(rumi);
     Assert.AreEqual(expected, actual);
 }
예제 #3
0
        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();
        }
예제 #4
0
        /// <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;
        }