Write locale to /etc/default/locale.

main
Teo Mrnjavac 9 years ago
parent fe9d8fadca
commit 9272d3d5b0

@ -27,7 +27,7 @@ import libcalamares
def run(): def run():
""" Create locale """ """ Create locale """
us = '#en_US' en_us_locale = '#en_US'
locale = libcalamares.globalstorage.value("lcLocale") locale = libcalamares.globalstorage.value("lcLocale")
if not locale: if not locale:
@ -50,7 +50,7 @@ def run():
# always enable en_US # always enable en_US
with open("{!s}/etc/locale.gen".format(install_path), "w") as gen: with open("{!s}/etc/locale.gen".format(install_path), "w") as gen:
for line in text: for line in text:
if us in line and line[0] == "#": if en_us_locale in line and line[0] == "#":
# uncomment line # uncomment line
line = line[1:].lstrip() line = line[1:].lstrip()
@ -63,10 +63,17 @@ def run():
libcalamares.utils.target_env_call(['locale-gen']) libcalamares.utils.target_env_call(['locale-gen'])
print('locale.gen done') print('locale.gen done')
# write /etc/locale.conf
locale_conf_path = os.path.join(install_path, "etc/locale.conf") locale_conf_path = os.path.join(install_path, "etc/locale.conf")
with open(locale_conf_path, "w") as locale_conf: with open(locale_conf_path, "w") as locale_conf:
locale_split = locale.split(' ')[0] locale_split = locale.split(' ')[0]
locale_conf.write("LANG={!s}\n".format(locale_split)) 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 return None

Loading…
Cancel
Save