Exemplo n.º 1
0
        void DelayedStartTranslation()
        {
            if (EditorApplication.timeSinceStartup < TimeStartTranslation)
            {
                return;
            }
            EditorApplication.update -= DelayedStartTranslation;

            if (mTranslationRequests.Count <= 0)
            {
                return;
            }

            mConnection_WWW           = GoogleTranslation.GetTranslationWWW(mTranslationRequests);
            mConnection_Text          = "Translating (" + mTranslationRequests.Count + ")";
            mConnection_Callback      = OnLanguageTranslated;
            EditorApplication.update += CheckForConnection;
        }
Exemplo n.º 2
0
        void TranslateAllToLanguage(string lanName)
        {
            if (!GoogleTranslation.CanTranslate())
            {
                ShowError("WebService is not set correctly or needs to be reinstalled");
                return;
            }

            int    LanIndex = mLanguageSource.GetLanguageIndex(lanName);
            string code     = mLanguageSource.mLanguages [LanIndex].Code;

            mTranslationRequests.Clear();
            foreach (var termData in mLanguageSource.mTerms)
            {
                if (!string.IsNullOrEmpty((GUI_SelectedInputType == 0 ? termData.Languages : termData.Languages_Touch)[LanIndex]))
                {
                    continue;
                }

                string sourceCode, sourceText;
                FindTranslationSource(LanguageSource.GetKeyFromFullTerm(termData.Term), termData, code, out sourceText, out sourceCode);

                mTranslationRequests.Add(new TranslationRequest()
                {
                    Term                = termData.Term,
                    Text                = sourceText,
                    LanguageCode        = sourceCode,
                    TargetLanguagesCode = new string[] { code }
                });
            }

            mConnection_WWW  = GoogleTranslation.GetTranslationWWW(mTranslationRequests);
            mConnection_Text = "Translating"; if (mTranslationRequests.Count > 1)
            {
                mConnection_Text += " (" + mTranslationRequests.Count + ")";
            }
            mConnection_Callback      = OnLanguageTranslated;
            EditorApplication.update += CheckForConnection;
        }