parent
3d5c65eaea
commit
62db44c71e
@ -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]);
|
||||
}
|
||||
|
||||
@ -20,9 +20,12 @@ PyObject* glfw_get_key_name(PyObject UNUSED *self, PyObject *args);
|
||||
|
||||
#ifdef __APPLE__
|
||||
PyObject* cocoa_hide_titlebar(PyObject UNUSED *self, PyObject *window_id);
|
||||
PyObject* cocoa_get_lang(PyObject UNUSED *self);
|
||||
#define COCOA_HIDE_TITLEBAR {"cocoa_hide_titlebar", (PyCFunction)cocoa_hide_titlebar, METH_O, ""},
|
||||
#define COCOA_GET_LANG {"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
|
||||
#else
|
||||
#define COCOA_HIDE_TITLEBAR
|
||||
#define COCOA_GET_LANG
|
||||
#endif
|
||||
|
||||
#define GLFW_FUNC_WRAPPERS \
|
||||
@ -35,5 +38,6 @@ PyObject* cocoa_hide_titlebar(PyObject UNUSED *self, PyObject *window_id);
|
||||
{"glfw_post_empty_event", (PyCFunction)glfw_post_empty_event, METH_NOARGS, ""}, \
|
||||
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""}, \
|
||||
{"glfw_get_key_name", (PyCFunction)glfw_get_key_name, METH_VARARGS, ""}, \
|
||||
COCOA_HIDE_TITLEBAR
|
||||
COCOA_HIDE_TITLEBAR \
|
||||
COCOA_GET_LANG
|
||||
|
||||
|
||||
@ -228,7 +228,19 @@ def on_glfw_error(code, msg):
|
||||
safe_print('[glfw error] ', msg, file=sys.stderr)
|
||||
|
||||
|
||||
def ensure_osx_locale():
|
||||
# Ensure the LANG env var is set. See
|
||||
# https://github.com/kovidgoyal/kitty/issues/90
|
||||
from .fast_data_types import cocoa_get_lang
|
||||
if 'LANG' not in os.environ:
|
||||
lang = cocoa_get_lang()
|
||||
if lang is not None:
|
||||
os.environ['LANG'] = lang + '.UTF-8'
|
||||
|
||||
|
||||
def main():
|
||||
if isosx:
|
||||
ensure_osx_locale()
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
if os.environ.pop('KITTY_LAUNCHED_BY_LAUNCH_SERVICES',
|
||||
None) == '1' and getattr(sys, 'frozen', True):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user