From 9272d3d5b0e7dd37ef59af18a2c01e2d6630453c Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Mon, 30 May 2016 16:14:26 +0200 Subject: [PATCH] Write locale to /etc/default/locale. --- src/modules/localecfg/main.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/localecfg/main.py b/src/modules/localecfg/main.py index b1a0efc77..3a912522b 100644 --- a/src/modules/localecfg/main.py +++ b/src/modules/localecfg/main.py @@ -27,7 +27,7 @@ import libcalamares def run(): """ Create locale """ - us = '#en_US' + en_us_locale = '#en_US' locale = libcalamares.globalstorage.value("lcLocale") if not locale: @@ -50,7 +50,7 @@ def run(): # always enable en_US with open("{!s}/etc/locale.gen".format(install_path), "w") as gen: for line in text: - if us in line and line[0] == "#": + if en_us_locale in line and line[0] == "#": # uncomment line line = line[1:].lstrip() @@ -63,10 +63,17 @@ def run(): libcalamares.utils.target_env_call(['locale-gen']) print('locale.gen done') + # write /etc/locale.conf locale_conf_path = os.path.join(install_path, "etc/locale.conf") - with open(locale_conf_path, "w") as locale_conf: locale_split = locale.split(' ')[0] locale_conf.write("LANG={!s}\n".format(locale_split)) + # write /etc/default/locale if /etc/default exists and is a dir + etc_default_path = os.path.join(install_path, "etc/default") + if os.path.isdir(etc_default_path): + with open(os.path.join(etc_default_path, "locale"), "w") as etc_default_locale: + locale_split = locale.split(' ')[0] + etc_default_locale.write("{!s}\n".format(locale_split)) + return None