void OnImported_Google(string Result, string Error, eSpreadsheetUpdateMode UpdateMode)
        {
            if (!string.IsNullOrEmpty(Error))
            {
                Debug.Log(Error);
                ShowError("Unable to access google");
                return;
            }
            LanguageSourceData source   = GetSourceData();
            string             ErrorMsg = source.Import_Google_Result(Result, UpdateMode);
            bool HasErrors = !string.IsNullOrEmpty(ErrorMsg);

            if (HasErrors)
            {
                ShowError(ErrorMsg);
            }

            serializedObject.Update();
            ParseTerms(true, false, !HasErrors);
            mSelectedKeys.Clear();
            mSelectedCategories.Clear();
            ScheduleUpdateTermsToShowInList();
            mLanguageSource.GetCategories(false, mSelectedCategories);

            EditorUtility.SetDirty(target);
            AssetDatabase.SaveAssets();
        }
        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
        }
Ejemplo n.º 3
0
        public bool IsEqualTo(LanguageSourceData Source)
        {
            if (Source.mLanguages.Count != mLanguages.Count)
            {
                return(false);
            }

            for (int i = 0, imax = mLanguages.Count; i < imax; ++i)
            {
                if (Source.GetLanguageIndex(mLanguages[i].Name) < 0)
                {
                    return(false);
                }
            }

            if (Source.mTerms.Count != mTerms.Count)
            {
                return(false);
            }

            for (int i = 0; i < mTerms.Count; ++i)
            {
                if (Source.GetTermData(mTerms[i].Term) == null)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        static void TranslateLanguage(string Key, TermData termdata, Localize localizeCmp, LanguageSourceData source)
        {
            ClearErrors();
            string mainText = localizeCmp == null?LanguageSourceData.GetKeyFromFullTerm(Key) : localizeCmp.GetMainTargetsText();

            for (int i = 0; i < source.mLanguages.Count; ++i)
            {
                if (source.mLanguages[i].IsEnabled() && string.IsNullOrEmpty(termdata.Languages[i]))
                {
                    var langIdx  = i;
                    var term     = termdata;
                    var i2source = source;
                    Translate(mainText, ref termdata, source.mLanguages[i].Code,
                              (translation, error) =>
                    {
                        if (error != null)
                        {
                            ShowError(error);
                        }
                        else
                        if (translation != null)
                        {
                            term.Languages[langIdx] = translation;             //SetTranslation(langIdx, translation);
                            i2source.Editor_SetDirty();
                        }
                    }, null);
                }
            }
        }
Ejemplo n.º 5
0
        static TermData AddTerm(string Term, bool AutoSelect = true, eTermType termType = eTermType.Text)
        {
            if (Term == "-" || string.IsNullOrEmpty(Term))
            {
                return(null);
            }

            Term = I2Utils.GetValidTermName(Term, true);

            TermData data = mLanguageSource.AddTerm(Term, termType);

            GetParsedTerm(Term);
            string sCategory = LanguageSourceData.GetCategoryFromFullTerm(Term);

            mParsedCategories.Add(sCategory);

            if (AutoSelect)
            {
                if (!mSelectedKeys.Contains(Term))
                {
                    mSelectedKeys.Add(Term);
                }

                if (!mSelectedCategories.Contains(sCategory))
                {
                    mSelectedCategories.Add(sCategory);
                }
            }
            ScheduleUpdateTermsToShowInList();
            mLanguageSource.Editor_SetDirty();
            return(data);
        }
        void Import_Google(eSpreadsheetUpdateMode UpdateMode)
        {
            StopConnectionWWW();
            LanguageSourceData source = GetSourceData();

            mConnection_WWW = source.Import_Google_CreateWWWcall(true, false);
            if (mConnection_WWW == null)
            {
                OnImported_Google(string.Empty, "Unable to import from google", eSpreadsheetUpdateMode.Replace);
            }
            else
            {
                mConnection_Callback = null;
                switch (UpdateMode)
                {
                case eSpreadsheetUpdateMode.Replace: mConnection_Callback += OnImported_Google_Replace; break;

                case eSpreadsheetUpdateMode.Merge: mConnection_Callback += OnImported_Google_Merge; break;

                case eSpreadsheetUpdateMode.AddNewTerms: mConnection_Callback += OnImported_Google_AddNewTerms; break;
                }
                EditorApplication.update += CheckForConnection;
                mConnection_Text          = "Downloading spreadsheet";
                //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
            }
        }
Ejemplo n.º 7
0
        public void Custom_OnEnable(LanguageSourceData sourceData, SerializedProperty propSource)
        {
            bool ForceParse = (mLanguageSource != sourceData);

            mLanguageSource       = sourceData;
            mLanguageSourceEditor = this;
            mCurrentInspector     = this;

            if (!LocalizationManager.Sources.Contains(mLanguageSource))
            {
                LocalizationManager.UpdateSources();
            }

            mProp_Assets                           = propSource.FindPropertyRelative("Assets");
            mProp_Languages                        = propSource.FindPropertyRelative("mLanguages");
            mProp_Google_WebServiceURL             = propSource.FindPropertyRelative("Google_WebServiceURL");
            mProp_GoogleUpdateFrequency            = propSource.FindPropertyRelative("GoogleUpdateFrequency");
            mProp_GoogleUpdateSynchronization      = propSource.FindPropertyRelative("GoogleUpdateSynchronization");
            mProp_GoogleInEditorCheckFrequency     = propSource.FindPropertyRelative("GoogleInEditorCheckFrequency");
            mProp_GoogleUpdateDelay                = propSource.FindPropertyRelative("GoogleUpdateDelay");
            mProp_Google_SpreadsheetKey            = propSource.FindPropertyRelative("Google_SpreadsheetKey");
            mProp_Google_SpreadsheetName           = propSource.FindPropertyRelative("Google_SpreadsheetName");
            mProp_Google_Password                  = propSource.FindPropertyRelative("Google_Password");
            mProp_CaseInsensitiveTerms             = propSource.FindPropertyRelative("CaseInsensitiveTerms");
            mProp_Spreadsheet_LocalFileName        = propSource.FindPropertyRelative("Spreadsheet_LocalFileName");
            mProp_Spreadsheet_LocalCSVSeparator    = propSource.FindPropertyRelative("Spreadsheet_LocalCSVSeparator");
            mProp_Spreadsheet_LocalCSVEncoding     = propSource.FindPropertyRelative("Spreadsheet_LocalCSVEncoding");
            mProp_Spreadsheet_SpecializationAsRows = propSource.FindPropertyRelative("Spreadsheet_SpecializationAsRows");
            mProp_OnMissingTranslation             = propSource.FindPropertyRelative("OnMissingTranslation");
            mProp_AppNameTerm                      = propSource.FindPropertyRelative("mTerm_AppName");
            mProp_IgnoreDeviceLanguage             = propSource.FindPropertyRelative("IgnoreDeviceLanguage");
            mProp_GoogleLiveSyncIsUptoDate         = propSource.FindPropertyRelative("GoogleLiveSyncIsUptoDate");
            mProp_AllowUnloadingLanguages          = propSource.FindPropertyRelative("_AllowUnloadingLanguages");

            if (!mIsParsing)
            {
                if (string.IsNullOrEmpty(mLanguageSource.Google_SpreadsheetKey))
                {
                    mSpreadsheetMode = eSpreadsheetMode.Local;
                }
                else
                {
                    mSpreadsheetMode = eSpreadsheetMode.Google;
                }

                mCurrentViewMode = (mLanguageSource.mLanguages.Count > 0 ? eViewMode.Keys : eViewMode.Languages);

                UpdateSelectedKeys();

                if (ForceParse || mParsedTerms.Count < mLanguageSource.mTerms.Count)
                {
                    mSelectedCategories.Clear();
                    ParseTerms(true, false, true);
                }
            }
            ScheduleUpdateTermsToShowInList();
            LoadSelectedCategories();
            //UpgradeManager.EnablePlugins();
        }
        public void Export_CSV(string FileName, eSpreadsheetUpdateMode UpdateMode, char Separator, System.Text.Encoding encoding)
        {
            LanguageSourceData source = GetSourceData();

            string CSVstring = source.Export_CSV(null, Separator, mProp_Spreadsheet_SpecializationAsRows.boolValue);

            System.IO.File.WriteAllText(FileName, CSVstring, encoding);
        }
Ejemplo n.º 9
0
        void TranslateAllToLanguage(string lanName)
        {
            if (!GoogleTranslation.CanTranslate())
            {
                ShowError("WebService is not set correctly or needs to be reinstalled");
                return;
            }
            ClearErrors();
            int    LanIndex   = mLanguageSource.GetLanguageIndex(lanName);
            string code       = mLanguageSource.mLanguages [LanIndex].Code;
            string googleCode = GoogleLanguages.GetGoogleLanguageCode(code);

            if (string.IsNullOrEmpty(googleCode))
            {
                ShowError("Language '" + code + "' is not supported by google translate");
                return;
            }
            googleCode = code;

            mTranslationTerms.Clear();
            mTranslationRequests.Clear();
            foreach (var termData in mLanguageSource.mTerms)
            {
                if (termData.TermType != eTermType.Text)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(termData.Languages[LanIndex]))
                {
                    continue;
                }

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

                mTranslationTerms.Add(termData.Term);

                GoogleTranslation.CreateQueries(sourceText, sourceCode, googleCode, mTranslationRequests);                   // can split plurals into several queries
            }

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

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

            GoogleTranslation.Translate(mTranslationRequests, OnLanguageTranslated);
        }
        static IEnumerator Delayed_Import_Google(LanguageSourceData source, float delay, bool justCheck)
        {
            yield return(new WaitForSeconds(delay));

            if (source != null) // handle cases where the source is already deleted
            {
                source.Import_Google(false, justCheck);
            }
        }
Ejemplo n.º 11
0
        public bool IsTerm(string name, bool allowCategoryMistmatch)
        {
            if (!allowCategoryMistmatch)
            {
                return(name == Term);
            }

            return(name == LanguageSourceData.GetKeyFromFullTerm(Term));
        }
        //[MenuItem( "Tools/I2 Localization/Create I2Languages", false, 1)]
        public static void CreateLanguageSources()
        {
            if (LocalizationManager.GlobalSources == null || LocalizationManager.GlobalSources.Length == 0)
            {
                return;
            }

            Object             GlobalSource = Resources.Load(LocalizationManager.GlobalSources[0]);
            LanguageSourceData sourceData   = null;
            string             sourcePath   = null;

            if (GlobalSource != null)
            {
                if (GlobalSource is GameObject)
                {
                    // I2Languages was a prefab before 2018.3, it should be converted to an ScriptableObject
                    sourcePath = AssetDatabase.GetAssetPath(GlobalSource);
                    LanguageSource langSourceObj = (GlobalSource as GameObject).GetComponent <LanguageSource>();
                    sourceData = langSourceObj.mSource;
                }
                else
                {
                    return;
                }
            }

            LanguageSourceAsset asset = ScriptableObject.CreateInstance <LanguageSourceAsset>();

            if (sourceData != null)
            {
                asset.mSource = sourceData;
                AssetDatabase.DeleteAsset(sourcePath);
            }

            if (string.IsNullOrEmpty(sourcePath))
            {
                //string PluginPath = GetI2LocalizationPath();
                string ResourcesFolder = "Assets/Resources";//PluginPath.Substring(0, PluginPath.Length-"/Localization".Length) + "/Resources";

                string fullresFolder = Application.dataPath + ResourcesFolder.Replace("Assets", "");
                if (!System.IO.Directory.Exists(fullresFolder))
                {
                    System.IO.Directory.CreateDirectory(fullresFolder);
                }

                sourcePath = ResourcesFolder + "/" + LocalizationManager.GlobalSources[0] + ".asset";
            }
            else
            {
                sourcePath = sourcePath.Replace(".prefab", ".asset");
            }

            AssetDatabase.CreateAsset(asset, sourcePath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
Ejemplo n.º 13
0
        public static void CreateTemp()
        {
            LanguageSourceData source = LocalizationManager.Sources[0];

            for (int i = 0; i < 1000; ++i)
            {
                source.AddTerm("Term " + i, eTermType.Text, false);
            }
            source.UpdateDictionary(true);
        }
 static bool AllowSyncFromGoogle(LanguageSourceData Source)
 {
     if (Callback_AllowSyncFromGoogle == null)
     {
         return(true);
     }
     else
     {
         return(Callback_AllowSyncFromGoogle.Invoke(Source));
     }
 }
Ejemplo n.º 15
0
 internal bool ManagerHasASimilarSource()
 {
     for (int i = 0, imax = LocalizationManager.Sources.Count; i < imax; ++i)
     {
         LanguageSourceData source = (LocalizationManager.Sources[i] as LanguageSourceData);
         if (source != null && source.IsEqualTo(this) && source != this)
         {
             return(true);
         }
     }
     return(false);
 }
        void OnGUI_NewOrExistingTerm()
        {
            if (mKeyToExplore == null)
            {
                mKeyToExplore = string.Empty;
            }

            GUI.backgroundColor = Color.Lerp(Color.gray, Color.white, 0.2f);
            GUILayout.BeginVertical(LocalizeInspector.GUIStyle_OldTextArea, GUILayout.Height(1));
            GUI.backgroundColor = Color.white;
            GUILayout.Space(5);
            GUILayout.Label("Replace By:");
            GUILayout.EndVertical();

            //--[ Create Term ]------------------------
            GUILayout.BeginHorizontal();
            mKeyToExplore = GUILayout.TextField(mKeyToExplore, EditorStyles.toolbarTextField, GUILayout.ExpandWidth(true));
            if (GUILayout.Button("Create", "toolbarbutton", GUILayout.Width(60)))
            {
                LanguageSourceData.ValidateFullTerm(ref mKeyToExplore);
                EditorApplication.update += ReplaceSelectedTerms;
            }
            GUILayout.EndHorizontal();

            //--[ Existing Term ]------------------------
            int           Index = 0;
            List <string> Terms = mLanguageSource.GetTermsList();

            for (int i = 0, imax = Terms.Count; i < imax; ++i)
            {
                if (Terms[i].ToLower().Contains(mKeyToExplore.ToLower()))
                {
                    Index = i;
                    break;
                }
            }

            GUILayout.BeginHorizontal();
            int NewIndex = EditorGUILayout.Popup(Index, Terms.ToArray(), EditorStyles.toolbarPopup, GUILayout.ExpandWidth(true));

            if (NewIndex != Index)
            {
                SelectTerm(Terms [NewIndex]);
                ClearErrors();
            }
            if (GUILayout.Button("Use", "toolbarbutton", GUILayout.Width(60)))
            {
                SelectTerm(Terms[NewIndex]);
                EditorApplication.update += ReplaceSelectedTerms;
            }
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 17
0
        void SwapLanguages(int iFirst, int iSecond)
        {
            serializedObject.ApplyModifiedProperties();
            LanguageSourceData Source = mLanguageSource;

            SwapValues(Source.mLanguages, iFirst, iSecond);
            foreach (TermData termData in Source.mTerms)
            {
                SwapValues(termData.Languages, iFirst, iSecond);
                SwapValues(termData.Flags, iFirst, iSecond);
            }
            serializedObject.Update();
        }
Ejemplo n.º 18
0
        public void OnAfterDeserialize()
        {
            if (version == 0 || mSource == null)
            {
                mSource       = new LanguageSourceData();
                mSource.owner = this;
                mSource.UserAgreesToHaveItOnTheScene             = UserAgreesToHaveItOnTheScene;
                mSource.UserAgreesToHaveItInsideThePluginsFolder = UserAgreesToHaveItInsideThePluginsFolder;
                mSource.IgnoreDeviceLanguage     = IgnoreDeviceLanguage;
                mSource._AllowUnloadingLanguages = _AllowUnloadingLanguages;
                mSource.CaseInsensitiveTerms     = CaseInsensitiveTerms;
                mSource.OnMissingTranslation     = OnMissingTranslation;
                mSource.mTerm_AppName            = mTerm_AppName;

                mSource.GoogleLiveSyncIsUptoDate  = GoogleLiveSyncIsUptoDate;
                mSource.Google_WebServiceURL      = Google_WebServiceURL;
                mSource.Google_SpreadsheetKey     = Google_SpreadsheetKey;
                mSource.Google_SpreadsheetName    = Google_SpreadsheetName;
                mSource.Google_LastUpdatedVersion = Google_LastUpdatedVersion;
                mSource.GoogleUpdateFrequency     = GoogleUpdateFrequency;
                mSource.GoogleUpdateDelay         = GoogleUpdateDelay;

                mSource.Event_OnSourceUpdateFromGoogle += Event_OnSourceUpdateFromGoogle;

                if (mLanguages != null && mLanguages.Count > 0)
                {
                    mSource.mLanguages.Clear();
                    mSource.mLanguages.AddRange(mLanguages);
                    mLanguages.Clear();
                }
                if (Assets != null && Assets.Count > 0)
                {
                    mSource.Assets.Clear();
                    mSource.Assets.AddRange(Assets);
                    Assets.Clear();
                }
                if (mTerms != null && mTerms.Count > 0)
                {
                    mSource.mTerms.Clear();
                    for (int i = 0; i < mTerms.Count; ++i)
                    {
                        mSource.mTerms.Add(mTerms[i]);
                    }
                    mTerms.Clear();
                }

                version = 1;

                Event_OnSourceUpdateFromGoogle = null;
            }
        }
Ejemplo n.º 19
0
        List <string> ScriptTool_GetSelectedTermsInCategory(string Category)
        {
            List <string> list = new List <string>();

            foreach (string FullKey in mSelectedKeys)
            {
                string categ = LanguageSourceData.GetCategoryFromFullTerm(FullKey);
                if (categ == Category && ShouldShowTerm(FullKey))
                {
                    list.Add(LanguageSourceData.GetKeyFromFullTerm(FullKey));
                }
            }

            return(list);
        }
Ejemplo n.º 20
0
 bool TermHasAllTranslations(LanguageSourceData source, TermData data)
 {
     if (source == null)
     {
         source = LocalizationManager.Sources[0];
     }
     for (int i = 0, imax = data.Languages.Length; i < imax; ++i)
     {
         bool isLangEnabled = (source.mLanguages.Count > i) ? source.mLanguages[i].IsEnabled() : true;
         if (string.IsNullOrEmpty(data.Languages[i]) && isLangEnabled)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 21
0
        void OnGUI_CategorizedTerm(string Term)
        {
            GUILayout.BeginHorizontal();
            string sKey, sCategory;

            LanguageSourceData.DeserializeFullTerm(Term, out sKey, out sCategory);
            if (!string.IsNullOrEmpty(sCategory))
            {
                GUI.color = Color.gray;
                GUILayout.Label(sCategory + "/");
                GUI.color = Color.white;
            }
            GUILayout.Label(sKey);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
        static ParsedTerm AddParsedTerm(string FullTerm, string TermKey, string Category, int Usage)
        {
            if (TermKey == null)
            {
                LanguageSourceData.DeserializeFullTerm(FullTerm, out TermKey, out Category);
            }

            var data = new ParsedTerm();

            data.Usage    = Usage;
            data.FullTerm = FullTerm;
            data.Term     = TermKey;
            data.Category = Category;

            mParsedTerms[FullTerm] = data;
            return(data);
        }
Ejemplo n.º 23
0
        public static string GetWebServiceURL(LanguageSourceData source = null)
        {
            if (source != null && !string.IsNullOrEmpty(source.Google_WebServiceURL))
            {
                return(source.Google_WebServiceURL);
            }

            InitializeIfNeeded();
            for (int i = 0; i < Sources.Count; ++i)
            {
                if (Sources[i] != null && !string.IsNullOrEmpty(Sources[i].Google_WebServiceURL))
                {
                    return(Sources[i].Google_WebServiceURL);
                }
            }
            return(string.Empty);
        }
        void Export_Google(eSpreadsheetUpdateMode UpdateMode)
        {
            StopConnectionWWW();
            LanguageSourceData source = GetSourceData();

            mConnection_WWW = source.Export_Google_CreateWWWcall(UpdateMode);
            if (mConnection_WWW == null)
            {
                OnExported_Google(string.Empty, "WebPlayer can't contact Google");
            }
            else
            {
                mConnection_Callback      = OnExported_Google;
                EditorApplication.update += CheckForConnection;
                mConnection_Text          = "Uploading spreadsheet";
                //mConnection_TimeOut = Time.realtimeSinceStartup + 10;
            }
        }
Ejemplo n.º 25
0
        private static void TranslateTerm(string Key, TermData termdata, LanguageSourceData source, int i)
        {
            string sourceText     = null;
            string sourceLangCode = null;

            FindTranslationSource(Key, termdata, source.mLanguages[i].Code, null, out sourceText, out sourceLangCode);

            var term           = termdata;
            var specialization = GUI_SelectedSpecialization;
            var langIdx        = i;
            var i2source       = source;

            Translate(sourceText, ref termdata, source.mLanguages[i].Code, (translation, error) =>
            {
                term.SetTranslation(langIdx, translation, specialization);
                i2source.Editor_SetDirty();
            }, specialization);
        }
Ejemplo n.º 26
0
        public static TermData GetTermData(string term, out LanguageSourceData source)
        {
            InitializeIfNeeded();

            TermData data;

            for (int i = 0, imax = Sources.Count; i < imax; ++i)
            {
                data = Sources[i].GetTermData(term);
                if (data != null)
                {
                    source = Sources[i];
                    return(data);
                }
            }

            source = null;
            return(null);
        }
        void Google_OnNewSpreadsheet(string Result, string Error)
        {
            if (!string.IsNullOrEmpty(Error))
            {
                ShowError("Unable to access google");
                return;
            }
            if (Result == "Wrong Password")
            {
                ShowError(Result);
                return;
            }

            try
            {
                var data = SimpleJSON.JSON.Parse(Result).AsObject;

                string name = data["name"];
                string key  = data["id"];

                serializedObject.Update();
                mProp_Google_SpreadsheetKey.stringValue  = key;
                mProp_Google_SpreadsheetName.stringValue = name;
                serializedObject.ApplyModifiedProperties();
                mGoogleSpreadsheets[name] = key;

                LanguageSourceData source = GetSourceData();
                if (source.mTerms.Count > 0 || source.mLanguages.Count > 0)
                {
                    Export_Google(eSpreadsheetUpdateMode.Replace);
                }
                else
                if (EditorPrefs.GetBool("I2Loc OpenDataSourceAfterExport", true))
                {
                    OpenGoogleSpreadsheet(key);
                }
            }
            catch (Exception e)
            {
                ShowError(e.Message);
            }
        }
Ejemplo n.º 28
0
        void OnGUI_KeysList_AddKey()
        {
            GUILayout.BeginHorizontal();
            GUI.color = Color.Lerp(Color.gray, Color.white, 0.5f);
            bool bWasEnabled = (mTermsList_NewTerm != null);
            bool bEnabled    = !GUILayout.Toggle(!bWasEnabled, "+", EditorStyles.toolbarButton, GUILayout.Width(30));

            GUI.color = Color.white;

            if (bWasEnabled && !bEnabled)
            {
                mTermsList_NewTerm = null;
            }
            if (!bWasEnabled && bEnabled)
            {
                mTermsList_NewTerm = string.Empty;
            }

            if (bEnabled)
            {
                GUILayout.BeginHorizontal(EditorStyles.toolbar);
                mTermsList_NewTerm = EditorGUILayout.TextField(mTermsList_NewTerm, EditorStyles.toolbarTextField, GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();

                LanguageSourceData.ValidateFullTerm(ref mTermsList_NewTerm);
                if (string.IsNullOrEmpty(mTermsList_NewTerm) || mLanguageSource.ContainsTerm(mTermsList_NewTerm) || mTermsList_NewTerm == "-")
                {
                    GUI.enabled = false;
                }

                if (TestButton(eTest_ActionType.Button_AddTerm_InTermsList, "Create Key", "toolbarbutton", GUILayout.ExpandWidth(false)))
                {
                    AddLocalTerm(mTermsList_NewTerm);
                    SelectTerm(mTermsList_NewTerm);
                    ClearErrors();
                    mTermsList_NewTerm = null;
                    SetAllTerms_When_InferredTerms_IsInSource();
                }
                GUI.enabled = true;
            }
            GUILayout.EndHorizontal();
        }
        void Import_CSV(string FileName, eSpreadsheetUpdateMode UpdateMode)
        {
            LanguageSourceData source = GetSourceData();
            var encoding = System.Text.Encoding.GetEncoding(mProp_Spreadsheet_LocalCSVEncoding.stringValue);

            if (encoding == null)
            {
                encoding = System.Text.Encoding.UTF8;
            }
            string CSVstring = LocalizationReader.ReadCSVfile(FileName, encoding);

            char   Separator = mProp_Spreadsheet_LocalCSVSeparator.stringValue.Length > 0 ? mProp_Spreadsheet_LocalCSVSeparator.stringValue[0] : ',';
            string sError    = source.Import_CSV(string.Empty, CSVstring, UpdateMode, Separator);

            if (!string.IsNullOrEmpty(sError))
            {
                ShowError(sError);
            }

            mSelectedCategories = source.GetCategories();
        }
        internal static void AddSource(LanguageSourceData Source)
        {
            if (Sources.Contains(Source))
            {
                return;
            }

            Sources.Add(Source);

            if (Source.HasGoogleSpreadsheet() && Source.GoogleUpdateFrequency != LanguageSourceData.eGoogleUpdateFrequency.Never && LocalizationManager.AllowSyncFromGoogle(Source))
            {
                #if !UNITY_EDITOR
                Source.Import_Google_FromCache();
                bool justCheck = false;
                #else
                bool justCheck = true;
                #endif
                if (Source.GoogleUpdateDelay > 0)
                {
                    CoroutineManager.Start(Delayed_Import_Google(Source, Source.GoogleUpdateDelay, justCheck));
                }
                else
                {
                    Source.Import_Google(false, justCheck);
                }
            }

            //if (force)
            {
                for (int i = 0; i < Source.mLanguages.Count(); ++i)
                {
                    Source.mLanguages[i].SetLoaded(true);
                }
            }

            if (Source.mDictionary.Count == 0)
            {
                Source.UpdateDictionary(true);
            }
        }