Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion winui/Common/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,26 @@ The application language can be changed by setting the desired language to the `
{
public MainWindow()
{
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "de";
Microsoft.Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "de"; // Works for the both and unpack deployments.
this.InitializeComponent();
}
}

{% endhighlight %}

{% endtabs %}

You can use the below code for packaged deployments. But in unpackaged deployments, it may cause the app to crash.

{% tabs %}

{% highlight c# %}

public sealed partial class MainWindow : Window
{
public MainWindow()
{
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "de"; // This code works for packaged deployments, but in unpackaged deployments, it may cause the app to crash.
this.InitializeComponent();
}
}
Expand All @@ -33,6 +52,8 @@ The application language can be changed by setting the desired language to the `

{% endtabs %}

N> We recommend setting the above code before the `InitializeComponent` method if you have added a .resw file to your project. Otherwise, it may cause the project to crash.

The following screenshot illustrates how the localization is applied to the datagrid based on the defined language to the `ApplicationLanguages.PrimaryLanguageOverride` property.

<img src="Localization-images/winui-datagrid-localization.png" alt="WinUI DataGrid Localization" width="100%" Height="Auto"/>
Expand Down