开发者

Localizing for sub-cultures on WP7 not getting picked up

I am trying to localize my wp7 application and I need to have different strings for de-DE and de-AT because there are some language differences between those two cultures even though the basic settings are the same.

I did the following to achieve this:

  1. Created an AppResources.resx file for the default English text
  2. Created an AppResources.de-DE.resx file for the German text
  3. Created an AppResources.de-AT.resx file for the German text for Austrian sub culture
  4. in the Assembly Information... in the project properties I set English as my Neutral Language
  5. I closed the solution, opened up my project.csproj file and changed the <SupportedCultures/> to the following: <SupportedCultures>de-AT;de-DE</SupportedCultures>
  6. I added a new Class LocalizedStrings, 开发者_Go百科registered it in Application.Resources in App.xaml and changed the output string accordingly.

Both the Emulator as the handset are set to Austrian Locale, System.Globalization.CultureInfo.CurrentCulture.ToString(); returns de-AT, but regardless of that the texts defined in AppResources.de-DE.resx are used and not the ones defined in the file for the Austrian culture.

Any idea how I might solve this issue?


You should check the CultureInfo.CurrentUICulture, not the CurrentCulture!

That is the property that controls what resources get loaded for interface!

The value of CurrentUICulture should match the one selected in the phone/emulator Settings -> Region+Language -> Display Language.

Ideally, you can always override the system imposed CurrentUICulture by setting a different CultureInfo on Thread.CurrentUICulture.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