locked
Subculutures are ignored? RRS feed

  • Question

  • For multilingual apps, it seems subcultures are ignored. For example, I can specify French (Canada) as a language I want to support, but French will only ever work for French (France). I can waste all the time in the world trying to figure out what's wrong, but a device whose current culture is fr-CA will only ever pull fr-FR despite the existence of fr-CA resources.

    Are subcultures just not supported on Windows Phone 8 despite being listed as options for the manifest?

    Monday, February 10, 2014 2:00 AM

Answers

  • So someone off the forums helped me with this.

    The piece of the puzzle I was missing is that the display language for the app is set by CultureInfo.CurrentUICulture. As a n00b programmer, I was unaware this object existed and was basing everything about language off of CultureInfo.CurrentCulture.

    So, since it pulls display language from CurrentUICulture, subcultures are ignored because they are NOT display languages. English and English (United States) are display languages thus en-GB and en-US resources are no issue. French only has one option, so CurrentUICulture will always be fr-FR.

    So if I want to use other subcultures such as fr-CA or fr-CH to use that Swiss "huitante" VS "quatre-vingts" example from before, I have to manually set CurrentUICulture.

    Put this as the first lines of code in the app's constructor:

    using System.Globalization;
    using System.Threading;
    
    ...
    
    public App()
    {
         if (CultureInfo.CurrentCulture.Name == "fr-CA")
              Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
    
    ...
    
    }

    That will set the CurrentUICulture to fr-CA. Replace fr-CA with the culture code that you've declared in your app manifest and have resource files for. The list of supported display languages is here.

    Thank you for everyone that helped me!

    • Marked as answer by EntegyMVP Thursday, March 13, 2014 1:32 AM
    Thursday, March 13, 2014 1:31 AM

All replies

  • Do you have "fr" listed as a supported language in the application.  That might stop the sub-cultures from being referenced.
    Monday, February 10, 2014 7:12 AM
  • I don't actually. I'll give that a go. But shouldn't the app pull fr-CA resources if fr-CA is explicitly defined in the manifest? fr-FR is pulled.
    Monday, February 10, 2014 7:15 AM
  • I don't actually. I'll give that a go. But shouldn't the app pull fr-CA resources if fr-CA is explicitly defined in the manifest? fr-FR is pulled.

    I agree.  The subculture makes a difference in spelling and word usage.  (Example: "huitante" is used in Switzerland, but "quatre-vingts" is used in just about every other French language.")

    I have read where having the "en" as a supported language would cause problems with trying to support "en-US" and "en-GB."

    Monday, February 10, 2014 7:48 AM
  • I still can't figure this out. I've tried every combination of "en", "fr", "en-US", "en-CA", "fr-fr", and "fr-CA" I can think of in the manifest. A phone with English as a display language will only ever pull from my en-US resources and a phone with French as a display language will only ever pull from my fr-FR resources. In fact, if I remove my fr-FR resources and just leave a fr-CA resource, then the entire app just stays in the default English language!

    I'm checking System.Globalization.CultureInfo.CurrentCulture.Name and it returns either en-CA or fr-CA on my devices every time. Tried other subcultures, like en-GB. Still only ever pulled from en-US!

    Has anyone successfully used subcultures to pull resources?

    Wednesday, March 12, 2014 1:54 PM
  • I built a really basic test WP8 project to see if I could get it working - and found the exact same thing. I can't get en-CA or fr-CA to work either.  They always default to en-US or fr-FR, respectively

    I ran the test on both a Nokia Lumia 920 V 8.0.10521.155 and the 512MB emu.  In fr-CA, the title of the page should read "Essai Canadien".  In fr-FR, it should say "France essai".  English Canada should say Canada Test, etc.


    Darin R.

    Wednesday, March 12, 2014 4:45 PM
  • So someone off the forums helped me with this.

    The piece of the puzzle I was missing is that the display language for the app is set by CultureInfo.CurrentUICulture. As a n00b programmer, I was unaware this object existed and was basing everything about language off of CultureInfo.CurrentCulture.

    So, since it pulls display language from CurrentUICulture, subcultures are ignored because they are NOT display languages. English and English (United States) are display languages thus en-GB and en-US resources are no issue. French only has one option, so CurrentUICulture will always be fr-FR.

    So if I want to use other subcultures such as fr-CA or fr-CH to use that Swiss "huitante" VS "quatre-vingts" example from before, I have to manually set CurrentUICulture.

    Put this as the first lines of code in the app's constructor:

    using System.Globalization;
    using System.Threading;
    
    ...
    
    public App()
    {
         if (CultureInfo.CurrentCulture.Name == "fr-CA")
              Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
    
    ...
    
    }

    That will set the CurrentUICulture to fr-CA. Replace fr-CA with the culture code that you've declared in your app manifest and have resource files for. The list of supported display languages is here.

    Thank you for everyone that helped me!

    • Marked as answer by EntegyMVP Thursday, March 13, 2014 1:32 AM
    Thursday, March 13, 2014 1:31 AM