String resources and localization
Tip
Relevant tutorials on this topic:
Localization is done through the resw
files in the current project. Normally, you would put these files in the strings/[lang]
folder in the [AppName]
project. Resources are then referenced using x:Uid
.
See the UWP documentation on localizing strings in your UI.
Resources may be placed in the default scope file Resources.resw
, or in a custom-named file. Custom-named file content
can be used with the x:Uid="/myResources/MyResource"
format, see how to factor strings into multiple resource files.
Note that the default language can be defined using the DefaultLanguage
MSBuild property, using an IETF Language Tag (e.g. en
or fr-FR
).
By default, the app will use the operating system's language first, falling back to the DefaultLanguage
second. If you would like to change localization at the app level, you can use the ApplicationLanguages.PrimaryLanguageOverride
property:
ApplicationLanguages.PrimaryLanguageOverride = "fr-CA"; // or, any IETF language tag
Note that changing the PrimaryLanguageOverride
will not retroactively update any loaded pages. You will need to reload the page or navigate to a new one.