From 7c8846474357c38e5557a9835ad9ad7fa9662f73 Mon Sep 17 00:00:00 2001 From: wolf109909 <84360921+wolf109909@users.noreply.github.com> Date: Mon, 28 Feb 2022 20:26:47 +0800 Subject: [PATCH 1/7] Added localization framework +zh_hans tranlation --- .../LocalizationAttachedPropertyHolder.cs | 57 ++++ .../Localizations/AppResources.Designer.cs | 261 ++++++++++++++++++ NSModCreator/Localizations/AppResources.resx | 186 +++++++++++++ .../AppResources.zh-Hans.Designer.cs | 261 ++++++++++++++++++ .../Localizations/AppResources.zh-Hans.resx | 186 +++++++++++++ NSModCreator/MainWindow.axaml | 59 ++-- NSModCreator/NSModCreator.csproj | 22 ++ 7 files changed, 1003 insertions(+), 29 deletions(-) create mode 100644 NSModCreator/LocalizationAttachedPropertyHolder.cs create mode 100644 NSModCreator/Localizations/AppResources.Designer.cs create mode 100644 NSModCreator/Localizations/AppResources.resx create mode 100644 NSModCreator/Localizations/AppResources.zh-Hans.Designer.cs create mode 100644 NSModCreator/Localizations/AppResources.zh-Hans.resx diff --git a/NSModCreator/LocalizationAttachedPropertyHolder.cs b/NSModCreator/LocalizationAttachedPropertyHolder.cs new file mode 100644 index 0000000..4a4866c --- /dev/null +++ b/NSModCreator/LocalizationAttachedPropertyHolder.cs @@ -0,0 +1,57 @@ +using Avalonia; +using Avalonia.Controls; +using NSModCreator.Localizations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NSModCreator.Localizations +{ + public class LocalizationAttachedPropertyHolder + { + public static AvaloniaProperty UidProperty = + AvaloniaProperty.RegisterAttached("Uid"); + + static LocalizationAttachedPropertyHolder() + { + TextBlock.TextProperty.Changed.Subscribe(next => + { + var uid = GetUid((AvaloniaObject)next.Sender); + if (uid != null) + { + next.Sender.SetValue(TextBlock.TextProperty, AppResources.ResourceManager.GetString(uid.ToString())); + } + }); + + ContentControl.ContentProperty.Changed.Subscribe(next => + { + var uid = GetUid((AvaloniaObject)next.Sender); + if (uid != null) + { + next.Sender.SetValue(ContentControl.ContentProperty, AppResources.ResourceManager.GetString(uid.ToString())); + } + }); + + TextBox.WatermarkProperty.Changed.Subscribe(next => + { + var uid = GetUid((AvaloniaObject)next.Sender); + if (uid != null) + { + next.Sender.SetValue(TextBox.WatermarkProperty, AppResources.ResourceManager.GetString(uid.ToString())); + } + }); + } + + public static void SetUid(AvaloniaObject target, string value) + { + target.SetValue(UidProperty, value); + } + + public static string GetUid(AvaloniaObject target) + { + return (string)target.GetValue(UidProperty); + } + } +} diff --git a/NSModCreator/Localizations/AppResources.Designer.cs b/NSModCreator/Localizations/AppResources.Designer.cs new file mode 100644 index 0000000..009e35a --- /dev/null +++ b/NSModCreator/Localizations/AppResources.Designer.cs @@ -0,0 +1,261 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace NSModCreator.Localizations { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class AppResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal AppResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NSModCreator.Localizations.AppResources", typeof(AppResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Takyon's Mod Creator. + /// + internal static string AppName { + get { + return ResourceManager.GetString("AppName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Browse. + /// + internal static string BrowseButton { + get { + return ResourceManager.GetString("BrowseButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear. + /// + internal static string ClearButton { + get { + return ResourceManager.GetString("ClearButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create. + /// + internal static string CreateButton { + get { + return ResourceManager.GetString("CreateButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create. + /// + internal static string CreateTab { + get { + return ResourceManager.GetString("CreateTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to For help hover over the labels. + /// + internal static string HelpText { + get { + return ResourceManager.GetString("HelpText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Icon Path. + /// + internal static string IconPath { + get { + return ResourceManager.GetString("IconPath", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Install Folder. + /// + internal static string InstallFolder { + get { + return ResourceManager.GetString("InstallFolder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Load Priority. + /// + internal static string LoadPriority { + get { + return ResourceManager.GetString("LoadPriority", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Dependencies. + /// + internal static string ModDependencies { + get { + return ResourceManager.GetString("ModDependencies", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Description. + /// + internal static string ModDescriptionLabel { + get { + return ResourceManager.GetString("ModDescriptionLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This is a very cool mod that only does cool stuff. + /// + internal static string ModDescWatermark { + get { + return ResourceManager.GetString("ModDescWatermark", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mod Folder. + /// + internal static string ModFolder { + get { + return ResourceManager.GetString("ModFolder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mod Name. + /// + internal static string ModName { + get { + return ResourceManager.GetString("ModName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to YourName.ModName. + /// + internal static string ModNameWatermark { + get { + return ResourceManager.GetString("ModNameWatermark", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Doesn't matter for most projects and can be left default. May be the reason for mods conflicting however. + /// + internal static string ModPrioTip { + get { + return ResourceManager.GetString("ModPrioTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Output Folder. + /// + internal static string OutputFolder { + get { + return ResourceManager.GetString("OutputFolder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Publish. + /// + internal static string PublishTab { + get { + return ResourceManager.GetString("PublishTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to RequiredOnClient. + /// + internal static string RequiredOnClient { + get { + return ResourceManager.GetString("RequiredOnClient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Run on. + /// + internal static string RunOn { + get { + return ResourceManager.GetString("RunOn", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Version. + /// + internal static string Version { + get { + return ResourceManager.GetString("Version", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Website. + /// + internal static string Website { + get { + return ResourceManager.GetString("Website", resourceCulture); + } + } + } +} diff --git a/NSModCreator/Localizations/AppResources.resx b/NSModCreator/Localizations/AppResources.resx new file mode 100644 index 0000000..7643e5a --- /dev/null +++ b/NSModCreator/Localizations/AppResources.resx @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Takyon's Mod Creator + + + Browse + + + Clear + + + Create + + + Create + + + For help hover over the labels + + + Icon Path + + + Install Folder + + + Load Priority + + + Dependencies + + + Description + + + This is a very cool mod that only does cool stuff + + + Mod Folder + + + Mod Name + + + YourName.ModName + + + Doesn't matter for most projects and can be left default. May be the reason for mods conflicting however + + + Output Folder + + + Publish + + + RequiredOnClient + + + Run on + + + Version + + + Website + + \ No newline at end of file diff --git a/NSModCreator/Localizations/AppResources.zh-Hans.Designer.cs b/NSModCreator/Localizations/AppResources.zh-Hans.Designer.cs new file mode 100644 index 0000000..e3fb067 --- /dev/null +++ b/NSModCreator/Localizations/AppResources.zh-Hans.Designer.cs @@ -0,0 +1,261 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace NSModCreator.Localizations { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class AppResources___Copy { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal AppResources___Copy() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NSModCreator.Localizations.AppResources - Copy", typeof(AppResources___Copy).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Takyon's Mod Creator. + /// + internal static string AppName { + get { + return ResourceManager.GetString("AppName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Browse. + /// + internal static string BrowseButton { + get { + return ResourceManager.GetString("BrowseButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Clear. + /// + internal static string ClearButton { + get { + return ResourceManager.GetString("ClearButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create. + /// + internal static string CreateButton { + get { + return ResourceManager.GetString("CreateButton", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create. + /// + internal static string CreateTab { + get { + return ResourceManager.GetString("CreateTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to For help hover over the labels. + /// + internal static string HelpText { + get { + return ResourceManager.GetString("HelpText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Icon Path. + /// + internal static string IconPath { + get { + return ResourceManager.GetString("IconPath", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Install Folder. + /// + internal static string InstallFolder { + get { + return ResourceManager.GetString("InstallFolder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Load Priority. + /// + internal static string LoadPriority { + get { + return ResourceManager.GetString("LoadPriority", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Dependencies. + /// + internal static string ModDependencies { + get { + return ResourceManager.GetString("ModDependencies", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Description. + /// + internal static string ModDescriptionLabel { + get { + return ResourceManager.GetString("ModDescriptionLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to This is a very cool mod that only does cool stuff. + /// + internal static string ModDescWatermark { + get { + return ResourceManager.GetString("ModDescWatermark", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mod Folder. + /// + internal static string ModFolder { + get { + return ResourceManager.GetString("ModFolder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Mod Name. + /// + internal static string ModName { + get { + return ResourceManager.GetString("ModName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to YourName.ModName. + /// + internal static string ModNameWatermark { + get { + return ResourceManager.GetString("ModNameWatermark", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Doesn't matter for most projects and can be left default. May be the reason for mods conflicting however. + /// + internal static string ModPrioTip { + get { + return ResourceManager.GetString("ModPrioTip", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Output Folder. + /// + internal static string OutputFolder { + get { + return ResourceManager.GetString("OutputFolder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Publish. + /// + internal static string PublishTab { + get { + return ResourceManager.GetString("PublishTab", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to RequiredOnClient. + /// + internal static string RequiredOnClient { + get { + return ResourceManager.GetString("RequiredOnClient", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Run on. + /// + internal static string RunOn { + get { + return ResourceManager.GetString("RunOn", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Version. + /// + internal static string Version { + get { + return ResourceManager.GetString("Version", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Website. + /// + internal static string Website { + get { + return ResourceManager.GetString("Website", resourceCulture); + } + } + } +} diff --git a/NSModCreator/Localizations/AppResources.zh-Hans.resx b/NSModCreator/Localizations/AppResources.zh-Hans.resx new file mode 100644 index 0000000..c2ea1d1 --- /dev/null +++ b/NSModCreator/Localizations/AppResources.zh-Hans.resx @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Takyon的模组生成器 + + + 浏览... + + + 清空 + + + 生成 + + + 创建 + + + 悬浮光标在文字上可以查看帮助信息 + + + 图标路径 + + + 安装路径 + + + 读取优先级 + + + 前置模组 + + + 模组介绍 + + + 这是一个很酷炫的Mod... + + + 模组文件夹 + + + 模组名称 + + + 你的名称.模组的名称 + + + Doesn't matter for most projects and can be left default. May be the reason for mods conflicting however + + + 输出文件夹 + + + 发布 + + + 需要客户端安装 + + + 执行于 + + + 版本 + + + 网站 + + \ No newline at end of file diff --git a/NSModCreator/MainWindow.axaml b/NSModCreator/MainWindow.axaml index 445b575..1969dd3 100644 --- a/NSModCreator/MainWindow.axaml +++ b/NSModCreator/MainWindow.axaml @@ -1,4 +1,5 @@ - + - Takyon's Mod Creator - For help hover over the labels + Text="Takyon's Mod Creator" + For help hover over the labels - + - + - +