public void InitializeCultureCollections(bool reloadAllCultures = false)
        {
            if (reloadAllCultures)
            {
                allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
            }

            availableCultures    = LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);
            nonAvailableCultures = LanguageHandlerEditor.GetNonAvailableLanguages(allCultures);

            availableCultures.cultureInfos.Sort((a, b) =>
            {
                return(a.englishName.CompareTo(b.englishName));
            });
            nonAvailableCultures.cultureInfos.Sort((a, b) =>
            {
                return(a.englishName.CompareTo(b.englishName));
            });

            availableCultures.cultureInfos.Insert(0, new SmartCultureInfo(string.Empty, "ROOT", "ROOT", false));

            languageListAdaptor     = new SmartCultureInfoListAdaptor(availableCultures.cultureInfos, DrawAvailableLanguageItem, 28);
            languageListContextMenu = new SmartCultureInfoMenuControl();

            createListAdaptor     = new CreateLanguageListAdaptor(nonAvailableCultures.cultureInfos, DrawCreateLanguageItem, 15);
            createListContextMenu = new CreateLanguageMenuControl();

            settingsAdaptor     = new SettingsListAdaptor(settingsList, DrawSettingsItem, 110);
            settingsContextMenu = new SettingsMenuControl();
        }
Beispiel #2
0
	/// <summary> Deletes the language. </summary>
	public static void DeleteLanguage(SmartCultureInfo cultureInfo)
	{
		string filePath = LocalizationWorkspace.LanguageFilePath(cultureInfo.languageCode);
		if(FileUtility.Exists(filePath))
		{
			FileUtility.Delete(filePath);
			FileUtility.Delete(filePath + LocalizationWorkspace.metaFileEnding);
		}
		//The text file
		filePath = LocalizationWorkspace.ResourcesFolderFilePath() + "/" + LocalizationWorkspace.rootLanguageName + "." + cultureInfo.languageCode + LocalizationWorkspace.txtFileEnding;
		if(FileUtility.Exists(filePath))
		{
			FileUtility.Delete(filePath);
			FileUtility.Delete(filePath + LocalizationWorkspace.metaFileEnding);
		}
		
		//The assets directory
		filePath = LocalizationWorkspace.LanguageRuntimeFolderPath(cultureInfo.languageCode);
		if(Directory.Exists(filePath))
		{
			Directory.Delete(filePath + "/", true);
			FileUtility.Delete(filePath + LocalizationWorkspace.metaFileEnding);
		}

		SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
		LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);
		AssetDatabase.Refresh();
	}
        public void AddCultureToCollection_Success()
        {
            SmartCultureInfoCollection testCollection = new SmartCultureInfoCollection();

            testCollection.AddCultureInfo(new SmartCultureInfo("te-ST", "TEST", "TEEEST", false));

            Assert.AreEqual(1, testCollection.cultureInfos.Count);
        }
        public void AddCultureToCollection_Failure()
        {
            SmartCultureInfoCollection testCollection = new SmartCultureInfoCollection();

            testCollection.AddCultureInfo(null);

            Assert.AreEqual(0, testCollection.cultureInfos.Count);
        }
        /// <summary>
        /// Extension method to serialize a SmartCultureInfoCollection to a given file path using XMLSerializer.
        /// </summary>
        /// <param name="info">The collection to serialize</param>
        /// <param name="fullPath">The full path where the collection will be saved</param>
        public static void Serialize(this SmartCultureInfoCollection info, string fullPath)
        {
            var serializer = new XmlSerializer(typeof(SmartCultureInfoCollection));

            using (XmlTextWriter writer = new XmlTextWriter(fullPath, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                serializer.Serialize(writer, info);
            }
        }
        public void FindCultureInCollection_Success()
        {
            SmartCultureInfoCollection testCollection    = new SmartCultureInfoCollection();
            SmartCultureInfo           cultureInfoToFind = new SmartCultureInfo("te-ST", "TEST", "TEEEST", false);

            testCollection.AddCultureInfo(cultureInfoToFind);

            SmartCultureInfo foundCultureInfo = testCollection.FindCulture(cultureInfoToFind);

            Assert.AreEqual(cultureInfoToFind, foundCultureInfo);
        }
        /// <summary>
        /// Extension method to deserialize a SmartCultureInfoCollection
        /// </summary>
        /// <param name="fullPath">The full path where the serialized SmartCultureInfoCollection can be found</param>
        /// <returns>The deserialized SmartCultureInfoCollection</returns>
        public static SmartCultureInfoCollection Deserialize(string fullPath)
        {
            var serializer = new XmlSerializer(typeof(SmartCultureInfoCollection));
            SmartCultureInfoCollection deserializedCulture = null;

            using (var stream = new FileStream(fullPath, FileMode.Open))
            {
                deserializedCulture = serializer.Deserialize(stream) as SmartCultureInfoCollection;
            }

            return(deserializedCulture);
        }
        public void FindCulture_Success()
        {
            var testCollection = new SmartCultureInfoCollection();
            var chineseOne     = new SmartCultureInfo("zh-CHT", "Chinese", "Chinese", false);
            var chineseTwo     = new SmartCultureInfo("zh-CHS", "Chinese", "Chinese", false);

            testCollection.AddCultureInfo(chineseTwo);
            testCollection.AddCultureInfo(chineseOne);

            var foundCulture = testCollection.FindCulture(chineseTwo);

            Assert.AreEqual(foundCulture, chineseTwo);
        }
Beispiel #9
0
	/// <summary>
	/// Gets a SmartCultureInfoCollection with all the cultures not available in this workspace
	/// </summary>
	/// <param name="allCultures">The list of all the available cultures</param>
	/// <returns>A SmartCultureInfoCollection with all the cultures not available in this workspace</returns>
	public static SmartCultureInfoCollection GetNonAvailableLanguages(SmartCultureInfoCollection allCultures)
	{
		SmartCultureInfoCollection nonCreatedLanguages = new SmartCultureInfoCollection();
		
		foreach(SmartCultureInfo cultureInfo in allCultures.cultureInfos)
		{
			if(!FileUtility.Exists(LocalizationWorkspace.LanguageFilePath(cultureInfo.languageCode)))
			{
				nonCreatedLanguages.AddCultureInfo(cultureInfo);
			}
		}
		
		return nonCreatedLanguages;
	}
        void OnGotAvailableLanguages(bool success, List <string> availableLanguages)
        {
            if (!success)
            {
                return;
            }

            availableTranslateFromLanguages.Clear();
            //Clear the array
            if (availableTranslateLangEnglishNames != null)
            {
                Array.Clear(availableTranslateLangEnglishNames, 0, availableTranslateLangEnglishNames.Length);
                availableTranslateLangEnglishNames = null;
            }

            if (translateFromDictionary != null)
            {
                translateFromDictionary.Clear();
                translateFromDictionary = null;
            }
            translateFromLanguageValue    = 0;
            oldTranslateFromLanguageValue = 0;

            List <string> englishNames = new List <string>();

            englishNames.Add("None");
            if (availableLanguages.Contains(currentCultureInfo.languageCode))
            {
                canLanguageBeTranslated = true;

                SmartCultureInfoCollection allCultures       = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                SmartCultureInfoCollection availableCultures = LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);

                foreach (SmartCultureInfo cultureInfo in availableCultures.cultureInfos)
                {
                    if (cultureInfo.languageCode != currentCultureInfo.languageCode && availableLanguages.Contains(cultureInfo.languageCode))
                    {
                        availableTranslateFromLanguages.Add(cultureInfo);
                        englishNames.Add(cultureInfo.englishName);
                    }
                }
            }
            else
            {
                canLanguageBeTranslated = false;
            }
            availableTranslateLangEnglishNames = englishNames.ToArray();
        }
