Improve OS::get_locale() on macOS and Windows, replace "-" with "_" and use system macros instead of bitwise AND. Add locale format info to the documentation.

(cherry picked from commit f797e1c078)
This commit is contained in:
bruvzg
2020-07-25 23:42:11 +03:00
committed by Rémi Verschelde
parent 5167a0281a
commit 131f913747
3 changed files with 11 additions and 6 deletions

View File

@ -3111,21 +3111,21 @@ String OS_Windows::get_locale() const {
LANGID langid = GetUserDefaultUILanguage();
String neutral;
int lang = langid & ((1 << 9) - 1);
int sublang = langid & ~((1 << 9) - 1);
int lang = PRIMARYLANGID(langid);
int sublang = SUBLANGID(langid);
while (wl->locale) {
if (wl->main_lang == lang && wl->sublang == SUBLANG_NEUTRAL)
neutral = wl->locale;
if (lang == wl->main_lang && sublang == wl->sublang)
return wl->locale;
return String(wl->locale).replace("-", "_");
wl++;
}
if (neutral != "")
return neutral;
return String(neutral).replace("-", "_");
return "en";
}