I18N Internationalization
Required Configuration
The following configuration is needed to enable:
<AutoGenerateI18N>set totruein Tools.Config.props file- Create
Stringsfolder in project file with language files:The- 📁Strings - 📁zh-cn - 🗒️Resources.resw - 📁en-us - 🗒️Resources.reswResources.reswfile usage is consistent withWinUI3projects.
Generation
After the required configuration, build the project once.
The following classes will be automatically generated:
{Project Namespace}.I18nResourcesHelperHelper class for reading localized stringsI18NHelper class that directly returns localized stringsResourceKeyKeys automatically generated fromreswfilesLocaleExtensionLocalization helper class forxaml
ResourcesHelper
Example usage:
csharp
// Use the Download value from resw
string downloadStr = ResourcesHelper.GetString(ResourceKey.Download);I18N
Example usage:
csharp
// Use the Download value from resw
string downloadStr = I18N.Download;Note
I18N.Download is equivalent to ResourcesHelper.GetString(ResourceKey.Download)
LocaleExtension
Example usage:
Reference namespace at the top of xaml file:
xmlns:ex="using:ShadowViewer.I18n"xml
<TextBlock Text="{ex:Locale Key=Download}" />