From 419acbb14a422064751cbba135245d65218cd9ad Mon Sep 17 00:00:00 2001
From: Jack <3486688394@qq.com>
Date: Thu, 23 Jan 2025 22:53:43 +0800
Subject: [PATCH] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E9=A1=B9=E7=9B=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JackCraft.I18N.sln | 6 +++
JackCraft.I18N.sln.DotSettings.user | 9 +++++
Test/App.axaml | 10 +++++
Test/App.axaml.cs | 26 +++++++++++++
Test/Assets/Resources.Designer.cs | 60 +++++++++++++++++++++++++++++
Test/Assets/Resources.en-us.resx | 24 ++++++++++++
Test/Assets/Resources.resx | 33 ++++++++++++++++
Test/Assets/Resources.zh.resx | 24 ++++++++++++
Test/MainWindow.axaml | 19 +++++++++
Test/MainWindow.axaml.cs | 23 +++++++++++
Test/Program.cs | 26 +++++++++++++
Test/Test.csproj | 41 ++++++++++++++++++++
Test/app.manifest | 18 +++++++++
13 files changed, 319 insertions(+)
create mode 100644 JackCraft.I18N.sln.DotSettings.user
create mode 100644 Test/App.axaml
create mode 100644 Test/App.axaml.cs
create mode 100644 Test/Assets/Resources.Designer.cs
create mode 100644 Test/Assets/Resources.en-us.resx
create mode 100644 Test/Assets/Resources.resx
create mode 100644 Test/Assets/Resources.zh.resx
create mode 100644 Test/MainWindow.axaml
create mode 100644 Test/MainWindow.axaml.cs
create mode 100644 Test/Program.cs
create mode 100644 Test/Test.csproj
create mode 100644 Test/app.manifest
diff --git a/JackCraft.I18N.sln b/JackCraft.I18N.sln
index c19fa34..d54c1d3 100644
--- a/JackCraft.I18N.sln
+++ b/JackCraft.I18N.sln
@@ -8,6 +8,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Folder", "Solution
Readme.MD = Readme.MD
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{933A9C2F-8C23-4898-A266-780A841218DD}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +20,9 @@ Global
{C759B9D3-5362-4F9A-AE9F-FCB8B2E51B9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C759B9D3-5362-4F9A-AE9F-FCB8B2E51B9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C759B9D3-5362-4F9A-AE9F-FCB8B2E51B9A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {933A9C2F-8C23-4898-A266-780A841218DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {933A9C2F-8C23-4898-A266-780A841218DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {933A9C2F-8C23-4898-A266-780A841218DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {933A9C2F-8C23-4898-A266-780A841218DD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/JackCraft.I18N.sln.DotSettings.user b/JackCraft.I18N.sln.DotSettings.user
new file mode 100644
index 0000000..3400518
--- /dev/null
+++ b/JackCraft.I18N.sln.DotSettings.user
@@ -0,0 +1,9 @@
+
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
+ True
+ True
\ No newline at end of file
diff --git a/Test/App.axaml b/Test/App.axaml
new file mode 100644
index 0000000..e482741
--- /dev/null
+++ b/Test/App.axaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Test/App.axaml.cs b/Test/App.axaml.cs
new file mode 100644
index 0000000..0ba308e
--- /dev/null
+++ b/Test/App.axaml.cs
@@ -0,0 +1,26 @@
+using System.Globalization;
+using Avalonia;
+using Avalonia.Controls.ApplicationLifetimes;
+using Avalonia.Markup.Xaml;
+using JackCraft.I18N;
+
+namespace Test;
+
+public class App : Application
+{
+ public static I18NManager I18NManager { get; set; } = new("Test.Assets.Resources", typeof(App).Assembly);
+
+ public override void Initialize()
+ {
+ I18NManager.Culture = new CultureInfo("zh");
+ AvaloniaXamlLoader.Load(this);
+ }
+
+ public override void OnFrameworkInitializationCompleted()
+ {
+ if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
+ desktop.MainWindow = new MainWindow();
+
+ base.OnFrameworkInitializationCompleted();
+ }
+}
\ No newline at end of file
diff --git a/Test/Assets/Resources.Designer.cs b/Test/Assets/Resources.Designer.cs
new file mode 100644
index 0000000..16dbb6e
--- /dev/null
+++ b/Test/Assets/Resources.Designer.cs
@@ -0,0 +1,60 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Test.Assets {
+ using System;
+
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static System.Resources.ResourceManager resourceMan;
+
+ private static System.Globalization.CultureInfo resourceCulture;
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.Equals(null, resourceMan)) {
+ System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Test.Assets.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ internal static string Test {
+ get {
+ return ResourceManager.GetString("Test", resourceCulture);
+ }
+ }
+
+ internal static string Test1 {
+ get {
+ return ResourceManager.GetString("Test1", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/Test/Assets/Resources.en-us.resx b/Test/Assets/Resources.en-us.resx
new file mode 100644
index 0000000..2429691
--- /dev/null
+++ b/Test/Assets/Resources.en-us.resx
@@ -0,0 +1,24 @@
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ Test
+
+
+ Hello {0}
+
+
\ No newline at end of file
diff --git a/Test/Assets/Resources.resx b/Test/Assets/Resources.resx
new file mode 100644
index 0000000..4c692af
--- /dev/null
+++ b/Test/Assets/Resources.resx
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ 测试
+
+
+ 你好 {0}
+
+
\ No newline at end of file
diff --git a/Test/Assets/Resources.zh.resx b/Test/Assets/Resources.zh.resx
new file mode 100644
index 0000000..821ae2a
--- /dev/null
+++ b/Test/Assets/Resources.zh.resx
@@ -0,0 +1,24 @@
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
+ PublicKeyToken=b77a5c561934e089
+
+
+
+ 测试
+
+
+ 你好 {0}
+
+
\ No newline at end of file
diff --git a/Test/MainWindow.axaml b/Test/MainWindow.axaml
new file mode 100644
index 0000000..361f456
--- /dev/null
+++ b/Test/MainWindow.axaml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Test/MainWindow.axaml.cs b/Test/MainWindow.axaml.cs
new file mode 100644
index 0000000..f52fd12
--- /dev/null
+++ b/Test/MainWindow.axaml.cs
@@ -0,0 +1,23 @@
+using System.Globalization;
+using Avalonia.Controls;
+using Avalonia.Interactivity;
+
+namespace Test;
+
+public partial class MainWindow : Window
+{
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+
+ private void ChangeToEnglishButton_OnClick(object? sender, RoutedEventArgs e)
+ {
+ App.I18NManager.Culture = new CultureInfo("en-US");
+ }
+
+ private void ChangeToDefaultButton_OnClick(object? sender, RoutedEventArgs e)
+ {
+ App.I18NManager.Culture = CultureInfo.InvariantCulture;
+ }
+}
\ No newline at end of file
diff --git a/Test/Program.cs b/Test/Program.cs
new file mode 100644
index 0000000..4369367
--- /dev/null
+++ b/Test/Program.cs
@@ -0,0 +1,26 @@
+using System;
+using Avalonia;
+
+namespace Test;
+
+internal class Program
+{
+ // Initialization code. Don't use any Avalonia, third-party APIs or any
+ // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
+ // yet and stuff might break.
+ [STAThread]
+ public static void Main(string[] args)
+ {
+ BuildAvaloniaApp()
+ .StartWithClassicDesktopLifetime(args);
+ }
+
+ // Avalonia configuration, don't remove; also used by visual designer.
+ public static AppBuilder BuildAvaloniaApp()
+ {
+ return AppBuilder.Configure()
+ .UsePlatformDetect()
+ .WithInterFont()
+ .LogToTrace();
+ }
+}
\ No newline at end of file
diff --git a/Test/Test.csproj b/Test/Test.csproj
new file mode 100644
index 0000000..5929837
--- /dev/null
+++ b/Test/Test.csproj
@@ -0,0 +1,41 @@
+
+
+ WinExe
+ net9.0
+ enable
+ true
+ app.manifest
+ true
+
+
+
+
+
+
+
+
+
+ None
+ All
+
+
+
+
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
+
+
diff --git a/Test/app.manifest b/Test/app.manifest
new file mode 100644
index 0000000..ecfcd1d
--- /dev/null
+++ b/Test/app.manifest
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+