private void LoadLocalization() { OpenFileDialog openFileDialog = new OpenFileDialog() { Title = "Select [lang].xaml file", Filter = "Xaml files|*.xaml" }; if (openFileDialog.ShowDialog() == true) { var fname = openFileDialog.FileName; var basename = Path.GetFileNameWithoutExtension(fname); if (!LocalizedString.Languages.Contains(basename, StringComparer.InvariantCultureIgnoreCase)) { MessageBox.Show("Filename must be XXX.xaml, with XXX being your language code. The file selected does not match a supported language."); return; } //Wipe existing strings for that lang foreach (var cat in LocalizationCategories) { foreach (var ls in cat.LocalizedStringsForSection) { switch (basename) { case "rus": ls.RUS = null; break; case "deu": ls.DEU = null; break; case "pol": ls.POL = null; break; case "fra": ls.FRA = null; break; case "esn": ls.ESN = null; break; case "bra": ls.BRA = null; break; } } } //Load lang from file var dict = new Dictionary <string, string>(); dict[basename] = File.ReadAllText(fname); parseLocalizations(LocalizationCategories.ToList(), dict); MessageBox.Show("Loaded localization for " + basename + "."); } }
/// <summary> /// Returns all localization categories /// </summary> /// <returns></returns> public List <LocalizationCategory> GetAllCategories() { return(LocalizationCategories.ToList()); }