Пример #1
0
 public void setContent(JsonText json, XmlText xml, string word)
 {
     if (buttonText.text == "Dict")
     {
         if (json != null)
         {
             originalText.text = word;
             translate.text    = json.text[0];
             Debug.Log("Translate: (" + json.lang + ") " + json.text[0]);
             //  break;
         }
     }
     else
     {
         if (xml != null)
         {
             translate.text = xml.fl + "\n <size=20>" + xml.sn + " " + xml.dt + "</size>";
             Debug.Log("Dict");
             //break;
         }
     }
 }
Пример #2
0
        IEnumerator Translate(string word)
        {
            string getLangs = "https://https://dictionary.yandex.net/api/v1/dicservice.json/getLangs?key=dict.1.1.20170712T213201Z.011f10ef04c6cd2b.9429d4487d86ea0269e4039b4776af5d480b71e1&lang=fr&text" + word;
            string lookUp   = "https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key=dict.1.1.20170712T213201Z.011f10ef04c6cd2b.9429d4487d86ea0269e4039b4776af5d480b71e1&lang=en-fr&text=" + word;

            string url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20170712T213228Z.50f66cb053334861.3305946c36e78fabf910df5491ed59c20967ebfd&lang=zh&text=" + word;
            WWW    www = new WWW(url);

            yield return(www);

            if (www.error == null)
            {
                string json = www.text;
                print(json);
                Debug.Log("Translate " + word + " ");
                myJson = JsonUtility.FromJson <JsonText>(json);
                setContent(myJson, null, word);
            }
            else
            {
                //error
            }
        }