There is no way to get the user’s locale through Juce. Such functionality would allow one to load a correct LocalizedStrings translation file without user intervention.
The C++ standard library has a locale class. It does not give the user’s current locale properly on all platforms. The locale string given is platform dependent and on Windows it is in an undesirable form.
std::locale userLocale(""); cout << "User Locale: " << userLocale.name() << endl;
On my en-US Windows machine this returns:
Microsoft has decided to give full names rather than 2-3 letter codes.
On my en-US OS X and iOS machines this returns:
I have been unable to figure out how to access the user’s locale on OS X via std::locale.
static String LocalizedStrings::getUserLocale();
The string this function returns would be in the form of:
would be a lowercase 2 or 3 letter language code (ISO 639-1 or ISO 639-2 respectively)
would be an uppercase 2 letter country code (ISO 3166-1 alpha-2)
I will begin by implementing this in OS X, iOS. Then move on to Vista and later which uses a newer recommended API. Then move on to XP which will require using an older API.
I don’t have access to a linux or Android machine so I’m hoping someone can help out for those platforms. This should be simple enough on Android with the Locale class. Not sure about Linux.