Esempio n. 1
0
        public LocalizationManager(string resource)
        {
            appLog_ = ServiceManager.GameServices.GetAppLog();

            var textAsset = Resources.Load <TextAsset>(resource);

            appLog_.LogErrorIfNull(textAsset, resource);

            var lines = textAsset.text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < lines.Length; ++i)
            {
                if (string.IsNullOrEmpty(lines[i]))
                {
                    continue;
                }

                List <string> header = new List <string>();
                var           items  = lines[i].Split('\t');
                if (i == 0)
                {
                    header.AddRange(items);
                    for (int j = 1; j < items.Length; ++j)
                    {
                        string lang = header[j];
                        languageMap_[lang] = new Dictionary <string, string>();
                    }
                }
                else
                {
                    string key = items[0];
                    for (int j = 1; j < items.Length; ++j)
                    {
                        string lang  = header[j];
                        string value = items[j];
                        languageMap_[lang][key] = value;
                    }
                }
            }
        }