Beispiel #11
0
	/// <summary>
	/// Checks all the created languages and Saves the AvailableCultures xml.
	/// </summary>
	/// <param name="allCultures">A list of all the available cultures</param>
	/// <returns>A list of all the created languages</returns>
	public static SmartCultureInfoCollection CheckAndSaveAvailableLanguages(SmartCultureInfoCollection allCultures)
	{
		SmartCultureInfoCollection createdCultures = new SmartCultureInfoCollection();
		
		foreach(SmartCultureInfo cultureInfo in allCultures.cultureInfos)
		{
			if(FileUtility.Exists(LocalizationWorkspace.LanguageFilePath(cultureInfo.languageCode)))
			{
				createdCultures.AddCultureInfo(cultureInfo);
			}
		}

		createdCultures.Serialize(LocalizationWorkspace.AvailableCulturesFilePath());
		
		return createdCultures;
	}
Beispiel #12
0
        void SaveRootLanguageFile()
        {
            var changeNewRootKeys   = new Dictionary <string, string>();
            var changeNewRootValues = new Dictionary <string, string>();

            for (int i = 0; i < changedRootKeys.Count; i++)
            {
                SerializableStringPair             rootKey   = changedRootKeys[i];
                SerializableLocalizationObjectPair rootValue = changedRootValues[i];
                //Check for possible duplicates and rename them
                string newKeyValue = LanguageDictionaryHelper.AddNewKeyPersistent(changeNewRootKeys,
                                                                                  rootKey.originalValue,
                                                                                  rootValue.changedValue.GetFullKey(rootKey.changedValue));

                //Check for possible duplicates and rename them(same as above)
                LanguageDictionaryHelper.AddNewKeyPersistent(changeNewRootValues, newKeyValue, rootValue.changedValue.TextValue);
            }

            //Add the full values before saving
            var changeNewRootKeysToSave   = new Dictionary <string, string>();
            var changeNewRootValuesToSave = new Dictionary <string, string>();

            foreach (var rootKey in changeNewRootKeys)
            {
                LocalizedObject thisLocalizedObject = parsedRootValues[rootKey.Key];
                changeNewRootKeysToSave.Add(thisLocalizedObject.GetFullKey(rootKey.Key), rootKey.Value);
                changeNewRootValuesToSave.Add(thisLocalizedObject.GetFullKey(rootKey.Key), changeNewRootValues[rootKey.Key]);
            }



            SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());

            LanguageHandlerEditor.SaveRootLanguageFile(changeNewRootKeysToSave, changeNewRootValuesToSave, LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures));

            //Fire the root language changed event
            if (OnRootFileChanged != null)
            {
                OnRootFileChanged();
            }

            //Reload the window(in case of duplicate keys)
            SetRootValues(LanguageHandlerEditor.LoadParsedLanguageFile(null, true));
        }
        /// <summary>
        /// Generates the SmartCultureInfoCollection xml with all the available language infos and keeps any difference in old data
        /// as well.
        /// </summary>
        /// <returns>If the operation was successful</returns>
        public static bool GenerateCultureInfoCollection(SmartCultureInfoCollection previousCollection)
        {
            if (!DirectoryUtility.Create(CultureInfoDataFolderPath()))
            {
                return(false);
            }

            SmartCultureInfoCollection availableCultures = new SmartCultureInfoCollection();

            availableCultures.version = SmartCultureInfoCollection.LatestVersion;

            if (previousCollection != null)
            {
                //Add all cultures from the previous collection in case any one of them were custom made
                foreach (var cultureInfo in previousCollection.cultureInfos)
                {
                    availableCultures.AddCultureInfo(cultureInfo);
                }
            }

            //Get all the cultures from Microsofts CultureInfo in the System.Globalization namespace
            CultureInfo[] cultureInfos = CultureInfo.GetCultures(System.Globalization.CultureTypes.AllCultures);
            foreach (var cultureInfo in cultureInfos)
            {
                if (availableCultures.FindCulture(cultureInfo.Name) == null)
                {
                    availableCultures.AddCultureInfo(new SmartCultureInfo(cultureInfo.Name, cultureInfo.EnglishName, cultureInfo.NativeName, cultureInfo.TextInfo.IsRightToLeft));
                }
            }

            foreach (var cultureInfo in ExtraCultureInfos)
            {
                if (availableCultures.FindCulture(cultureInfo) == null)
                {
                    availableCultures.AddCultureInfo(new SmartCultureInfo(cultureInfo.languageCode, cultureInfo.englishName, cultureInfo.nativeName, cultureInfo.isRightToLeft));
                }
            }

            availableCultures.Serialize(CultureInfoCollectionFilePath());

            return(true);
        }
