CamTimer.Language.Language C# (CSharp) Method

Language() static private method

static private Language ( ) : System
return System
        static Language()
        {
            m_strings = new Dictionary<string,string>();
            #if (DEBUG)
            string languageFilename = @"..\..\Languages\" + Settings.Language + ".txt";
            #else
            string languageFilename = Path.Combine(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Languages"), Settings.Language + ".txt");
            #endif

            // load language file
            StreamReader reader = new StreamReader(languageFilename);
            while (!reader.EndOfStream) {
                string line = reader.ReadLine();
                int x = line.IndexOf("=");
                if (x > -1) {
                    if ((line.Substring(0, x) == LanguageString.MainForm_Information_About.ToString()) && (line.IndexOf("%ProductManufacturer%") < 0)) {
                        MessageBox.Show("Language file " + Path.GetFileName(languageFilename) + "/" + LanguageString.MainForm_Information_About.ToString() + " must contain %ProductManufacturer%", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Application.Exit();
                    }
                    m_strings.Add(line.Substring(0, x), line.Substring(x + 1).Replace("%ProductName%", Application.ProductName).Replace("%ProductManufacturer%", Application.CompanyName));
                }
            }

            // validate language file
            LanguageString[] items = (LanguageString[])Enum.GetValues(typeof(LanguageString));
            for (int x = 0; x < items.Length; x++) {
                if (!m_strings.ContainsKey(items[x].ToString())) {
                    MessageBox.Show("Language file " + Path.GetFileName(languageFilename) + " does not contain a definition for " + items[x].ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
        }