In order to present the proper menu text and some other aspects of the UI I am trying to get the current user's country and keyboard language.
I know the locale (via the env. variable) but I can't find a way to get these two pieces of info.
The code is in C for Mac OS X. I can use Cocoa API to get them but they need to be called from C. Any ideas?
Thank you!
Switch between keyboard layouts or input methods On a hardware keyboard, press and hold the Windows logo key , and then press the Spacebar to cycle through your input methods.
Remove extra language packs or keyboard languagesSelect Start > Settings > Time & language > Language & region. Under Preferred languages, select the language you want to remove, and then select Remove.
Use CFLocaleCopyCurrent
, CFLocaleGetValue
and CFLocaleCopyPreferredLanguages
(note that the preferred language may not match the locale's language). See the documentation.
Edit: ok, here's some sample code.
#include <CoreFoundation/CoreFoundation.h>
#include <stdio.h>
int main (int argc, char **argv)
{
CFLocaleRef loc = CFLocaleCopyCurrent();
CFStringRef countryCode = CFLocaleGetValue (loc, kCFLocaleCountryCode);
CFStringRef countryName = CFLocaleCopyDisplayNameForPropertyValue (loc, kCFLocaleCountryCode, countryCode);
CFShow(countryCode);
CFShow(countryName);
CFArrayRef langs = CFLocaleCopyPreferredLanguages();
CFStringRef langCode = CFArrayGetValueAtIndex (langs, 0);
CFStringRef langName = CFLocaleCopyDisplayNameForPropertyValue (loc, kCFLocaleLanguageCode, langCode);
CFShow(langCode);
CFShow(langName);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With