Beispiel #14
0
        /// <summary>
        /// Checks .resx files and converts them into text assets that can be used at runtime
        /// </summary>
        public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            //Only use this if there's a localization system created
            if (!LocalizationWorkspace.Exists())
            {
                return;
            }

            foreach (string asset in importedAssets)
            {
                if (asset.EndsWith(LocalizationWorkspace.resXFileEnding))
                {
                    string newFileName = LocalizationWorkspace.ResourcesFolderFilePath() + "/" + Path.GetFileNameWithoutExtension(asset) + LocalizationWorkspace.txtFileEnding;

                    if (!DirectoryUtility.CheckAndCreate(LocalizationWorkspace.ResourcesFolderFilePath()))
                    {
                        return;
                    }

                    //Delete the file if it already exists
                    if (FileUtility.Exists(newFileName))
                    {
                        FileUtility.Delete(newFileName);
                    }

                    string fileData = "";
                    using (StreamReader reader = new StreamReader(asset))
                    {
                        fileData = reader.ReadToEnd();
                    }


                    FileUtility.WriteToFile(newFileName, fileData);

                    SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                    LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);

                    AssetDatabase.Refresh(ImportAssetOptions.Default);
                }
            }
        }
Beispiel #15
0
        void Initialize()
        {
            if (undoManager == null)
            {
                undoManager = new HOEditorUndoManager(this, "SmartLocalization-Main");
            }

            if (availableCultures == null)
            {
                allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());

                if (allCultures.version != SmartCultureInfoCollection.LatestVersion)
                {
                    LocalizationWorkspace.GenerateCultureInfoCollection(allCultures);
                    allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                }
                InitializeCultureCollections();
            }

            if (EditorPrefs.HasKey(MicrosoftTranslatorIDSaveKey) && EditorPrefs.HasKey(MicrosoftTranslatorSecretSaveKey) && EditorPrefs.HasKey(KeepAuthenticatedSaveKey))
            {
                mtClientID     = EditorPrefs.GetString(MicrosoftTranslatorIDSaveKey);
                mtClientSecret = EditorPrefs.GetString(MicrosoftTranslatorSecretSaveKey);
                keepTranslatorAuthenticated = EditorPrefs.GetBool(KeepAuthenticatedSaveKey);
            }

            InitializeTranslator();

            generateAndroidPresence = AndroidStorePresenceGenerator.GenerateStorePresence;
            generateiOSPresence     = IOSStorePresenceGenerator.GenerateStorePresence;

            settingsList.Clear();
            settingsList.Add("SETTINGS");
            settingsList.Add("STOREPRESENCE");
            settingsList.Add("AUTOTRANSLATE");

            isInitialized = true;

            GUIUtility.keyboardControl = 0;
        }
