Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Country and language code detecting

I need to detect user's language and country code in Qt. That codes must be matching standards at http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s04.html.

I've tried QLocale, but it returned full country and language name in countryToString and languageToString. (I need short code, like "en" instead of "English".)

One of the ways is creating map of QLocale::Language and QString. But is there any faster and simpler way?

like image 963
Ivan Akulov Avatar asked Feb 20 '23 00:02

Ivan Akulov


1 Answers

See QLocale::name()

Returns the language and country of this locale as a string of the form "language_country", where language is a lowercase, two-letter ISO 639 language code, and country is an uppercase, two- or three-letter ISO 3166 country code.

like image 86
Paul Dixon Avatar answered Mar 03 '23 13:03

Paul Dixon