We moved all namespaces into a single namespace. No matter which (WinUICommunity) library you use, the namespace is always as follows
For use in the Xaml:xmlns:wuc="using:WinUICommunity"
For use in the Csharp:using WinUICommunity;
The Localizer helps you to localize your app.
- Switch languages without restarting the app
- You (users) can edit localized strings even after deployment
- You (users) can add new languages even after deployment
- Use the starndard Resources.resw
- Support Both Packaged and UnPackaged
Quick Start
Create your resources in this format:
Strings\en-US\Resources.resw
Strings\fa-IR\Resources.resw
Go to App.cs
file and Copy InitializeLocalizer
method
1 |
|
now we need to call InitializeLocalizer
in OnLaunched
method:
1 |
|
we need to copy our resources to output next to Exe
file, so copy this codes and put it in CSProj
file:
1 | <!-- Copy the String folder to output directory --> |
now in UIElement you need to set Uid
:
1 | <Page |
Get Localization in Code Behind
1 | txt.Text = Localizer.Get().GetLocalizedStrings("myButtonId").FirstOrDefault(); |
Change Language in Runtime
1 | Localizer.Get().SetLanguage("en-US"); |
Multiple Resources
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.
include /<resources-file-name>/
before the string resource identifier.
1 | <TextBlock wuc:Localizer.Uid="/Messages/ButtonFlyoutMessage" /> |
for more info please see Demo