Beispiel #16
0
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                GUILayout.Label("Create a new culture info", EditorStyles.boldLabel);

                languageCode = EditorGUILayout.TextField("Language Code", languageCode);
                if (languageCode != null)
                {
                    languageCode = languageCode.RemoveWhitespace();
                }

                englishName   = EditorGUILayout.TextField("English Name", englishName);
                nativeName    = EditorGUILayout.TextField("Native Name", nativeName);
                isRightToLeft = EditorGUILayout.Toggle("Is Right To Left", isRightToLeft);

                if (GUILayout.Button("Create"))
                {
                    SmartCultureInfo newInfo = new SmartCultureInfo();
                    newInfo.languageCode  = languageCode;
                    newInfo.englishName   = englishName.Trim();
                    newInfo.nativeName    = nativeName.Trim();
                    newInfo.isRightToLeft = isRightToLeft;

                    SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                    if (!allCultures.IsCultureInCollection(newInfo))
                    {
                        allCultures.AddCultureInfo(newInfo);
                        allCultures.Serialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                        LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);

                        showHelpMessage = true;
                        helpMessageType = MessageType.Info;
                        helpMessage     = string.Format("Successfully created language!\n Language Code: {0}\n English Name:{1}\n Native Name:{2}\n IsRightToLeft:{3}",
                                                        newInfo.languageCode, newInfo.englishName, newInfo.nativeName, newInfo.isRightToLeft);

                        if (parentWindow != null)
                        {
                            parentWindow.InitializeCultureCollections(true);
                        }

                        this.Close();
                    }
                    else
                    {
                        SmartCultureInfo conflictingCulture  = allCultures.FindCulture(newInfo);
                        string           conflictingVariable = null;

                        if (conflictingCulture.languageCode.ToLower() == newInfo.languageCode.ToLower())
                        {
                            conflictingVariable = "Language Code:" + newInfo.languageCode;
                        }
                        else if (conflictingCulture.englishName.ToLower() == newInfo.englishName.ToLower())
                        {
                            conflictingVariable = "English Name:" + newInfo.englishName;
                        }

                        showHelpMessage = true;
                        helpMessageType = MessageType.Error;
                        helpMessage     = string.Format("Failed to create language!\n Conflicting variable - {0}\n\n",
                                                        conflictingVariable);

                        helpMessage += string.Format("Conflicting Culture \n Language Code: {0}\n English Name:{1}\n Native Name:{2}",
                                                     conflictingCulture.languageCode, conflictingCulture.englishName, conflictingCulture.nativeName);
                    }
                }

                if (showHelpMessage)
                {
                    EditorGUILayout.HelpBox(helpMessage, helpMessageType);
                }
            }
        }
