CheckAvailableLanguages() 공개 정적인 메소드

Checks the available languages.
public static CheckAvailableLanguages ( List availableLanguages, List notAvailableLanguages, List notAvailableLanguagesEnglishNames ) : void
availableLanguages List
notAvailableLanguages List
notAvailableLanguagesEnglishNames List
리턴 void
예제 #1
0
    public void Initialize()
    {
        // Instantiate Undo Manager
        if (undoManager == null)
        {
            undoManager = new HOEditorUndoManager(this, "Smart Localization - Main Window");
        }
        if (microsoftTranslator == null)
        {
            microsoftTranslator = new MicrosoftTranslatorManager();

            //cws == Cry Wolf Studios
            //mt == Microsoft Translator
            if (EditorPrefs.HasKey("cws_mtClientID") && EditorPrefs.HasKey("cws_mtClientSecret") && EditorPrefs.HasKey("cws_mtKeepAuthenticated"))
            {
                mtCliendID     = EditorPrefs.GetString("cws_mtClientID");
                mtCliendSecret = EditorPrefs.GetString("cws_mtClientSecret");
                keepTranslatorAuthenticated = EditorPrefs.GetBool("cws_mtKeepAuthenticated");
            }

            //Authenticate on enable
            if (keepTranslatorAuthenticated)
            {
                microsoftTranslator.GetAccessToken(mtCliendID, mtCliendSecret);
            }
        }

        if (availableLanguages == null || availableLanguages.Count < 1)
        {
            LocFileUtility.CheckAvailableLanguages(availableLanguages, notAvailableLanguages, notAvailableLanguagesEnglishNames);
        }
    }
예제 #2
0
    /// <summary>
    /// Creates a new language. Gets the languagename and passes it over to LocFileUtility.CreateNewLanguage
    /// </summary>
    private void CreateNewLanguage(string englishName)
    {
        string languageName = "ERROR";

        //Find the chosen culture name
        foreach (CultureInfo info in notAvailableLanguages)
        {
            if (info.EnglishName == englishName)
            {
                languageName = info.Name;
                break;
            }
        }

        if (languageName == "ERROR")
        {
            Debug.Log("ERROR:Couldn't create the language: " + englishName);
            return;
        }
        LocFileUtility.CreateNewLanguage(languageName);

        //Update the available languages
        LocFileUtility.CheckAvailableLanguages(availableLanguages, notAvailableLanguages, notAvailableLanguagesEnglishNames);
    }
예제 #3
0
    void OnGUI()
    {
        if (EditorWindowUtility.ShowWindow())
        {
            GUILayout.Label("Settings", EditorStyles.boldLabel);
            if (!LocFileUtility.CheckIfRootLanguageFileExists())
            {
                if (GUILayout.Button("Create New Localization System"))
                {
                    LocFileUtility.CreateRootResourceFile();
                }
            }
            else
            {
                undoManager.CheckUndo();
                if (GUILayout.Button("Refresh"))
                {
                    LocFileUtility.CheckAvailableLanguages(availableLanguages, notAvailableLanguages, notAvailableLanguagesEnglishNames);
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Microsoft Translator Settings", EditorStyles.boldLabel, GUILayout.Width(200));
                if (microsoftTranslator.IsInitialized)
                {
                    GUILayout.Label(" - Authenticated!", EditorStyles.miniLabel);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Client ID:", GUILayout.Width(70));
                mtCliendID = EditorGUILayout.TextField(mtCliendID);
                GUILayout.Label("Client Secret:", GUILayout.Width(100));
                mtCliendSecret = EditorGUILayout.TextField(mtCliendSecret);
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Save", GUILayout.Width(50)))
                {
                    SaveMicrosoftTranslatorSettings();
                    if (!microsoftTranslator.IsInitialized)
                    {
                        microsoftTranslator.GetAccessToken(mtCliendID, mtCliendSecret);
                    }
                }
                if (!microsoftTranslator.IsInitialized)
                {
                    if (GUILayout.Button("Authenticate!", GUILayout.Width(150)))
                    {
                        microsoftTranslator.GetAccessToken(mtCliendID, mtCliendSecret);
                    }
                }
                keepTranslatorAuthenticated = EditorGUILayout.Toggle("Keep Authenticated", keepTranslatorAuthenticated);
                EditorGUILayout.EndHorizontal();

                GUILayout.Label("Edit Root Language File", EditorStyles.boldLabel);
                if (GUILayout.Button("Edit"))
                {
                    ShowRootEditWindow(LocFileUtility.LoadParsedLanguageFile(null));
                }

                GUILayout.Label("Create new language", EditorStyles.boldLabel);
                chosenCreateNewCultureValue = EditorGUILayout.Popup(chosenCreateNewCultureValue, notAvailableLanguagesEnglishNames.ToArray());
                if (GUILayout.Button("Create Language"))
                {
                    CreateNewLanguage(notAvailableLanguagesEnglishNames[chosenCreateNewCultureValue]);
                }

                GUILayout.Label("Translate Languages", EditorStyles.boldLabel);
                //Start the scroll view
                scrollPosition = GUILayout.BeginScrollView(scrollPosition);
                bool languageDeleted = false;
                foreach (CultureInfo info in availableLanguages)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button(info.EnglishName + " - " + info.Name))
                    {
                        //Open language edit window
                        ShowTranslateWindow(info);
                    }
                    if (GUILayout.Button("Delete", GUILayout.Width(60)))
                    {
                        LocFileUtility.DeleteLanguage(info);
                        languageDeleted = true;
                        break;
                    }
                    EditorGUILayout.EndHorizontal();
                }

                if (languageDeleted)                //Refresh
                {
                    LocFileUtility.CheckAvailableLanguages(availableLanguages, notAvailableLanguages, notAvailableLanguagesEnglishNames);
                }

                //End the scroll view
                GUILayout.EndScrollView();
                undoManager.CheckDirty();
            }
        }
    }