示例#1
0
    /// <summary>
    /// Load the specified text file and activate the localization.
    /// </summary>

    void Load(string fileName)
    {
        mLanguage = fileName;
        PlayerPrefs.SetString("Language", mLanguage);

        string[] itemList = ResourceManager.LoadText(fileName);
        if (itemList != null)
        {
            char[] separator = new char[] { '=' };

            mDictionary.Clear();

            int l = itemList.Length;
            for (int i = 0; i < l; ++i)
            {
                if (itemList[i].StartsWith("//"))
                {
                    continue;
                }

                string[] split = itemList[i].Split(separator, System.StringSplitOptions.RemoveEmptyEntries);
                if (split.Length == 2)
                {
                    string key = split[0].Trim();
                    string val = split[1].Trim().Replace("\\n", "\n");
                    mDictionary[key] = val;
                }
            }
        }

        NGUIRoot.Broadcast("OnLocalize", this);
        forceUpdate = false;
    }
示例#2
0
    /// <summary>
    /// Load the specified asset and activate the localization.
    /// </summary>

    void Load(TextAsset asset)
    {
        mLanguage = asset.name;
        PlayerPrefs.SetString("Language", mLanguage);
        ByteReader reader = new ByteReader(asset);

        mDictionary = reader.ReadDictionary();
        NGUIRoot.Broadcast("OnLocalize", this);
        forceUpdate = false;
    }