示例#1
0
        public static void Reload()
        {
            string[] localisationFiles = GetLocaleFiles();
            Match    m;

            foreach (string fileName in localisationFiles)
            {
                string[] fileContents = new string[] { };
                fileContents = File.ReadAllLines(fileName);

                foreach (string line in fileContents)
                {
                    m = Regex.Match(line, @"\s*(.*):\d ""(.*)""");
                    if (!m.Success)
                    {
                        continue;
                    }

                    string key = m.Groups[1].Value;
                    string val = m.Groups[2].Value;

                    LocaleItem l = new LocaleItem(val, fileName, false);

                    dict.AddOrSet(key, l);
                }
            }
        }
示例#2
0
        public static bool Update(string key, string value, LocaleType type)
        {
            LocaleItem li;

            if (!Exists(key))
            {
                string path;
                switch (type)
                {
                case LocaleType.VictoryPointName: {
                    path = @$ "{basePath}{localeFileLocation}\ttr_victory_points_l_english.yml";
                    break;
                }

                case LocaleType.StateName: {
                    path = @$ "{basePath}{localeFileLocation}\ttr_state_names_l_english.yml";
                    break;
                }

                default: {
                    path = @$ "{basePath}{localeFileLocation}\ttr_misc_l_english.yml";
                    break;
                }
                }
                li = new LocaleItem(value, path, true);
                dict.AddOrSet(key, li);
                return(true);
            }

            if (IsLocaleVanilla(dict[key]))
            {
                string path;
                switch (type)
                {
                case LocaleType.VictoryPointName: {
                    path = @$ "{basePath}{localeFileLocation}\replace\ttr_victory_points_replace_l_english.yml";
                    break;
                }

                case LocaleType.StateName: {
                    path = @$ "{basePath}{localeFileLocation}\replace\ttr_state_names_replace_l_english.yml";
                    break;
                }

                default: {
                    path = @$ "{basePath}{localeFileLocation}\replace\ttr_misc_replace_l_english.yml";
                    break;
                }
                }
                li = new LocaleItem(value, path, true);
                dict.AddOrSet(key, li);
                return(true);
            }

            li        = new LocaleItem(value, dict[key].Source, true);
            dict[key] = li;
            return(true);
        }
示例#3
0
 public static bool IsLocaleVanilla(LocaleItem li)
 {
     return(li.Source.Contains(vanillaLocaleFileLocation));
 }