Beispiel #17
0
	/// <summary>
	/// Saves the root language file and updates all the available languages.
	/// </summary>
	public static void SaveRootLanguageFile(Dictionary<string,string> changedRootKeys, Dictionary<string,string> changedRootValues, SmartCultureInfoCollection availableCultures)
	{
		//The dictionary with all the final changes
		Dictionary<string,string> changedDictionary = new Dictionary<string, string>();
		
		foreach(KeyValuePair<string,string> changedKey in changedRootKeys)
		{
			if(changedKey.Key == changedKey.Value)
			{
				//The key is not changed, just add the key and the changed value to the new dictionary
				LanguageDictionaryHelper.AddNewKeyPersistent(changedDictionary, changedKey.Key, changedRootValues[changedKey.Key]);
			}
			else
			{
				//Add the new key along with the new changed value
				LanguageDictionaryHelper.AddNewKeyPersistent(changedDictionary, changedKey.Value, changedRootValues[changedKey.Key]);
			}
		}
		
		//Look if any keys were deleted,(so that we can delete the created files)
		List<string> deletedKeys = new List<string>();
		IEnumerable<string> originalKeys = LoadLanguageFile(null, true).Keys;
		foreach(string originalKey in originalKeys)
		{
			bool foundMatch = false;
			foreach(KeyValuePair<string,string> changedKey in changedRootKeys)
			{
				if(originalKey == changedKey.Key)
				{
					foundMatch = true;
					break;
				}
			}
			if(!foundMatch)
			{
				deletedKeys.Add(originalKey);
			}
		}
		
		//Save the language file
		SaveLanguageFile(changedDictionary, LocalizationWorkspace.RootLanguageFilePath());
		
		//Change all the key values for all the translated languages
		var changedCultureValues = new Dictionary<string, string>();
		foreach(var cultureInfo in availableCultures.cultureInfos)
		{
			var currentCultureValues = LoadLanguageFile(cultureInfo.languageCode, false);
			foreach(var changedKey in changedRootKeys)
			{
				string currentValue;
				currentCultureValues.TryGetValue(changedKey.Key, out currentValue);
				if(currentValue == null)
				{
					currentValue = "";
				}
				
				//If the key is changed, we need to change the asset names as well
				if(changedKey.Key != changedKey.Value && currentValue != "")
				{
					LocalizedObjectType originalType = LocalizedObject.GetLocalizedObjectType(changedKey.Key);
					LocalizedObjectType changedType = LocalizedObject.GetLocalizedObjectType(changedKey.Value);
					
					if(originalType != changedType)
					{
						//If the type is changed, then delete the asset and reset the value
						DeleteFileFromResources(changedKey.Key, cultureInfo);
						currentValue = "";
					}
					else
					{
						//just rename it otherwise
						RenameFileFromResources(changedKey.Key, changedKey.Value, cultureInfo);
					}
				}
				
				LanguageDictionaryHelper.AddNewKeyPersistent(changedCultureValues, changedKey.Value, currentValue);
			}
			
			//Save the language file
			SaveLanguageFile (changedCultureValues, LocalizationWorkspace.LanguageFilePath(cultureInfo.languageCode));
			changedCultureValues.Clear();
			
			//Remove all the deleted files associated with the deleted keys
			foreach(string deletedKey in deletedKeys)
			{
				Debug.Log("Deleted key!:" + deletedKey);
				DeleteFileFromResources(deletedKey, cultureInfo);
			}
		}
	}
