예제 #1
0
        public void ExampleMultiTranslations_Async()
        {
            IsTranslating = true;

            // This shows how to ask for many translations
            var dict = new Dictionary <string, TranslationQuery>();

            GoogleTranslation.AddQuery("This is an example", "en", "es", dict);
            GoogleTranslation.AddQuery("This is an example", "auto", "zh", dict);
            GoogleTranslation.AddQuery("Hola", "es", "en", dict);

            GoogleTranslation.Translate(dict, OnMultitranslationReady);
        }
예제 #2
0
        public void ExampleMultiTranslations_Blocking()
        {
            // This shows how to ask for many translations
            var dict = new System.Collections.Generic.Dictionary <string, TranslationQuery>();

            GoogleTranslation.AddQuery("This is an example", "en", "es", dict);
            GoogleTranslation.AddQuery("This is an example", "auto", "zh", dict);
            GoogleTranslation.AddQuery("Hola", "es", "en", dict);

            if (!GoogleTranslation.ForceTranslate(dict))
            {
                return;
            }

            Debug.Log(GoogleTranslation.GetQueryResult("This is an example", "en", dict));
            Debug.Log(GoogleTranslation.GetQueryResult("This is an example", "zh", dict));
            Debug.Log(GoogleTranslation.GetQueryResult("This is an example", "", dict)); // This returns ANY translation of that text (in this case, the first one 'en')
            Debug.Log(dict["Hola"].Results[0]);                                          // example of getting the translation directly from the Results
        }