Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get actual language in a WinRT app?

Is it possible to get the actual language of the OS like on Windows Phone? I'm using CultureInfo.CurrentCulture.TwoLetterIsoString, but I recieve always en and not the right language, which is de in my case.

So how can I get the actual language in a WinRT app?

like image 620
Thomas Sebastian Jensen Avatar asked Oct 09 '12 12:10

Thomas Sebastian Jensen


People also ask

Is WinRT based on Win32?

WinRT represents a new application execution environment with semantics that are very different than Win32. Unlike Win32, which was designed with C in mind, the WinRT APIs are written in C++ and designed from the beginning to be object oriented.

What is a language projection?

In linguistics, the projection principle is a stipulation proposed by Noam Chomsky as part of the phrase structure component of generative-transformational grammar. The projection principle is used in the derivation of phrases under the auspices of the principles and parameters theory.

What is WinRT service?

WinRT allows developers to create safe "sandboxed" touchscreen applications available from the Microsoft Store. WinRT apps support both the x86 and ARM architectures and multiple programming languages, including C/C++, C#, Visual Basic and JavaScript. WinRT was augmented by the Universal Windows Platform (see UWP).


1 Answers

There are actually many "kind-of wrong" answers to this.

  • Windows.Globalization.Language.CurrentInputMethodLanguageTag as pointed out by Thomas will not work in all the scenarios. It only returns the language in which user's keyboard is displayed.
  • You can also use Windows.Globalization.ApplicationLanguages.Languages but it is a combination of user language preference and applications supported languages.

For most acurate user preference language, You'll need to use Windows.System.UserProfile.GlobalizationPreferences.Languages[0].

like image 142
Avi Avatar answered Nov 09 '22 23:11

Avi