Beispiel #1
0
        private void LoadLangs()
        {
            var f = new FileStream(NWResourceManager.GetAppPath() + LANGS_XML, FileMode.Open);

            try {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(f);

                XmlNode root = xmlDocument.DocumentElement;
                if (!root.Name.Equals("langs"))
                {
                    throw new Exception("Its not langs file!");
                }

                XmlNodeList nl = root.SelectNodes("lang");
                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode el = nl[i];
                    try {
                        string name   = (el.Attributes["name"].InnerText);
                        string prefix = (el.Attributes["prefix"].InnerText);

                        fLangs.Add(new LangRec(name, prefix));
                    } catch (Exception ex) {
                        Logger.Write("Locale.loadLangs.1(): " + ex.Message);
                    }
                }
            } catch (Exception ex) {
                Logger.Write("Locale.loadLangs(): " + ex.Message);
            }
        }
Beispiel #2
0
        public bool SetLang(string name)
        {
            int idx = FindLang(name);

            if (idx < 0)
            {
                return(false);
            }
            else
            {
                try {
                    string prefix = LANGS_FOLDER + fLangs[idx].Prefix;
                    string f      = NWResourceManager.GetAppPath() + prefix;
                    LoadLangDB(f + "_db.xml");
                    LoadLangTexts(f + "_texts.xml");
                    LoadLangDialogs(f);
                    return(true);
                } catch (Exception) {
                    return(false);
                }
            }
        }