Beispiel #18
0
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                GUILayout.Label("Создать новую информацию о культуре", EditorStyles.boldLabel);

                languageCode = EditorGUILayout.TextField("Код языка", languageCode);
                if (languageCode != null)
                {
                    languageCode = languageCode.RemoveWhitespace();
                }

                englishName   = EditorGUILayout.TextField("Английское имя", englishName);
                nativeName    = EditorGUILayout.TextField("Родное имя", nativeName);
                isRightToLeft = EditorGUILayout.Toggle("Справа налево", isRightToLeft);

                if (GUILayout.Button("Создать"))
                {
                    SmartCultureInfo newInfo = new SmartCultureInfo();
                    newInfo.languageCode  = languageCode;
                    newInfo.englishName   = englishName.Trim();
                    newInfo.nativeName    = nativeName.Trim();
                    newInfo.isRightToLeft = isRightToLeft;

                    SmartCultureInfoCollection allCultures = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                    if (!allCultures.IsCultureInCollection(newInfo))
                    {
                        allCultures.AddCultureInfo(newInfo);
                        allCultures.Serialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                        LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);

                        showHelpMessage = true;
                        helpMessageType = MessageType.Info;
                        helpMessage     = string.Format("Язык успешно создан!\n Код языка: {0}\n Английское имя:{1}\n Родное имя:{2}\n Справа налево:{3}",
                                                        newInfo.languageCode, newInfo.englishName, newInfo.nativeName, newInfo.isRightToLeft);

                        if (parentWindow != null)
                        {
                            parentWindow.InitializeCultureCollections(true);
                        }

                        this.Close();
                    }
                    else
                    {
                        SmartCultureInfo conflictingCulture  = allCultures.FindCulture(newInfo);
                        string           conflictingVariable = null;

                        if (conflictingCulture.languageCode.ToLower() == newInfo.languageCode.ToLower())
                        {
                            conflictingVariable = "Language Code:" + newInfo.languageCode;
                        }
                        else if (conflictingCulture.englishName.ToLower() == newInfo.englishName.ToLower())
                        {
                            conflictingVariable = "English Name:" + newInfo.englishName;
                        }

                        showHelpMessage = true;
                        helpMessageType = MessageType.Error;
                        helpMessage     = string.Format("Не удалось создать язык!\n Конфликтующая переменная - {0}\n\n",
                                                        conflictingVariable);

                        helpMessage += string.Format("Конфликтующая культура \n Код языка: {0}\n Английское имя:{1}\n Родное имя:{2}",
                                                     conflictingCulture.languageCode, conflictingCulture.englishName, conflictingCulture.nativeName);
                    }
                }

                if (showHelpMessage)
                {
                    EditorGUILayout.HelpBox(helpMessage, helpMessageType);
                }
            }
        }
        public void Initialize(SmartCultureInfo thisCultureInfo, bool forceNewLanguage = false)
        {
            if (thisCultureInfo != null)
            {
                if (undoManager == null)
                {
                    // Instantiate Undo Manager
                    undoManager = new HOEditorUndoManager(this, "Smart Localization - Translate Language Window");
                }

                if (thisCultureInfo != null)
                {
                    bool newLanguage = thisCultureInfo != this.currentCultureInfo ? true : false;

                    if (Application.isPlaying || forceNewLanguage)
                    {
                        newLanguage = true;
                    }

                    this.currentCultureInfo = thisCultureInfo;
                    if (loadedLanguageValues == null || loadedLanguageValues.Count < 1 || newLanguage)
                    {
                        InitializeLanguage(thisCultureInfo,
                                           LanguageHandlerEditor.LoadParsedLanguageFile(null, true),
                                           LanguageHandlerEditor.LoadParsedLanguageFile(thisCultureInfo.languageCode,
                                                                                        false));
                    }
                }

                settingsList.Clear();
                settingsList.Add("SETTINGS");
                settingsList.Add("CONVERTLINEBREAK");
                settingsList.Add("WATCHFILE");
                settingsList.Add("AUTOTRANSLATE");
                settingsList.Add("GENERAL");

#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3
                if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.WebPlayer &&
                    EditorUserBuildSettings.activeBuildTarget != BuildTarget.WebPlayerStreamed)
#endif
                {
                    settingsList.Add("SORT");
                }

                settingsList.Add("SEARCH");

                settingsAdaptor     = new SettingsListAdaptor(settingsList, DrawSettingsItem, 20);
                settingsContextMenu = new SettingsMenuControl();

                listColumns = new EditorColumns(0.02f, true);
                listColumns.AddColumn("Copy", 0.1f);
                listColumns.AddColumn("Translate", 0.1f);
                listColumns.AddColumn("Key", 0.21f);
                listColumns.AddColumn("Comment", 0.21f);
                listColumns.AddColumn("Override", 0.07f);
                listColumns.AddColumn("Value", 0.25f);
                listColumns.RecalculateColumnWidths();

                if (EditorPrefs.HasKey(CollapseMultilineSaveKey))
                {
                    collapseMultilineFields = EditorPrefs.GetBool(CollapseMultilineSaveKey);
                }

                GUIUtility.keyboardControl = 0;

                SmartCultureInfoCollection allCultures       = SmartCultureInfoEx.Deserialize(LocalizationWorkspace.CultureInfoCollectionFilePath());
                SmartCultureInfoCollection availableCultures = LanguageHandlerEditor.CheckAndSaveAvailableLanguages(allCultures);
                otherAvailableLanguageCodes.Clear();
                otherAvailableLanguageCodesArray = null;
                foreach (SmartCultureInfo otherCulture in availableCultures.cultureInfos)
                {
                    if (otherCulture.languageCode != thisCultureInfo.languageCode)
                    {
                        otherAvailableLanguageCodes.Add(otherCulture.languageCode);
                    }
                }

                if (otherAvailableLanguageCodes.Count > 0)
                {
                    otherAvailableLanguageCodesArray = otherAvailableLanguageCodes.ToArray();
                }
            }
        }