diff --git a/WinUI3Localizer.SampleApp/MainWindow.xaml b/WinUI3Localizer.SampleApp/MainWindow.xaml
index f921fb2..b550b09 100644
--- a/WinUI3Localizer.SampleApp/MainWindow.xaml
+++ b/WinUI3Localizer.SampleApp/MainWindow.xaml
@@ -25,9 +25,8 @@
Grid.Column="1"
Margin="8,0,0,0"
VerticalAlignment="Center"
- l:Uids.Uid="MainWindow_AppTitleBar"
+ l:Uids.Uid="MainWindow_AppTitleBar.Text"
FontSize="12"
- Text="WinUI 3 Localizer"
TextWrapping="NoWrap" />
diff --git a/WinUI3Localizer.SampleApp/Strings/en-US/Resources.resw b/WinUI3Localizer.SampleApp/Strings/en-US/Resources.resw
index db7526e..fc08318 100644
--- a/WinUI3Localizer.SampleApp/Strings/en-US/Resources.resw
+++ b/WinUI3Localizer.SampleApp/Strings/en-US/Resources.resw
@@ -216,7 +216,7 @@
Main
-
+
WinUI3Localizer Sample App😎
diff --git a/WinUI3Localizer.SampleApp/Strings/es-ES/Resources.resw b/WinUI3Localizer.SampleApp/Strings/es-ES/Resources.resw
index 8da698c..49a8169 100644
--- a/WinUI3Localizer.SampleApp/Strings/es-ES/Resources.resw
+++ b/WinUI3Localizer.SampleApp/Strings/es-ES/Resources.resw
@@ -216,7 +216,7 @@
Principal
-
+
WinUI3Localizer App de Muestra😎
diff --git a/WinUI3Localizer.SampleApp/Strings/ja/Resources.resw b/WinUI3Localizer.SampleApp/Strings/ja/Resources.resw
index 74485c2..2b4bdea 100644
--- a/WinUI3Localizer.SampleApp/Strings/ja/Resources.resw
+++ b/WinUI3Localizer.SampleApp/Strings/ja/Resources.resw
@@ -216,7 +216,7 @@
メイン
-
+
WinUI3Localizer サンプルアプリ 😎
diff --git a/WinUI3Localizer.SampleApp/WinUI3Localizer.SampleApp.csproj b/WinUI3Localizer.SampleApp/WinUI3Localizer.SampleApp.csproj
index 928b849..bebf534 100644
--- a/WinUI3Localizer.SampleApp/WinUI3Localizer.SampleApp.csproj
+++ b/WinUI3Localizer.SampleApp/WinUI3Localizer.SampleApp.csproj
@@ -1,4 +1,4 @@
-
+
WinExe
net8.0-windows10.0.19041.0
@@ -17,6 +17,7 @@
None
true
-->
+ 10.0.19041.38
@@ -43,26 +44,23 @@
-
+
-
-
-
+
+
+
-
-
+
+
+
-
-
-
-
diff --git a/WinUI3Localizer/Localizer.cs b/WinUI3Localizer/Localizer.cs
index 44e3d8e..b8422eb 100644
--- a/WinUI3Localizer/Localizer.cs
+++ b/WinUI3Localizer/Localizer.cs
@@ -294,27 +294,45 @@ private async Task LocalizeDependencyObjects()
private void LocalizeDependencyObject(DependencyObject dependencyObject)
{
- if (Uids.GetUid(dependencyObject) is string uid &&
- CurrentDictionary.TryGetItems(uid, out LanguageDictionary.Items? items) is true)
+ if (Uids.GetUid(dependencyObject) is not string uidSource ||
+ string.IsNullOrEmpty(uidSource) is true)
{
- foreach (LanguageDictionary.Item item in items)
- {
- LocalizeDependencyObject(dependencyObject, item);
- }
+ Logger.LogWarning("DependencyObject does not have Uid. [Type: {Type}]", dependencyObject.GetType());
+ return;
+ }
+
+ string uid = uidSource;
+ string? uidDependencyPropertyName = null;
+
+ if (uidSource.Split('.') is { Length: 2 } splitResult)
+ {
+ uid = splitResult[0];
+ uidDependencyPropertyName = splitResult[1] + "Property";
+ }
+
+ if (CurrentDictionary.TryGetItems(uid, out LanguageDictionary.Items? items) is false)
+ {
+ Logger.LogWarning("DependencyObject does not have Uid in the dictionary. [Type: {Type} Uid: {Uid}]", dependencyObject.GetType(), uid);
+ return;
+ }
+
+ foreach (LanguageDictionary.Item item in items)
+ {
+ LocalizeDependencyObject(dependencyObject, uidDependencyPropertyName ?? item.DependencyPropertyName, item.Value);
}
}
- private void LocalizeDependencyObject(DependencyObject dependencyObject, LanguageDictionary.Item item)
+ private void LocalizeDependencyObject(DependencyObject dependencyObject, string dependencyPropertyName, string value)
{
if (GetDependencyProperty(
dependencyObject,
- item.DependencyPropertyName) is DependencyProperty dependencyProperty)
+ dependencyPropertyName) is DependencyProperty dependencyProperty)
{
- LocalizeDependencyObjectsWithDependencyProperty(dependencyObject, dependencyProperty, item.Value);
+ LocalizeDependencyObjectsWithDependencyProperty(dependencyObject, dependencyProperty, value);
return;
}
- LocalizeDependencyObjectsWithoutDependencyProperty(dependencyObject, item.Value);
+ LocalizeDependencyObjectsWithoutDependencyProperty(dependencyObject, value);
}
private void LocalizeDependencyObjectsWithDependencyProperty(DependencyObject dependencyObject, DependencyProperty dependencyProperty, string value)
diff --git a/WinUI3Localizer/WinUI3Localizer.csproj b/WinUI3Localizer/WinUI3Localizer.csproj
index 9f79113..6197063 100644
--- a/WinUI3Localizer/WinUI3Localizer.csproj
+++ b/WinUI3Localizer/WinUI3Localizer.csproj
@@ -17,7 +17,7 @@
- You/users can add new languages even after deployment
- Use standard Resources.resw
- 2.2.0
+ 2.3.0-alpha
winui3;winappsdk;localization;localize;language;multilanguage
https://github.com/AndrewKeepCoding/WinUI3Localizer
https://github.com/AndrewKeepCoding/WinUI3Localizer