public IEntity FindEntityTypeByExternalName(string alias, SpatialType type) { IEntity result = (m_Translator == null ? null : m_Translator.Translate(alias)); if (result != null) { return(result); } // Ask the user to pick a suitable translation EntityTranslationForm dial = new EntityTranslationForm(alias, type); dial.ShowDialog(); result = dial.Result; dial.Dispose(); // Remember what was specified if (result != null) { if (m_Translator == null) { m_Translator = new TranslationFile(); } m_Translator.Add(alias, result); } return(result); }
public JsonResult EditTranslationFile(string id, string contentJson) { var translationFiles = TranslationFile.GetTranslationFiles(); var selectedTranslationFile = translationFiles.Where(x => x.Id == id).FirstOrDefault(); if (selectedTranslationFile == null) { ViewBag.ErrorMessage = "File not found"; return(Json(new ApiResponse() { IsSuccess = false, Message = "Translation file not found" })); } else { selectedTranslationFile.Content = contentJson; selectedTranslationFile.Save(); NccTranslator.LoadTranslations(); return(Json(new ApiResponse() { IsSuccess = true, Message = "Update successful" })); } }
private static void TryInitTranslations() { // file in binary root path var transFilePath = "translations.json"; try { TranslationFile translations = JsonConvert.DeserializeObject <TranslationFile>(File.ReadAllText(transFilePath, Encoding.UTF8)); if (translations == null) { return; } if (translations.Languages != null) { _availableLanguages = translations.Languages.Select(pair => new Language { Code = pair.Key, Name = pair.Value }).ToList(); foreach (var kvp in _availableLanguages) { Helpers.ConsolePrint("NICEHASH", $"Found language: code: {kvp.Code}, name: {kvp.Name}"); } } if (translations.Translations != null) { _entries = translations.Translations; } } catch (Exception e) { Helpers.ConsolePrint("NICEHASH", "Lang error: " + e.Message); } }
private void OdataFileTypes_SelectionChanged(object sender, SelectionChangedEventArgs e) { MessageBoxResult userSel = MessageBoxResult.OK; if (UserChangedTranslation) { userSel = MessageBox.Show("You have modified the translation but not yet saved. If you click on OK, the modifications will be lost. Otherwise click Cancel.", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning); } try { if (userSel == MessageBoxResult.OK) { ComboBox c = (ComboBox)sender; TranslationFile selection = (TranslationFile)c.SelectedItem; string json = File.ReadAllText(selection.Path); Dictionary <string, TranslationElement> elements = JsonConvert.DeserializeObject <Dictionary <string, TranslationElement> >(json); TranslationElementCollection.Clear(); foreach (var element in elements) { element.Value.Id = element.Key; TranslationElementCollection.Add(element.Value); } UserChangedTranslation = false; } } catch (Exception ex) { MessageBox.Show("Failed to load translation with error: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void CreateInstanceOfClass() { // just reference to GitUI MouseWheelRedirector.Active = true; var translatableTypes = TranslationUtl.GetTranslatableTypes(); var testTranslation = new Dictionary <string, TranslationFile>(); foreach (var types in translatableTypes) { var tranlation = new TranslationFile(); foreach (Type type in types.Value) { try { ITranslate obj = TranslationUtl.CreateInstanceOfClass(type) as ITranslate; obj.AddTranslationItems(tranlation); obj.TranslateItems(tranlation); } catch (Exception) { Trace.WriteLine("Problem with class: " + type.FullName); throw; } } testTranslation[types.Key] = tranlation; } }
private void lbSourceTranslation_SelectedIndexChanged(object sender, EventArgs e) { clbTags.Items.Clear(); string srcFile = lbSourceTranslation.SelectedItem as string; if (!string.IsNullOrEmpty(srcFile) && File.Exists(srcFile)) { try { _srcTranslation = new TranslationFile(srcFile, "ro"); } catch (Exception ex) { MessageBox.Show("Failed: " + ex.Message); _srcTranslation = null; return; } if (_srcTranslation != null && _srcTranslation.Items != null) { foreach (TranslationItem ti in _srcTranslation.Items.Values) { clbTags.Items.Add(ti.StringName); } clbTags.Sorted = true; } else { _srcTranslation = null; } } }
private void LoadTranslation() { var dialogResult = LoadFileDialog.ShowDialog(this); if (dialogResult == DialogResult.OK) { if (!CloseAllDocuments()) { return; } var workForm = new WorkingForm(dockTheme, "Cargar traducción", true); TranslationProject project = null; workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; try { project = TranslationProject.Load(LoadFileDialog.FileName, _pluginManager, worker); } catch (UserCancelException e) { args.Cancel = true; } catch (Exception e) { MessageBox.Show(e.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }; workForm.ShowDialog(this); if (workForm.Cancelled) { return; } _project = project; _currentFile = null; _explorer.LoadTree(_project.FileContainers); _project.Save(); Text = $"Translation Framework 2.0 - {_project.Game.Name} - {_project.WorkPath}"; tsbExportProject.Enabled = true; mniFileExport.Enabled = true; tsbSearchInFiles.Enabled = true; mniEditSearchInFiles.Enabled = true; mniBulkTextsExport.Enabled = true; mniBulkTextsImport.Enabled = true; mniBulkImagesExport.Enabled = true; mniBulkImagesImport.Enabled = true; } }
public void CreateInstanceOfClass() { UserEnvironmentInformation.Initialise("", false); var translatableTypes = TranslationUtil.GetTranslatableTypes(); var problems = new List <(string typeName, Exception exception)>(); foreach (var types in translatableTypes.Values) { var translation = new TranslationFile(); foreach (var type in types) { try { var obj = (ITranslate)TranslationUtil.CreateInstanceOfClass(type); obj.AddTranslationItems(translation); obj.TranslateItems(translation); } catch (Exception ex) { problems.Add((type.FullName, ex)); } } } if (problems.Count != 0) { Assert.Fail(string.Join( "\n\n--------\n\n", problems.Select(p => $"Problem with type {p.typeName}\n\n{p.exception}"))); } }
public ActionResult TranslationFiles() { var translator = new NccTranslator(CurrentLanguage); translator.SaveTranslations(); var resourceFileList = TranslationFile.GetTranslationFiles(); return(View(resourceFileList)); }
protected virtual bool OnFileChanged(TranslationFile selectedFile) { if (FileChanged != null) { var cancel = FileChanged.Invoke(selectedFile); return(cancel); } return(false); }
/// <summary> /// 创建一个不具有翻译的新实例。 /// 所有翻译将使用空字符串代替。 /// Initialize a new instance without translations. /// Empty strings will be used instead of the translations. /// </summary> public Zhouyi() { TranslationFile translation = TranslationFile.Empty; Debug.Assert(translation.Check()); this.patternsAndNumbers = new PatternsAndNumbers( translation.Patterns, translation.Numbers); this.trigramsAndHexagrams = new TrigramsAndHexagrams( translation.Hexagrams, translation.Trigrams); }
public void GenerateFile(string outputFilename) { var DestinationFile = new TranslationFile(); FileStream fileStream = new FileStream(_inputFilename, FileMode.Open); using var reader = new StreamReader(fileStream, Encoding.UTF8); string line = reader.ReadLine(); while (line != null) { var IsChecked = false; foreach (var noIndexWord in TranslationConstants.NoIndexWords) { if (IsChecked) { break; } if (line.Contains($"{noIndexWord}[\"")) { var item = GetItemWithNoIndex(line); AddNoIdexWord(DestinationFile, noIndexWord, item); IsChecked = true; } } if (!IsChecked) { if (IsChecked) { break; } foreach (var indexWord in TranslationConstants.IndexWords) { if (line.Contains($"{indexWord}[\"")) { var item = GetItemWithIndex(line); AddIndexWord(DestinationFile, indexWord, item); IsChecked = true; } } } line = reader.ReadLine(); } var text = JsonSerializer.Serialize(DestinationFile, new JsonSerializerOptions { WriteIndented = true, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping }); File.WriteAllText(outputFilename, text); }
protected virtual bool OnFileChanged(TranslationFile selectedFile) { if (FileChanged != null) { var cancel = FileChanged.Invoke(selectedFile); tvGameFiles.BeforeSelect -= tvGameFiles_BeforeSelect; tvGameFiles.Focus(); tvGameFiles.BeforeSelect += tvGameFiles_BeforeSelect; return(cancel); } return(false); }
public void Initialize(string inputFile) { if (!File.Exists(inputFile)) { throw new FileNotFoundException(inputFile); } _config = GetConfig(); _translations = inputFile.FromJson <TranslationFile>(); _translationsFile = inputFile; }
public static IDictionary <string, List <TranslationItemWithCategory> > LoadNeutralItems() { IDictionary <string, TranslationFile> neutralTranslation = new Dictionary <string, TranslationFile>(); try { // Set language to neutral to get neutral translations GitCommands.AppSettings.CurrentTranslation = ""; var translatableTypes = TranslationUtil.GetTranslatableTypes(); foreach (var(key, types) in translatableTypes) { var translation = new TranslationFile(); try { foreach (Type type in types) { try { if (TranslationUtil.CreateInstanceOfClass(type) is ITranslate obj) { obj.AddTranslationItems(translation); if (obj is IDisposable disposable) { disposable.Dispose(); } } } catch { // no-op } } } finally { translation.Sort(); neutralTranslation[key] = translation; } } } finally { // Restore translation GitCommands.AppSettings.CurrentTranslation = null; } return(GetItemsDictionary(neutralTranslation)); }
public ActionResult EditTranslationFile(string id) { var translationFiles = TranslationFile.GetTranslationFiles(); var selectedTranslationFile = translationFiles.Where(x => x.Id == id).FirstOrDefault(); if (selectedTranslationFile == null) { ViewBag.ErrorMessage = "File not found"; return(View(new TranslationFile())); } ViewBag.TranslationFile = selectedTranslationFile; return(View(selectedTranslationFile)); }
public GridView(TranslationFile file) { _file = file; InitializeComponent(); var font = Fonts.FontCollection.GetFont("Noto Sans CJK JP Regular", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); var cellStyle = new DataGridViewCellStyle(); cellStyle.Font = font; SubtitleGridView.RowsDefaultCellStyle = cellStyle; InitScintilla(scintilla1); InitScintilla(scintilla2); }
private void FillNeutralTranslation() { try { //Set language to neutral to get neutral translations GitCommands.AppSettings.CurrentTranslation = ""; var translatableTypes = TranslationUtl.GetTranslatableTypes(); progressBar.Maximum = translatableTypes.Sum(types => types.Value.Count); progressBar.Visible = true; int index = 0; foreach (var types in translatableTypes) { var translation = new TranslationFile(); try { foreach (Type type in types.Value) { ITranslate obj = TranslationUtl.CreateInstanceOfClass(type) as ITranslate; if (obj != null) { obj.AddTranslationItems(translation); } progressBar.Value = index; index++; if (index % 10 == 0) { Update(); } } } finally { translation.Sort(); _neutralTranslation[types.Key] = translation; } } } finally { //Restore translation GitCommands.AppSettings.CurrentTranslation = null; progressBar.Visible = false; } }
internal static void DownloadData(TranslationFile filename) { var url = AppSettings.Default.EOTranslations.AbsoluteUri + "en-US/" + $"{filename}.xml"; var dest = TranslationFolder + $"\\{filename}.xml"; try { using (var client = new WebClient()) { client.DownloadFile(new Uri(url), dest); Logger.Add(2, $"File {filename} updated."); } } catch (Exception e) { Logger.Add(3, $"Failed to update {filename} data. " + e.Message); } }
internal static void DownloadTranslation(TranslationFile filename, string latestVersion) { var url = AppSettings.Default.EOTranslations.AbsoluteUri + "en-US"; try { var r2 = WebRequest.Create(url + $"/{filename}.xml"); using (var resp = r2.GetResponse()) { var doc = XDocument.Load(resp.GetResponseStream()); doc.Save(TranslationFolder + $"\\{filename}.xml"); } Logger.Add(2, $"Updated {filename} translations to v{latestVersion}."); } catch (Exception e) { Logger.Add(3, $"Failed to download {filename}.xml. " + e.Message); } }
public static string CheckDataVersion(TranslationFile filename) { var source = TranslationFolder + $"\\{filename}.xml"; if (!File.Exists(source)) { DownloadData(filename); } Console.WriteLine(source); try { var xml = XDocument.Load(source); return(xml.Root.Attribute("Version").Value); } catch (Exception) { return("0.0.0"); } }
private void loadButton_Click(object sender, EventArgs e) { // Confirm stuff is defined string ntxFile = ntxFileTextBox.Text.Trim(); string translationFile = translationTextBox.Text.Trim(); if (ntxFile.Length == 0) { MessageBox.Show("You must first specify the name of the input file."); return; } // Load any translation file that's been specified if (translationFile.Length > 0) { m_Translator = new TranslationFile(); m_Translator.Load(translationFile); } ForwardingTraceListener trace = new ForwardingTraceListener(ShowLoadProgress); try { statusStrip.Visible = true; loadButton.Enabled = false; closeButton.Enabled = false; Trace.Listeners.Add(trace); LoadNtx(ntxFile); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } finally { Trace.Listeners.Remove(trace); statusStrip.Visible = false; closeButton.Enabled = true; } }
private void AddIndexWord(TranslationFile destinationFile, string indexWord, TranslationItemWithIndex item) { switch (indexWord) { case "et_misc_texts": destinationFile.et_misc_texts.Add(item); break; case "wps_texts": destinationFile.wps_texts.Add(item); break; case "asleap_texts": destinationFile.asleap_texts.Add(item); break; case "jtr_texts": destinationFile.jtr_texts.Add(item); break; case "hashcat_texts": destinationFile.hashcat_texts.Add(item); break; case "aircrack_texts": destinationFile.aircrack_texts.Add(item); break; case "enterprise_texts": destinationFile.enterprise_texts.Add(item); break; case "footer_texts": destinationFile.footer_texts.Add(item); break; case "arr": destinationFile.arr.Add(item); break; } }
public static void SaveTranslation(string targetLanguageCode, IDictionary <string, List <TranslationItemWithCategory> > items, string filename) { var ext = Path.GetExtension(filename); foreach (var pair in items) { var foreignTranslation = new TranslationFile(GitCommands.AppSettings.ProductVersion, "en", targetLanguageCode); foreach (var translateItem in pair.Value) { var item = translateItem.GetTranslationItem(); var ti = new TranslationItem(item.Name, item.Property, item.Source, item.Value); ti.Value = ti.Value ?? String.Empty; foreignTranslation.FindOrAddTranslationCategory(translateItem.Category) .Body.AddTranslationItem(ti); } var newfilename = Path.ChangeExtension(filename, pair.Key + ext); TranslationSerializer.Serialize(foreignTranslation, newfilename); } }
private void LoadFile(TranslationFile filename) { try { switch (filename) { case TranslationFile.Equipment: _equipmentXml = XDocument.Load(_folder + "\\Equipment.xml"); break; case TranslationFile.EquipmentTypes: _equipTypesXml = XDocument.Load(_folder + "\\EquipmentTypes.xml"); break; case TranslationFile.Expeditions: _expeditionsXml = XDocument.Load(_folder + "\\Expeditions.xml"); break; case TranslationFile.Operations: _operationsXml = XDocument.Load(_folder + "\\Operations.xml"); break; case TranslationFile.Quests: _questsXml = XDocument.Load(_folder + "\\Quests.xml"); break; case TranslationFile.Ships: _shipsXml = XDocument.Load(_folder + "\\Ships.xml"); break; case TranslationFile.ShipTypes: _shipTypesXml = XDocument.Load(_folder + "\\ShipTypes.xml"); break; } } catch (Exception ex) { Logger.Add(3, "Could not load translation file: " + ex.Message); } }
public void Update(TranslationFile file, bool isExtract) { var cacheKey = MakeCacheKey(file.SeasonNum, file.Filename); TranslationFile existingFile = null; try { existingFile = Get(file.SeasonNum, file.Filename); } catch { } if (existingFile == null) { cache[cacheKey] = file; } else { // merging var allStrings = existingFile.Strings.ToDictionary(x => x.Address); foreach (var str in file.Strings) { if (!isExtract || !allStrings.TryGetValue(str.Address, out _)) { allStrings[str.Address] = str; } } file.Strings = allStrings .Select(x => x.Value) .OrderBy(x => x.Address, comparer) .ToArray(); } if (file.Strings.Length > 0) { File.WriteAllText(GetPath(file.SeasonNum, file.Filename), JsonConvert.SerializeObject(file, Formatting.Indented), encoding); } cache[cacheKey] = file; }
public IEntity FindEntityTypeByExternalName(string alias, SpatialType type) { IEntity result = (m_Translator==null ? null : m_Translator.Translate(alias)); if (result!=null) return result; // Ask the user to pick a suitable translation EntityTranslationForm dial = new EntityTranslationForm(alias, type); dial.ShowDialog(); result = dial.Result; dial.Dispose(); // Remember what was specified if (result!=null) { if (m_Translator==null) m_Translator = new TranslationFile(); m_Translator.Add(alias, result); } return result; }
private bool ExplorerOnFileChanged(TranslationFile selectedFile) { if (CloseAllDocuments()) { _currentFile = selectedFile; if (_currentFile != null) { _currentFile.Open(dockPanel, dockTheme); _currentFile.FileChanged += SelectedFileChanged; } mniEditSearch.Enabled = _currentFile != null && _currentFile.Type == FileType.TextFile; tsbSearch.Enabled = _currentFile != null && _currentFile.Type == FileType.TextFile; return(false); } mniEditSearch.Enabled = _currentFile != null && _currentFile.Type == FileType.TextFile; tsbSearch.Enabled = _currentFile != null && _currentFile.Type == FileType.TextFile; return(true); }
private List <TranslationFile> GetTranslationFiles(string group, string resourceFolder) { var translationFileList = new List <TranslationFile>(); if (Directory.Exists(resourceFolder)) { var files = Directory.GetFiles(resourceFolder, "*.lang"); foreach (var item in files) { var fi = new FileInfo(item); var tf = new TranslationFile(); tf.Content = System.IO.File.ReadAllText(item); tf.FileName = fi.Name; tf.FullPath = item; tf.Group = group; tf.Culture = TranslationFile.GetCultureFromFileName(fi.Name); tf.Id = Cryptography.GetHash(item); translationFileList.Add(tf); } } return(translationFileList); }
public static void CheckDataVersion(TranslationFile filename, string latestVer) { var source = TranslationFolder + $"\\{filename}.xml"; var currentVer = "0.0.0"; if (!File.Exists(source)) { DownloadData(filename); } try { var xml = XDocument.Load(source); currentVer = xml.Root.Attribute("Version").Value; } catch (Exception e) { Logger.Add(3, "Error while checking translation data. " + e); } if (latestVer != currentVer) { DownloadData(filename); } }
private void AddNoIdexWord(TranslationFile destinationFile, string noIndexWord, TranslationItem item) { switch (noIndexWord) { case "unknown_chipset": destinationFile.unknown_chipset.Add(item); break; case "hintprefix": destinationFile.hintprefix.Add(item); break; case "optionaltool_needed": destinationFile.optionaltool_needed.Add(item); break; case "under_construction": destinationFile.under_construction.Add(item); break; case "possible_package_names_text": destinationFile.possible_package_names_text.Add(item); break; case "disabled_text": destinationFile.disabled_text.Add(item); break; case "reboot_required": destinationFile.reboot_required.Add(item); break; case "docker_image": destinationFile.docker_image.Add(item); break; } }
void ResourceValidationDialog_Load(object sender, EventArgs e) { Dictionary<string, List<TranslationItem[]>> duplicateTranslations = new Dictionary<string, List<TranslationItem[]>>(); foreach (string file in _scanAssemblies) { if (!duplicateTranslations.ContainsKey("en")) { duplicateTranslations["en"] = new List<TranslationItem[]>(); } TranslationFile tf = new TranslationFile(file, "ro"); foreach (TranslationItem ti in tf.Items.Values) { try { TranslationItem conflict = null; if (CheckConflictingResource("en", ti, ref conflict)) { List<TranslationItem[]> lst = duplicateTranslations["en"]; TranslationItem[] pair = new TranslationItem[2] { ti, conflict }; lst.Add(pair); } } catch { } } foreach (string lang in TranslationFile.SupportedLanguages) { if (!duplicateTranslations.ContainsKey(lang)) { duplicateTranslations[lang] = new List<TranslationItem[]>(); } tf = new TranslationFile(file, lang); foreach (TranslationItem ti in tf.Items.Values) { try { TranslationItem conflict = null; if (CheckConflictingResource(lang, ti, ref conflict)) { List<TranslationItem[]> lst = duplicateTranslations[lang]; TranslationItem[] pair = new TranslationItem[2] { ti, conflict }; lst.Add(pair); } } catch { } } } } tvResults.Nodes.Clear(); foreach (KeyValuePair<string, List<TranslationItem[]>> kvp in duplicateTranslations) { TreeNode langNode = tvResults.Nodes.Add(string.Format("{0} - {1} conflict(s) found", kvp.Key, kvp.Value.Count)); List<TranslationItem[]> lst = null; try { lst = kvp.Value.ToList(); lst.Sort(CompareSort); } catch { } foreach (TranslationItem[] cds in lst) { TreeNode conflictNode = langNode.Nodes.Add(cds[0].StringName); conflictNode.Nodes.Add(cds[0].ToString()); conflictNode.Nodes.Add(cds[1].ToString()); } } //tvResults.ExpandAll(); }
private void loadButton_Click(object sender, EventArgs e) { // Confirm stuff is defined string ntxFile = ntxFileTextBox.Text.Trim(); string translationFile = translationTextBox.Text.Trim(); if (ntxFile.Length==0) { MessageBox.Show("You must first specify the name of the input file."); return; } // Load any translation file that's been specified if (translationFile.Length>0) { m_Translator = new TranslationFile(); m_Translator.Load(translationFile); } ForwardingTraceListener trace = new ForwardingTraceListener(ShowLoadProgress); try { statusStrip.Visible = true; loadButton.Enabled = false; closeButton.Enabled = false; Trace.Listeners.Add(trace); LoadNtx(ntxFile); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } finally { Trace.Listeners.Remove(trace); statusStrip.Visible = false; closeButton.Enabled = true; } }
public NtxImportForm() { InitializeComponent(); m_Translator = null; }
private void CreateNewTranslation() { var infos = _pluginManager.GetAllGames(); var form = new NewProjectSettings(dockTheme, infos); var formResult = form.ShowDialog(this); if (formResult == DialogResult.Cancel) { return; } if (!CloseAllDocuments()) { return; } var game = _pluginManager.GetGame(form.SelectedGame); var workFolder = form.WorkFolder; var gameFolder = form.GameFolder; if (Directory.Exists(workFolder)) { var files = Directory.GetFiles(workFolder); var directories = Directory.GetDirectories(workFolder); if (files.Length + directories.Length > 0) { #if DEBUG PathHelper.DeleteDirectory(workFolder); #else MessageBox.Show($"La carpeta {workFolder} no está vacía. Debes elegir una carpeta vacía.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; #endif } } else { Directory.CreateDirectory(workFolder); } var project = new TranslationProject(game, gameFolder, workFolder); var workForm = new WorkingForm(dockTheme, "Nueva traducción"); workForm.DoWork += (sender, args) => { var worker = sender as BackgroundWorker; try { project.ReadTranslationFiles(worker); worker.ReportProgress(-1, "FINALIZADO"); } catch (UserCancelException e) { args.Cancel = true; worker.ReportProgress(-1, "Eliminando ficheros..."); PathHelper.DeleteDirectory(workFolder); worker.ReportProgress(-1, "Terminado"); } #if !DEBUG catch (Exception e) { worker.ReportProgress(0, $"ERROR: {e.Message}\n{e.StackTrace}"); } #endif }; workForm.ShowDialog(this); if (workForm.Cancelled) { return; } _project = project; _explorer.LoadTree(_project.FileContainers); _currentFile = null; _project.Save(); Text = $"Translation Framework 2.0 - {_project.Game.Name} - {_project.WorkPath}"; tsbExportProject.Enabled = true; mniFileExport.Enabled = true; tsbSearchInFiles.Enabled = true; mniEditSearchInFiles.Enabled = true; mniBulkTextsExport.Enabled = true; mniBulkTextsImport.Enabled = true; mniBulkImagesExport.Enabled = true; mniBulkImagesImport.Enabled = true; }
private void StartTask(string sourceFile, string destFile, List<string> tags, bool isMove, bool isDelete) { if (!isDelete) { foreach (string lang in TranslationFile.SupportedLanguages) { TranslationFile srcTranslation = new TranslationFile(sourceFile, lang); TranslationFile destTranslation = new TranslationFile(destFile, lang); foreach (string tag in tags) { TranslationItem ti = srcTranslation.Items[tag]; destTranslation.Items[tag] = ti; } destTranslation.ForceSave(); } } if (isMove || isDelete) { foreach (string lang in TranslationFile.SupportedLanguages) { TranslationFile srcTranslation = new TranslationFile(sourceFile, lang); foreach (string tag in tags) { srcTranslation.Items.Remove(tag); } srcTranslation.ForceSave(); } } }
private void ReloadTranslations() { // Save data first SaveTranslations(); string stringName = string.Empty; if (lvTranslations.SelectedItems.Count == 1) { stringName = lvTranslations.SelectedItems[0].SubItems[0].Text; } lvTranslations.Items.Clear(); string file = lbTranslationFiles.SelectedItem as string; if (!string.IsNullOrEmpty(file) && File.Exists(file)) { try { _tf = new TranslationFile(file, cmbLanguage.Text); } catch (Exception ex) { MessageBox.Show("ReloadTranslations failed: " + ex.Message); _tf = null; } if (_tf != null && _tf.Items != null) { foreach (TranslationItem ti in _tf.Items.Values) { ListViewItem item = new ListViewItem(new string[] { ti.StringName, ti.BaseString, ti.TranslatedString }); item.Tag = ti; lvTranslations.Items.Add(item); } lvTranslations.SelectedItems.Clear(); lvTranslations.Select(); lvTranslations.Focus(); if (!string.IsNullOrEmpty(stringName)) { foreach (ListViewItem lvi in lvTranslations.Items) { if (lvi.SubItems[0].Text == stringName) { lvi.Selected = true; lvi.Focused = true; lvi.EnsureVisible(); break; } } } } } EnableMenus(); }