macOS: Ensure the LANG environment variable is set

Fixes #90
This commit is contained in:
Kovid Goyal
2017-06-25 20:44:16 +05:30
parent 3d5c65eaea
commit 62db44c71e
3 changed files with 32 additions and 1 deletions

View File

@@ -25,3 +25,18 @@ cocoa_hide_titlebar(PyObject UNUSED *self, PyObject *window_id) {
}
Py_RETURN_NONE;
}
PyObject*
cocoa_get_lang(PyObject UNUSED *self) {
NSString* locale = nil;
NSString* lang_code = [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode];
NSString* country_code = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
if (lang_code && country_code) {
locale = [NSString stringWithFormat:@"%@_%@", lang_code, country_code];
} else {
locale = [[NSLocale currentLocale] localeIdentifier];
}
if (!locale) { Py_RETURN_NONE; }
return Py_BuildValue("s", [locale UTF8String]);
}