1
votes

Though I have changed the Display and Input languages to other languages for which I have RESX files, I always get the en-US for the below method:

 public System.Globalization.CultureInfo GetCurrentCultureInfo()
    {
        return new System.Globalization.CultureInfo(
            Windows.System.UserProfile.GlobalizationPreferences.Languages[0].ToString());
    }

Should I try something else?

1

1 Answers

4
votes

Make sure you set the new language as default:

enter image description here

Next, there is a catch - UWP apps by default use RESW files instead of RESX which is not a problem per se, because RESX is still supported, but the supported languages are analyzed based on the available RESW files included in the project.

You have two solutions:

Add custom resw files

Create a folder Strings in the UWP project and inside create folders for the languages you want to support - for example en-US, pt-BR, etc.

Next inside each folder add a Resources.resw file by right-clicking the folder, choosing Add, New Item... and selecting Resources File (.resw) in the list.

This should be enough for UWP to pick up on the declared languages and generate language-specific resources.

Modify the Package.appmanifest

This solution is a bit worse as it removes the automatic language detection and you will have to make sure to remember to modify the manifest each time a new language is supported. Right-click the Package.appmanifest file and find the Resources element:

<Resources>
  <Resource Language="x-generate"/>
</Resources>

You can replace it with a list of languages you support. The first should be your default language:

<Resources>
   <Resource Language="EN-US" />
   <Resource Language="JA-JP" />
   <Resource Language="FR-FR" />
</Resources>