Skip to content

Commit 52f19dc

Browse files
Merge pull request #26 from AndrewKeepCoding/23-add-support-for-factoring-strings-into-multiple-resources-files
Update README
2 parents 712b3dd + 754cd9d commit 52f19dc

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,28 @@ Add this ItemGroup in the project file (\*.csproj) of your app.
119119

120120
This is an example of how to localize the `Content` of a `Button`.
121121

122-
First, we need to asign an `Uid` to the `Button`.
122+
First asign an `Uid` to the `Button`, then in each language resources file, add an item that corresponds to the `Uid`.
123+
124+
You can also have multiple string resources files. For example, besides the default **Resources.resw** file, you can have a **Messages.resw** for your messages file.
125+
To just need to include `/<resources-file-name>/` before the string resource identifier.
123126

124127
```xml
125128
<Page
126129
x:Class="WinUI3Localizer.SampleApp.TestPage"
127130
...
128131
xmlns:l="using:WinUI3Localizer">
129132
<StackPanel>
130-
<Button l:Uids.Uid="TestPage_Button" />
133+
<Button l:Uids.Uid="TestPage_Button">
134+
<Button.Flyout>
135+
<Flyout>
136+
<TextBlock l:Uids.Uid="/Messages/ButtonFlyoutMessage" />
137+
</Flyout>
138+
</Button.Flyout>
139+
</Button>
131140
</StackPanel>
132141
</Page>
133142
```
134143

135-
Then in each language resources file, we need to add an item that corresponds to the `Uid`.
136-
137144
- en-US
138145

139146
- Resources.resw
@@ -142,6 +149,12 @@ Then in each language resources file, we need to add an item that corresponds to
142149
| ---- | ----- |
143150
| TestPageButton.Content | Awesome! |
144151

152+
- Messages.resw
153+
154+
| Name | Value |
155+
| ---- | ----- |
156+
| ButtonFlyoutMessage.Text | This is an awesome message! |
157+
145158
- es-ES:
146159

147160
- Resources.resw
@@ -150,6 +163,12 @@ Then in each language resources file, we need to add an item that corresponds to
150163
| ---- | ----- |
151164
| TestPageButton.Content | ¡Increíble! |
152165

166+
- Messages.resw
167+
168+
| Name | Value |
169+
| ---- | ----- |
170+
| ButtonFlyoutMessage.Text | ¡Esto es un mensaje increíble! |
171+
153172
- ja:
154173

155174
- Resources.resw
@@ -158,6 +177,12 @@ Then in each language resources file, we need to add an item that corresponds to
158177
| ---- | ----- |
159178
| TestPageButton.Content | 素晴らしい! |
160179

180+
- Messages.resw
181+
182+
| Name | Value |
183+
| ---- | ----- |
184+
| ButtonFlyoutMessage.Text | これは素晴らしいメッセージです! |
185+
161186
### **Getting localized strings**
162187

163188
If we need to localize strings in code-behind or in ViewModels, we can use the `GetLocalizedString()` method.

0 commit comments

Comments
 (0)