diff --git a/README.md b/README.md index 622ce17..30e8e0f 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,34 @@ To just need to include `//` before the string resource ide | ---- | ----- | | ButtonFlyoutMessage.Text | ¡Esto es un mensaje increíble! | +- zh-CN: + + - Resources.resw + + | Name | Value | + | ---- | ----- | + | TestPageButton.Content | 完美! | + + - Messages.resw + + | Name | Value | + | ---- | ----- | + | ButtonFlyoutMessage.Text | 这是一条完美的消息! | + +- zh-TW: + + - Resources.resw + + | Name | Value | + | ---- | ----- | + | TestPageButton.Content | 完美! | + + - Messages.resw + + | Name | Value | + | ---- | ----- | + | ButtonFlyoutMessage.Text | 這是一條完美的消息! | + - ja: - Resources.resw @@ -221,6 +249,26 @@ In this case, we just use the `Uid` as `Name`. | Green | Verde | | Blue | Azul | +- zh-CN: + + - Resources.resw + + | Name | Value | + | ---- | ----- | + | Red | 红 | + | Green | 绿 | + | Blue | 蓝 | + +- zh-TW: + + - Resources.resw + + | Name | Value | + | ---- | ----- | + | Red | 紅 | + | Green | 緑 | + | Blue | 藍 | + - ja: - Resources.resw diff --git a/WinUI3Localizer.SampleApp/App.xaml.cs b/WinUI3Localizer.SampleApp/App.xaml.cs index 438ecd2..f14b4eb 100644 --- a/WinUI3Localizer.SampleApp/App.xaml.cs +++ b/WinUI3Localizer.SampleApp/App.xaml.cs @@ -160,6 +160,10 @@ private static async Task PrepareEnvironmentForWinUI3LocalizerOnPackagedApp() await MakeSureStringResourceFileExists(stringsFolder, "en-US", "ErrorMessages.resw"); await MakeSureStringResourceFileExists(stringsFolder, "es-ES", "Resources.resw"); await MakeSureStringResourceFileExists(stringsFolder, "es-ES", "ErrorMessages.resw"); + await MakeSureStringResourceFileExists(stringsFolder, "zh-CN", "Resources.resw"); + await MakeSureStringResourceFileExists(stringsFolder, "zh-CN", "ErrorMessages.resw"); + await MakeSureStringResourceFileExists(stringsFolder, "zh-TW", "Resources.resw"); + await MakeSureStringResourceFileExists(stringsFolder, "zh-TW", "ErrorMessages.resw"); await MakeSureStringResourceFileExists(stringsFolder, "ja", "Resources.resw"); await MakeSureStringResourceFileExists(stringsFolder, "ja", "ErrorMessages.resw"); } diff --git a/WinUI3Localizer.SampleApp/ShellPage.xaml b/WinUI3Localizer.SampleApp/ShellPage.xaml index a6306ff..642ad90 100644 --- a/WinUI3Localizer.SampleApp/ShellPage.xaml +++ b/WinUI3Localizer.SampleApp/ShellPage.xaml @@ -14,6 +14,7 @@ x.Language == Localizer.Get().GetCurrentLanguage()); this.NavigationViewControl.Loaded += NavigationViewControl_Loaded; + this.ContentFrame.Navigated += On_Navigated; LanguageDictionaryItems = Localizer .Get() @@ -42,7 +44,42 @@ private void NavigationViewControl_Loaded(object sender, RoutedEventArgs e) Uids.SetUid(settingsItem, "MainWindow_NavigationView_Settings"); } } + private void NavigationViewControl_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) + { + if (sender.IsPaneOpen && (sender.DisplayMode == NavigationViewDisplayMode.Compact || sender.DisplayMode == NavigationViewDisplayMode.Minimal)) + { + return; + } + this.ContentFrame.GoBack(); + } + private void On_Navigated(object sender, NavigationEventArgs e) + { + this.NavigationViewControl.IsBackEnabled = this.ContentFrame.CanGoBack; + if (this.ContentFrame.SourcePageType == typeof(SettingsPage)) + { + // SettingsItem is not part of NavView.MenuItems, and doesn't have a Tag. + this.NavigationViewControl.SelectedItem = (NavigationViewItem)this.NavigationViewControl.SettingsItem; + + // We don't use Control.Header sofar + // NavigationViewControl.Header = "Settings"; + } + else if (this.ContentFrame.SourcePageType != null) + { + // Select the nav view item that corresponds to the page being navigated to. + string? s = this.ContentFrame.SourcePageType.FullName; + string result = s?.Substring(s.LastIndexOf('.') + 1) ?? string.Empty; + if (result.Length > 0) + { + this.NavigationViewControl.SelectedItem = this.NavigationViewControl.MenuItems + .OfType() + .First(i => i.Tag.Equals(result)); + + // We don't use Control.Header sofar + //this.NavigationViewControl.Header = ((NavigationViewItem)this.NavigationViewControl.SelectedItem).Tag; + } + } + } private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) { if (args.IsSettingsSelected is true) diff --git a/WinUI3Localizer.SampleApp/Strings/en-US/Resources.resw b/WinUI3Localizer.SampleApp/Strings/en-US/Resources.resw index db7526e..6e6e7c5 100644 --- a/WinUI3Localizer.SampleApp/Strings/en-US/Resources.resw +++ b/WinUI3Localizer.SampleApp/Strings/en-US/Resources.resw @@ -284,4 +284,16 @@ To scope a string resource identifier reference to a particular file, you just a Top + + 中文 + + + Chinese [中文] + + + 繁體中文 + + + Chinese Traditional [繁體中文] + \ No newline at end of file diff --git a/WinUI3Localizer.SampleApp/Strings/es-ES/Resources.resw b/WinUI3Localizer.SampleApp/Strings/es-ES/Resources.resw index 8da698c..57a769d 100644 --- a/WinUI3Localizer.SampleApp/Strings/es-ES/Resources.resw +++ b/WinUI3Localizer.SampleApp/Strings/es-ES/Resources.resw @@ -284,4 +284,16 @@ Para especificar el alcance de un identificador de recurso de cadena a un archiv Arriba + + 中文 + + + Chino [中文] + + + Chino Tradicional [繁體中文] + + + 繁體中文 + \ No newline at end of file diff --git a/WinUI3Localizer.SampleApp/Strings/ja/Resources.resw b/WinUI3Localizer.SampleApp/Strings/ja/Resources.resw index 74485c2..7656081 100644 --- a/WinUI3Localizer.SampleApp/Strings/ja/Resources.resw +++ b/WinUI3Localizer.SampleApp/Strings/ja/Resources.resw @@ -284,4 +284,16 @@ + + 中文 + + + 中国語 + + + 繁体中国語 + + + 繁體中文 + \ No newline at end of file diff --git a/WinUI3Localizer.SampleApp/Strings/zh-CN/ErrorMessages.resw b/WinUI3Localizer.SampleApp/Strings/zh-CN/ErrorMessages.resw new file mode 100644 index 0000000..4b711e5 --- /dev/null +++ b/WinUI3Localizer.SampleApp/Strings/zh-CN/ErrorMessages.resw @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 错误消息示例 + + \ No newline at end of file diff --git a/WinUI3Localizer.SampleApp/Strings/zh-CN/Resources.resw b/WinUI3Localizer.SampleApp/Strings/zh-CN/Resources.resw new file mode 100644 index 0000000..4a77358 --- /dev/null +++ b/WinUI3Localizer.SampleApp/Strings/zh-CN/Resources.resw @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 点击 + + + 激活 + + + 选项 A + + + 选项 B + + + 选项 C + + + 选项 + + + 选项 A + + + 选项 B + + + 选项 C + + + 选项 + + + 选项 A + + + 选项 B + + + 选项 C + + + 等级 + + + 这是一个 RichTextBlock 译文。 + + + 滑块 + + + 这是一个 TextBlock 译文。 + + + 密码 + + + 已停用 + + + 已激活 + + + 将鼠标指针放置此处 + + + 底部 + + + 这是翻译工具提示。 + + + English + + + Español + + + + + + ID + + + + + + 日本語 + + + 某些 依赖项(例如“Run”、“Bold”或“Hyperlink”)无法使用依赖项属性进行本地化。WinUI3Localizer 提供了“LocazationActions”来翻译这些类型的 依赖项。 + + + 这是一个译文的超链接。 + + + 点击 + + + 主要的 + + + WinUI3多语言演示程序😎 + + + 英语 [English] + + + 西班牙语 [Español] + + + 日语 [日本語] + + + 搜索... + + + 控制 + + + 项目模板 + + + 汉化行动 + + + 主要的 + + + 多种资源 + + + 设置 + + + 样式 + + + 您可以将所有字符串保存在一个资源文件 (resw) 中,也可以将它们分解到多个资源文件中。例如,您可能希望将错误消息保存在一个资源文件中,将应用包清单字符串保存在另一个资源文件中,将 UI 字符串保存在第三个资源文件中。 + +要将字符串资源标识符引用范围限定到特定文件,只需在 Uid 前添加 /<resources-file-name>/。以下示例假设 ErrorMessages.resw 包含一个名为“ErrorMessageExample.Text”的资源,其值描述错误。 + + + 设置 + + + 在“字符串”文件夹中找到的语言 + + + 字典 + + + 字符串资源文件夹 + + + 切换语言 + + + + + + + + + + + + + + + 中文 + + + 中文 + + + 繁体中文 + + + 繁體中文 + + \ No newline at end of file diff --git a/WinUI3Localizer.SampleApp/Strings/zh-TW/ErrorMessages.resw b/WinUI3Localizer.SampleApp/Strings/zh-TW/ErrorMessages.resw new file mode 100644 index 0000000..4b711e5 --- /dev/null +++ b/WinUI3Localizer.SampleApp/Strings/zh-TW/ErrorMessages.resw @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 错误消息示例 + + \ No newline at end of file diff --git a/WinUI3Localizer.SampleApp/Strings/zh-TW/Resources.resw b/WinUI3Localizer.SampleApp/Strings/zh-TW/Resources.resw new file mode 100644 index 0000000..8a81b36 --- /dev/null +++ b/WinUI3Localizer.SampleApp/Strings/zh-TW/Resources.resw @@ -0,0 +1,298 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 選項 A + + + 選項 B + + + 選項 C + + + 選項 + + + 選項 A + + + 選項 B + + + 選項 C + + + 選項 + + + 選項 A + + + 選項 B + + + 選項 C + + + 等級 + + + 這是一個 RichTextBlock 譯文。 + + + 滑块 + + + 這是一個 TextBlock 譯文。 + + + 密碼 + + + 已停用 + + + 已激活 + + + 将鼠标指针放置此处 + + + 底部 + + + 这是翻译工具提示。 + + + English + + + Español + + + + + + ID + + + + + + 日本語 + + + 某些 依賴項(例如“Run”、“Bold”或“Hyperlink”)無法使用依賴項屬性進行本地化。WinUI3Localizer 提供了“LocazationActions”來翻譯這些類型的 依賴項。 + + + 這是一個譯文的超鏈接。 + + + 点击 + + + 主要的 + + + WinUI3多语言演示程序😎 + + + 英语 [English] + + + 西班牙语 [Español] + + + 日语 [日本語] + + + 搜索... + + + 控制 + + + 项目模板 + + + 漢化行动 + + + 主要的 + + + 多種資源 + + + 設置 + + + 樣式 + + + 您可以將所有字符串保存在一個資源文件 (resw) 中,也可以將它們分解到多個資源文件中。例如,您可能希望將錯誤消息保存在一個資源文件中,將應用包清單字符串保存在另一個資源文件中,將 UI 字符串保存在第三個資源文件中。 +要將字符串資源標識符引用範圍限定到特定文件,只需在 Uid 前添加 /<resources-file-name>/。以下示例假設 ErrorMessages.resw 包含一個名爲“ErrorMessageExample.Text”的資源,其值描述錯誤。 + + + 设置 + + + 在“字符串”文件夹中找到的语言 + + + 字典 + + + 字符串資源文件夾 + + + 切換語言 + + + + + + 中文 + + + 中文 + + + 繁体中文 + + + 繁體中文 + + + + + + + + + + + + 點擊 + + + 激活 + + \ No newline at end of file diff --git a/WinUI3Localizer.SampleApp/WinUI3Localizer.SampleApp.csproj b/WinUI3Localizer.SampleApp/WinUI3Localizer.SampleApp.csproj index 928b849..8946a7d 100644 --- a/WinUI3Localizer.SampleApp/WinUI3Localizer.SampleApp.csproj +++ b/WinUI3Localizer.SampleApp/WinUI3Localizer.SampleApp.csproj @@ -1,7 +1,7 @@ WinExe - net8.0-windows10.0.19041.0 + net8.0-windows10.0.22000.0 10.0.17763.0 WinUI3Localizer.SampleApp app.manifest diff --git a/WinUI3Localizer.Tests/WinUI3Localizer.Tests.csproj b/WinUI3Localizer.Tests/WinUI3Localizer.Tests.csproj index f81b1e0..d0c79ae 100644 --- a/WinUI3Localizer.Tests/WinUI3Localizer.Tests.csproj +++ b/WinUI3Localizer.Tests/WinUI3Localizer.Tests.csproj @@ -1,14 +1,12 @@ - - net6.0-windows10.0.19041.0 + net8.0-windows10.0.22000.0 enable enable false x86;x64;arm64 - win10-x86;win10-x64;win10-arm64 + win-x86;win-x64;win-arm64 - @@ -24,19 +22,15 @@ all - - - PreserveNewest - - + \ No newline at end of file diff --git a/WinUI3Localizer/WinUI3Localizer.csproj b/WinUI3Localizer/WinUI3Localizer.csproj index 9f79113..26f401f 100644 --- a/WinUI3Localizer/WinUI3Localizer.csproj +++ b/WinUI3Localizer/WinUI3Localizer.csproj @@ -1,13 +1,12 @@ - net6.0-windows10.0.19041.0;net7.0-windows10.0.19041.0 + net8.0-windows10.0.22000.0 10.0.17763.0 WinUI3Localizer - win10-x86;win10-x64;win10-arm64 + win-x86;win-x64;win-arm64 true enable - WinUI3Localizer @@ -32,20 +31,16 @@ README.md winui.png - - + - - - - + \ No newline at end of file