summaryrefslogtreecommitdiffstats
path: root/pyanaconda/localization.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyanaconda/localization.py')
-rw-r--r--pyanaconda/localization.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/pyanaconda/localization.py b/pyanaconda/localization.py
index ff02d8a77..d3dda8a6e 100644
--- a/pyanaconda/localization.py
+++ b/pyanaconda/localization.py
@@ -30,6 +30,13 @@ import babel
LOCALE_PREFERENCES = {}
+SYSCONF_I18N_FILE_PATH = "/etc/sysconfig/i18n"
+LOCALE_CONF_FILE_PATH = "/etc/locale.conf"
+
+class LocalizationConfigError(Exception):
+ """Exception class for localization configuration related problems"""
+
+ pass
class LocaleInfo(object):
@@ -168,6 +175,34 @@ def expand_langs(astring):
return langs
+def write_language_configuration(lang, root):
+ """
+ Write language configuration to the $root/etc/sysconfig/i18n and the
+ $root/etc/locale.conf files.
+
+ @param lang: ksdata.lang object
+ @param root: path to the root of the installed system
+
+ """
+
+ try:
+ fpath = os.path.normpath(root + SYSCONF_I18N_FILE_PATH)
+ with open(fpath, "w") as fobj:
+ fobj.write('LANG="%s"\n' % lang.lang)
+
+ except IOError as ioerr:
+ msg = "Cannot write language configuration file: %s" % ioerr.strerror
+ raise LocalizationConfigError(msg)
+
+ try:
+ fpath = os.path.normpath(root + LOCALE_CONF_FILE_PATH)
+ with open(fpath, "w") as fobj:
+ fobj.write('LANG="%s"\n' % lang.lang)
+
+ except IOError as ioerr:
+ msg = "Cannot write language configuration file: %s" % ioerr.strerror
+ raise LocalizationConfigError(msg)
+
class PreferredLocale(object):
@staticmethod