private void btnAppendTranslation_Click(object sender, RoutedEventArgs e) { lstTranslationDict.ItemsSource = null; var ofd = new OpenFileDialog(); ofd.Filter = "Supported Files|*.xlsx;*.xaml;*.resx|Excel Files|*.xlsx|XAML Files|*.xaml|Resource Files|*.resx"; ofd.Multiselect = false; if (ofd.ShowDialog().Value) { var filename = ofd.FileName; TranslationDict trans = null; if (filename.EndsWith(".xlsx")) { trans = StringResourceHelper.LoadFromXlsx(filename, KEY_INDEX, tMap); } else if (filename.EndsWith(".xaml")) { trans = StringResourceHelper.LoadFromXaml(filename, transLang); } else if (filename.EndsWith(".resx")) { trans = StringResourceHelper.LoadFromResx(filename, transLang); } else { trans = new TranslationDict(); } Dict.Combine(trans); } lstTranslationDict.ItemsSource = Dict.Keys; }
private void btnSaveTargetFile_Click(object sender, RoutedEventArgs e) { if (Dict.Count == 0) { MessageBox.Show(this, "Translation dict is empty"); return; } var targetFile = tbTargetFile.Text; if (string.IsNullOrWhiteSpace(targetFile)) { MessageBox.Show(this, "Target filename is empty"); return; } if (targetFile.EndsWith(".resx")) { StringResourceHelper.ReplaceResx(Dict, transLang, tbSourceFile.Text, targetFile); } else if (targetFile.EndsWith(".xaml")) { StringResourceHelper.ReplaceXaml(Dict, transLang, tbSourceFile.Text, targetFile); } }
private void btnExportTranslation_Click(object sender, RoutedEventArgs e) { if (Dict.Count == 0) { MessageBox.Show(this, "Translation dict is empty"); return; } var sfd = new SaveFileDialog(); sfd.Filter = "Excel Files|*.xlsx"; sfd.AddExtension = true; if (sfd.ShowDialog().Value) { if (File.Exists(sfd.FileName)) { File.Delete(sfd.FileName); } StringResourceHelper.SaveAsXlsx(Dict, sfd.FileName); } }