diff --git a/kallithea/bin/kallithea_cli_config.py b/kallithea/bin/kallithea_cli_config.py --- a/kallithea/bin/kallithea_cli_config.py +++ b/kallithea/bin/kallithea_cli_config.py @@ -22,6 +22,7 @@ from collections import defaultdict import mako.exceptions +import kallithea.lib.locale from kallithea.lib import inifile def show_defaults(ctx, param, value): @@ -64,6 +65,7 @@ def config_create(config_file, key_value 'git_hook_interpreter': sys.executable, 'user_home_path': os.path.expanduser('~'), 'kallithea_cli_path': cli_base.kallithea_cli_path, + 'ssh_locale': kallithea.lib.locale.get_current_locale(), } ini_settings = defaultdict(dict) diff --git a/kallithea/lib/locale.py b/kallithea/lib/locale.py --- a/kallithea/lib/locale.py +++ b/kallithea/lib/locale.py @@ -35,3 +35,14 @@ def current_locale_is_valid(): log.error("Note: No locale setting found in environment variables - perhaps set LC_CTYPE to some value from 'locale -a', like 'C.UTF-8' or 'en_US.UTF-8'") return False return True + +def get_current_locale(): + """Return the current locale based on environment variables. + There does not seem to be a good (and functional) way to get it via Python. + """ + for var in ['LC_ALL', 'LC_CTYPE', 'LANG']: + val = os.environ.get(var) + if val: + log.debug('Determined current locale via environment variable %s (%s)', var, val) + return val + return None diff --git a/kallithea/lib/paster_commands/template.ini.mako b/kallithea/lib/paster_commands/template.ini.mako --- a/kallithea/lib/paster_commands/template.ini.mako +++ b/kallithea/lib/paster_commands/template.ini.mako @@ -346,6 +346,9 @@ kallithea_cli_path = ${kallithea_cli_pat <%text>## settings, which may not be available on the server. <%text>## See `locale -a` for valid values on this system. #ssh_locale = C.UTF-8 +%if ssh_locale: +ssh_locale = ${ssh_locale} +%endif <%text>#################################### <%text>### CELERY CONFIG ####