Exemple #1
0
        /// <summary>
        /// Creates a localized string from a .INI file.
        /// </summary>
        /// <param name="ini">The .ini file to load from.</param>
        /// <param name="section">The section in which the string is stored.</param>
        /// <param name="key">The key to load from. Languages others than <see cref="Toolbox.DEFAULT_LANGUAGE"/> are loaded from keys with the name of the language appended (e.g. "mystring.lituanian")</param>
        public LocalizedString(INIFile ini, string section, string key)
        {
            Strings = new Dictionary <string, string> {
                { Toolbox.DEFAULT_LANGUAGE, ini.GetValue <string>(section, key) }
            };

            foreach (string k in ini.GetKeysInSection(section))
            {
                if (!k.StartsWith(key + "."))
                {
                    continue;
                }
                string language = k.Substring(k.Length + 1).ToLowerInvariant();
                if (Strings.ContainsKey(language))
                {
                    continue;
                }
                Strings.Add(language, ini.GetValue <string>(section, k));
            }
        }