void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                if (!isInitialized)
                {
                    Initialize();
                }

                if (createListContextMenu == null ||
                    createListAdaptor == null ||
                    settingsContextMenu == null ||
                    settingsAdaptor == null ||
                    languageListAdaptor == null ||
                    languageListContextMenu == null)
                {
                    InitializeCultureCollections(true);
                }

                undoManager.CheckUndo();

                //Show settings
                ReorderableListGUI.Title("Smart Localization");
                EditorGUILayout.Space();

                ShowCreateAndSettingsActions();

                ShowCreatedLanguages();

                undoManager.CheckDirty();
            }
        }
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                if (chosenCulture == null)
                {
                    this.Close();
                }

                GUILayout.Label("Import Language", EditorStyles.boldLabel);
                GUILayout.Label("Language to Import: " + chosenCulture.englishName + " - " + chosenCulture.languageCode);

                chosenFileFormat = EditorGUILayout.Popup("File Format", chosenFileFormat, availableFileFormats);

                if (availableFileFormats[chosenFileFormat] == csvFileEnding)
                {
                    delimiter = (CSVParser.Delimiter)EditorGUILayout.EnumPopup("Delimiter", delimiter);
                }

                if (GUILayout.Button("Import"))
                {
                    OnImportClicked();
                }
            }
        }
        void OnGUI()
        {
            if (localizedObjectContextMenu == null ||
                localizedObjectAdaptor == null ||
                settingsContextMenu == null ||
                settingsAdaptor == null)
            {
                Initialize();
            }


            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                ReorderableListGUI.Title("Edit Root Values");
                EditorGUILayout.Space();

                settingsContextMenu.Draw(settingsAdaptor);

                bool shouldRepaint = listColumns.DrawColumns();
                scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
                localizedObjectContextMenu.Draw(localizedObjectAdaptor);
                EditorGUILayout.EndScrollView();

                if (guiChanged)
                {
                    GUILayout.Label("- You have unsaved changes", EditorStyles.miniLabel);
                }

                //If any changes to the gui is made
                if (GUI.changed)
                {
                    guiChanged = true;
                }

                GUILayout.Label("Save Changes", EditorStyles.boldLabel);
                GUILayout.Label("Remember to always press save when you have changed values", EditorStyles.miniLabel);
                if (GUILayout.Button("Save Root Language File"))
                {
                    SaveRootLanguageFile();
                    guiChanged = false;
                    GUIUtility.keyboardControl = 0;
                }

                if (shouldRepaint)
                {
                    Repaint();
                }
            }
        }
Exemple #4
0
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                GUILayout.Label("Update Language from file", EditorStyles.boldLabel);
                GUILayout.Label("Language to Update: " + chosenCulture.englishName + " - " + chosenCulture.languageCode);
                chosenFileFormat = EditorGUILayout.Popup("File Format", chosenFileFormat, availableFileFormats);

                if (availableFileFormats[chosenFileFormat] == csvFileEnding)
                {
                    delimiter = (CSVParser.Delimiter)EditorGUILayout.EnumPopup("Delimiter", delimiter);
                }

                if (GUILayout.Button("Update"))
                {
                    OnUpdateClicked();
                }
            }
        }
        void OnGUI()
        {
            if (this.parentWindow == null)
            {
                this.Close();
            }

            if (LocalizationWindowUtility.ShouldShowWindow())
            {
                if (updateMedhod == BulkUpdateMethod.Import)
                {
                    GUILayout.Label("Import all languages from single file", EditorStyles.boldLabel);
                    ShowCommonGUI();
                    ShowImportGUI();
                }
                else
                {
                    GUILayout.Label("Export all languages to single file", EditorStyles.boldLabel);
                    ShowCommonGUI();
                    ShowExportGUI();
                }
            }
        }
Exemple #6
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);
                }
            }
        }
        void OnGUI()
        {
            if (LocalizationWindowUtility.ShouldShowWindow(true))
            {
                if (Application.isPlaying)
                {
                    if (currentCultureInfo == null ||
                        (LanguageManager.HasInstance && currentCultureInfo.languageCode != LanguageManager.Instance.CurrentlyLoadedCulture.languageCode))
                    {
                        if (LanguageManager.HasInstance)
                        {
                            SmartCultureInfo currentLanguage = LanguageManager.Instance.GetCultureInfo(LanguageManager.Instance.CurrentlyLoadedCulture.languageCode);
                            if (currentLanguage == null)
                            {
                                return;
                            }

                            Initialize(currentLanguage);
                        }
                        else
                        {
                            GUILayout.Label("There is no LanguageManager in the scene. Smart Localization Translation Window cannot be used at runtime without it.", EditorStyles.boldLabel);
                            return;
                        }
                    }
                    else if (rootValues == null && currentCultureInfo != null)
                    {
                        Initialize(currentCultureInfo);
                    }
                }
                else if (rootValues == null)
                {
                    if (currentCultureInfo != null)
                    {
                        Initialize(currentCultureInfo, true);
                    }
                    else
                    {
                        this.Close();
                        return;
                    }
                }

                if (!rootFileChanged)
                {
                    DrawMainTranslationView();
                }
                else
                {
                    //The root file did change, which means that you have to reload. A key might have changed
                    //We can't have language files with different keys
                    GUILayout.Label("The root file might have changed", EditorStyles.boldLabel);
                    GUILayout.Label("The root file did save, which means that you have to reload. A key might have changed.", EditorStyles.miniLabel);
                    GUILayout.Label("You can't have language files with different keys", EditorStyles.miniLabel);
                    if (GUILayout.Button("Reload Language File"))
                    {
                        ReloadLanguage();
                    }
                }
            }
        }