예제 #1
0
        public void SaveWord(string key, string[] data)
        {
#if UNITY_EDITOR
            bool isKeyExist = false;
            Localizator.Keys.ForEach((string oldKey) =>
            {
                isKeyExist |= string.Equals(oldKey, key, System.StringComparison.OrdinalIgnoreCase);
            });

            if (isKeyExist)
            {
                Debug.LogError("Key " + key + " is already in use!");
                return;
            }

            string keyValue = string.Empty;
            for (int i = 0; i < data.Length; i++)
            {
                keyValue = string.Format("\n'{0}' : '{1}'", key, data[i]);
                File.AppendAllText(string.Format(Application.dataPath + "/Resources/Languages/{0}.txt", Localizator.Languages[i]), keyValue);
            }

            Debug.Log("Word " + key + " has been writen!");
            AssetDatabase.Refresh();

            Localizator.Init();
#endif
        }
 private void OnEnable()
 {
     if (instance == null)
     {
         instance = (Localizator)target;
     }
     SScript          = serializedObject.FindProperty("m_Script");
     Defines          = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
     instance.IsSteam = Defines.Contains("STEAM_APP");
     parserIndex      = instance.ParserIndex;
 }
예제 #3
0
        public void SaveWord()
        {
#if UNITY_EDITOR
            string keyValue = string.Empty;
            for (int i = 0; i < NewWords.Length; i++)
            {
                keyValue = string.Format("\n'{0}' : '{1}'", NewKey, NewWords[i]);
                File.AppendAllText(string.Format(Application.dataPath + "/Resources/Languages/{0}.txt", Localizator.Languages[i]), keyValue);
            }

            webWordsAppender.ShowWordWritten();

            Localizator.Init();
#endif
        }
예제 #4
0
        public void SaveDeleted()
        {
#if UNITY_EDITOR
            string newText = string.Empty;
            string key     = "'" + OldKey + "'";

            for (int i = 0; i < Localizator.Languages.Count; i++)
            {
                TextAsset text = Resources.Load <TextAsset>("Languages/" + Localizator.Languages[i]);
                if (text != null)
                {
                    int startIndex = text.text.IndexOf(key, System.StringComparison.OrdinalIgnoreCase);
                    if (startIndex > -1)
                    {
                        int endIndex = text.text.IndexOf("\n", startIndex, System.StringComparison.OrdinalIgnoreCase);
                        if (endIndex < 0)
                        {
                            endIndex = text.text.Length;
                        }
                        newText = text.text.Remove(startIndex - 1, endIndex - startIndex + 1);
                        System.IO.File.WriteAllText(string.Format(Application.dataPath + "/Resources/Languages/{0}.txt", Localizator.Languages[i]), newText);
                    }
                    else
                    {
                        Debug.LogWarning("No key: " + key);
                    }
                }
                else
                {
                    Debug.LogWarning("No file: " + "Languages/" + Localizator.Languages[i]);
                }
            }

            webWordsEraser.ShowWordErased();

            Localizator.Invoke("Init", 0.1f);
#endif
        }
예제 #5
0
 public CsvParser(Localizator localizator)
 {
     this.Localizator = localizator;
 }
예제 #6
0
 public WebLanguageParser(Localizator localizator)
 {
     this.Localizator = localizator;
 }