Beispiel #1
0
 public static void select_lang(string code) => selected = get_lang(code);
Beispiel #2
0
        public static void load_lang_xml(string file)
        {
            lang l = nulllang;
            Dictionary <string, dynamic> translations = new Dictionary <string, dynamic>();
            XmlReader xml = XmlReader.Create(file);

            while (xml.Read())
            {
                if (xml.NodeType == XmlNodeType.Element)
                {
                    if (xml.Name == "lang")
                    {
                        l = new lang(xml.GetAttribute("code"), xml.GetAttribute("name"), xml.GetAttribute("version"));
                    }
                    else if (xml.Name == "translation")
                    {
                        string  name = xml.GetAttribute("name");
                        string  type = xml.GetAttribute("type");
                        string  val  = xml.GetAttribute("value");
                        dynamic v    = "$ERROR%WHAT&THE/HELL§";
                        switch (type)
                        {
                        case "str_arr": v = val.Split('\\'); break;

                        case "str": v = val; break;

                        case "int": v = int.Parse(val); break;

                        case "uint": v = uint.Parse(val); break;

                        case "short": v = short.Parse(val); break;

                        case "ushort": v = ushort.Parse(val); break;

                        case "long": v = long.Parse(val); break;

                        case "ulong": v = ulong.Parse(val); break;

                        case "byte": v = byte.Parse(val); break;

                        case "sbyte": v = sbyte.Parse(val); break;

                        case "decimal": v = decimal.Parse(val); break;

                        case "bool": v = bool.Parse(val); break;

                        case "char": v = char.Parse(val); break;

                        default:
                            v = $"Bad language translation. " +
                                $"(lang: {l.code}/{l.name}, " +
                                $"name: {name}, " +
                                $"type: {type}, " +
                                $"raw value: {val})"; break;
                        }
                        translations.Add(name, v);
                    }
                }
            }
            langs.Add(l, translations);
        }
Beispiel #3
0
 public bool Equals(lang lang)
 {
     return(lang.code == code && lang.name == name);
 }