コード例 #1
0
        public UnityWebRequest Import_Google_CreateWWWcall(bool ForceUpdate, bool justCheck)
        {
            if (!HasGoogleSpreadsheet())
            {
                return(null);
            }

            string savedVersion = PersistentStorage.GetSetting_String("I2SourceVersion_" + GetSourcePlayerPrefName(), Google_LastUpdatedVersion);

            if (savedVersion.Length > 19)             // Check for corruption
            {
                savedVersion = string.Empty;
            }

#if !UNITY_EDITOR
            if (IsNewerVersion(savedVersion, Google_LastUpdatedVersion))
            {
                Google_LastUpdatedVersion = savedVersion;
            }
#endif

            string query = string.Format("{0}?key={1}&action=GetLanguageSource&version={2}",
                                         LocalizationManager.GetWebServiceURL(this),
                                         Google_SpreadsheetKey,
                                         ForceUpdate ? "0" : Google_LastUpdatedVersion);
#if UNITY_EDITOR
            if (justCheck)
            {
                query += "&justcheck=true";
            }
#endif
            UnityWebRequest www = UnityWebRequest.Get(query);
            I2Utils.SendWebRequest(www);
            return(www);
        }
        void Google_NewSpreadsheet()
        {
                        #if UNITY_WEBPLAYER
            ShowError("Contacting google translation is not yet supported on WebPlayer");
                        #else
            ClearErrors();
            string SpreadsheetName;

            LanguageSourceData source = GetSourceData();
            if (source.IsGlobalSource())
            {
                SpreadsheetName = string.Format("{0} Localization", PlayerSettings.productName);
            }
            else
            {
                SpreadsheetName = string.Format("{0} {1} {2}", PlayerSettings.productName, Editor_GetCurrentScene(), source.ownerObject.name);
            }

            string query = mProp_Google_WebServiceURL.stringValue + "?action=NewSpreadsheet&name=" + Uri.EscapeDataString(SpreadsheetName) + "&password="******"Creating Spreadsheet";
            //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
                        #endif
        }
        void Google_FindSpreadsheets()
        {
            ClearErrors();
            EditorApplication.update -= Google_FindSpreadsheets;
            string query = mProp_Google_WebServiceURL.stringValue + "?action=GetSpreadsheetList&password="******"Accessing google";
            //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
        }
コード例 #4
0
        void ExecuteNextBatch()
        {
            if (mQueries.Count == 0)
            {
                mJobState = eJobState.Succeeded;
                return;
            }
            mCurrentBatch_Text = new List <string>();

            string lastLangCode = null;
            int    maxLength    = 200;

            var sb = new StringBuilder();
            int i;

            for (i = 0; i < mQueries.Count; ++i)
            {
                var text     = mQueries[i].Key;
                var langCode = mQueries[i].Value;

                if (lastLangCode == null || langCode == lastLangCode)
                {
                    if (i != 0)
                    {
                        sb.Append("|||");
                    }
                    sb.Append(text);

                    mCurrentBatch_Text.Add(text);
                    lastLangCode = langCode;
                }
                if (sb.Length > maxLength)
                {
                    break;
                }
            }
            mQueries.RemoveRange(0, i);

            var fromtoLang = lastLangCode.Split(':');

            mCurrentBatch_FromLanguageCode = fromtoLang[0];
            mCurrentBatch_ToLanguageCode   = fromtoLang[1];

            string url = string.Format("http://www.google.com/translate_t?hl=en&vi=c&ie=UTF8&oe=UTF8&submit=Translate&langpair={0}|{1}&text={2}", mCurrentBatch_FromLanguageCode, mCurrentBatch_ToLanguageCode, Uri.EscapeUriString(sb.ToString()));

            Debug.Log(url);

            www = UnityWebRequest.Get(url);
            I2Utils.SendWebRequest(www);
        }
 void VerifyGoogleService(string WebServiceURL)
 {
                 #if UNITY_WEBPLAYER
     ShowError("Contacting google translation is not yet supported on WebPlayer");
                 #else
     StopConnectionWWW();
     mWebService_Status = null;
     mConnection_WWW    = UnityWebRequest.Get(WebServiceURL + "?action=Ping");
     I2Utils.SendWebRequest(mConnection_WWW);
     mConnection_Callback      = OnVerifyGoogleService;
     EditorApplication.update += CheckForConnection;
     mConnection_Text          = "Verifying Web Service";
     //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
                 #endif
 }
コード例 #6
0
        public TranslationJob_POST(TranslationDictionary requests, Action <TranslationDictionary, string> OnTranslationReady)
        {
            _requests           = requests;
            _OnTranslationReady = OnTranslationReady;

            var data = GoogleTranslation.ConvertTranslationRequest(requests, false);

            WWWForm form = new WWWForm();

            form.AddField("action", "Translate");
            form.AddField("list", data[0]);

            www = UnityWebRequest.Post(LocalizationManager.GetWebServiceURL(), form);
            I2Utils.SendWebRequest(www);
        }
コード例 #7
0
        void ExecuteNextQuery()
        {
            if (mQueries.Count == 0)
            {
                mJobState = eJobState.Succeeded;
                return;
            }

            int lastQuery = mQueries.Count - 1;
            var query     = mQueries[lastQuery];

            mQueries.RemoveAt(lastQuery);

            string url = string.Format("{0}?action=Translate&list={1}", LocalizationManager.GetWebServiceURL(), query);

            www = UnityWebRequest.Get(url);
            I2Utils.SendWebRequest(www);
        }
コード例 #8
0
        public UnityWebRequest Export_Google_CreateWWWcall(eSpreadsheetUpdateMode UpdateMode = eSpreadsheetUpdateMode.Replace)
        {
            #if UNITY_WEBPLAYER
            Debug.Log("Contacting google translation is not yet supported on WebPlayer");
            return(null);
#else
            string Data = Export_Google_CreateData();

            WWWForm form = new WWWForm();
            form.AddField("key", Google_SpreadsheetKey);
            form.AddField("action", "SetLanguageSource");
            form.AddField("data", Data);
            form.AddField("updateMode", UpdateMode.ToString());

            #if UNITY_EDITOR
            form.AddField("password", Google_Password);
#endif


            UnityWebRequest www = UnityWebRequest.Post(LocalizationManager.GetWebServiceURL(this), form);
            I2Utils.SendWebRequest(www);
            return(www);
                        #endif
        }