From e371e37010e762f2addb5d7cf3d903f9153281bb Mon Sep 17 00:00:00 2001 From: Hakoyu Date: Thu, 31 Aug 2023 17:20:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/ModEdit/ModEditWindowVM.cs | 47 ++++++++++++------- VPet.ModMaker/ViewModels/ModMakerWindowVM.cs | 2 +- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs index 3a5da85..ad446d5 100644 --- a/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModEdit/ModEditWindowVM.cs @@ -13,6 +13,7 @@ using System.ComponentModel; using VPet.ModMaker.Views.ModEdit; using System.Windows; using System.IO; +using LinePutScript.Localization.WPF; namespace VPet.ModMaker.ViewModels.ModEdit; @@ -56,21 +57,21 @@ public class ModEditWindowVM { var foodI18n = food.I18nDatas[i18n.Key]; if (i18n.Value.TryGetValue(food.Name.Value, out var i18nName)) - foodI18n.Name.Value = i18nName; + foodI18n.Name.Value = i18nName.Translate(); if (i18n.Value.TryGetValue(food.Description.Value, out var i18nDescription)) - foodI18n.Description.Value = i18nDescription; + foodI18n.Description.Value = i18nDescription.Translate(); } foreach (var lowText in ModInfo.Value.LowTexts) { var lowTextI18n = lowText.I18nDatas[i18n.Key]; if (i18n.Value.TryGetValue(lowText.Name.Value, out var text)) - lowTextI18n.Text.Value = text; + lowTextI18n.Text.Value = text.Translate(); } foreach (var clickText in ModInfo.Value.ClickTexts) { var clickTextI18n = clickText.I18nDatas[i18n.Key]; if (i18n.Value.TryGetValue(clickText.Name.Value, out var text)) - clickTextI18n.Text.Value = text; + clickTextI18n.Text.Value = text.Translate(); } } } @@ -123,7 +124,11 @@ public class ModEditWindowVM private void AddImage() { OpenFileDialog openFileDialog = - new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" }; + new() + { + Title = "选择图片".Translate(), + Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp".Translate() + }; if (openFileDialog.ShowDialog() is true) { ModInfo.Value.Image.Value = Utils.LoadImageToStream(openFileDialog.FileName); @@ -133,7 +138,11 @@ public class ModEditWindowVM private void ChangeImage() { OpenFileDialog openFileDialog = - new() { Title = "选择图片", Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp" }; + new() + { + Title = "选择图片".Translate(), + Filter = $"图片|*.jpg;*.jpeg;*.png;*.bmp".Translate() + }; if (openFileDialog.ShowDialog() is true) { ModInfo.Value.Image.Value?.StreamSource?.Close(); @@ -153,7 +162,7 @@ public class ModEditWindowVM private void EditLang(string oldLang) { var window = new Window_AddLang(); - window.Lang.Value = oldLang; + window.Lang.Value = oldLang.Translate(); window.ShowDialog(); if (window.IsCancel) return; @@ -165,7 +174,10 @@ public class ModEditWindowVM private void RemoveLang(string oldLang) { - if (MessageBox.Show("确定删除吗", "", MessageBoxButton.YesNo) is MessageBoxResult.No) + if ( + MessageBox.Show("确定删除吗".Translate(), "".Translate(), MessageBoxButton.YesNo) + is MessageBoxResult.No + ) return; I18nHelper.Current.CultureNames.Remove(oldLang); } @@ -174,19 +186,19 @@ public class ModEditWindowVM { if (string.IsNullOrEmpty(ModInfo.Value.SourcePath.Value)) { - MessageBox.Show("源路径为空, 请使用 保存至"); + MessageBox.Show("源路径为空, 请使用 保存至".Translate()); return; } try { - ModInfo.Value.SaveTo(Path.GetDirectoryName(ModInfo.Value.SourcePath.Value)); + ModInfo.Value.SaveTo(ModInfo.Value.SourcePath.Value); } catch (Exception ex) { MessageBox.Show($"保存失败 错误信息:\n{ex}"); return; } - MessageBox.Show("保存成功"); + MessageBox.Show("保存成功".Translate()); } private void SaveTo() @@ -194,23 +206,24 @@ public class ModEditWindowVM SaveFileDialog saveFileDialog = new() { - Title = "保存 模组信息文件,并在文件夹内保存模组数据", - Filter = $"LPS文件|*.lps;", - FileName = "info.lps" + Title = "保存 模组信息文件,并在文件夹内保存模组数据".Translate(), + Filter = $"LPS文件|*.lps;".Translate(), + FileName = "info.lps".Translate() }; if (saveFileDialog.ShowDialog() is true) { try { - ModInfo.Value.SaveTo(Path.GetDirectoryName(saveFileDialog.FileName)); - ModInfo.Value.SourcePath.Value = saveFileDialog.FileName; + var path = Path.GetDirectoryName(saveFileDialog.FileName); + ModInfo.Value.SaveTo(path); + ModInfo.Value.SourcePath.Value = path.Translate(); } catch (Exception ex) { MessageBox.Show($"保存失败 错误信息:\n{ex}"); return; } + MessageBox.Show("保存成功".Translate()); } - MessageBox.Show("保存成功"); } } diff --git a/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs b/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs index 37fbe6e..6500bb2 100644 --- a/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs +++ b/VPet.ModMaker/ViewModels/ModMakerWindowVM.cs @@ -65,7 +65,7 @@ public class ModMakerWindowVM public void CreateNewMod() { - ModInfoModel.Current = new(); + ModInfoModel.Current ??= new(); // I18nHelper.Current = new(); ModEditWindow = new(); ModEditWindow.Show();