private IEnumerator Process(LanguageCodes sourceLang, List <LanguageCodes> targetLang, string sourceText)
        {
            string sourcText = sourceLang.ToString();
            bool   isError   = false;

            Debug.Log("Word" + " : " + sourceText);
            foreach (var val in targetLang)
            {
                string targetText = val.ToString();

                // if Language code has hyphen such as Chinene ... Hyphen not allow in Enums..
                if (targetText.Contains("_"))
                {
                    targetText = targetText.Replace('_', '-');
                }
                string url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl="
                             + sourcText + "&tl=" + targetText + "&dt=t&q=" + WWW.EscapeURL(sourceText);

                WWW www = new WWW(url);
                yield return(www);

                if (www.isDone)
                {
                    if (string.IsNullOrEmpty(www.error))
                    {
                        var N = JSONNode.Parse(www.text);// Json Parser
                        translatedText = N[0][0][0];
                        print(targetText + " : " + translatedText);
                        OnTranslatedWord(val, translatedText, sourceText);
                    }
                    else
                    {
                        //isError = true;
                        InternetNotWorking();
                        yield break;
                    }
                }
            }
            if (!isError)
            {
                _controller.ValueChange(db.GetDB().Count, db.GetList().Count);
                db.OnTranslated();
            }
        }
示例#2
0
        } // !FromString()

        public static string EnumToString(this LanguageCodes c)
        {
            return(c.ToString("g").ToLower());
        } // !ToString()