Answered how to get locale setting in metro system?

  • Wednesday, August 22, 2012 1:35 PM
     
     

    Hi, I am developing metro style apps with xaml + c#. Now I hope to get locale of the metro system based on user's language settings. Such as EN-US, JA-JP.

    The method I use is CultureInfo.CurrentCulture.Name. When I set language to EN, it will return en-us. But when I set language to Japanese, it will return ja instead of JA-JP

    As I hope to generate en-us, ja-jp format string, how could I get that?

    Thanks in advance.


    dollar zhang

All Replies

  • Wednesday, August 22, 2012 1:50 PM
     
      Has Code

    You can use...

    Windows.System.UserProfile.GlobalizationPreferences.Languages.FirstOrDefault();

    This will pull the default language from their user profile.

    Or you can use...

    Windows.Globalization.Language.CurrentInputMethodLanguageTag;

    This will pull the language they currently have set.  (you can set this from the desktop app in the tasks bar if you have multiple languages defined)


    RBL3

    • Proposed As Answer by RBL_3 Wednesday, August 22, 2012 4:24 PM
    • Unproposed As Answer by Dollar Zhang Thursday, August 23, 2012 1:23 AM
    •  
  • Thursday, August 23, 2012 1:25 AM
     
      Has Code

    Hi, thanks for your reply. I tried

    Windows.System.UserProfile.GlobalizationPreferences.Languages.FirstOrDefault();

    but it will still return JA instead of JA-JP, I hope to generate JA-JP, EN-US format strings, any ideas?

    Thanks.


    dollar zhang

  • Thursday, August 23, 2012 1:48 PM
     
     Answered

    I hadn't tested it with JA.  It's odd because it returns the full format on the others...

    I did notice that when you select Japanese there is only one option instead of multiple options like the other languages.  Not sure what other languages are like that.

    Some more help might be coming from Matt if you watch this thread...

    http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/4a178a08-b664-4d46-a138-557fb5918953


    RBL3

  • Thursday, August 23, 2012 9:23 PM
     
     

    This scenario is not unique to Japanese, there are other language examples. Are there country specific variants of the Japanese language do you think?