diff options
author | Sascha Silbe <sascha@silbe.org> | 2009-09-23 17:09:09 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha@silbe.org> | 2009-09-23 17:09:09 (GMT) |
commit | 569e9d9a98e08ab223842119c276beaca83f2e43 (patch) | |
tree | 8b17539940449f0db5170416ffeba5c4163a7f42 | |
parent | 7bf05fe942dfb7e701403e30a73178872b73ce8b (diff) |
bin/sugar: parse ~/.i18n
-rw-r--r-- | .topdeps | 2 | ||||
-rw-r--r-- | .topmsg | 6 | ||||
-rw-r--r-- | bin/sugar | 13 | ||||
-rw-r--r-- | bin/sugar-emulator | 21 |
4 files changed, 14 insertions, 28 deletions
@@ -1 +1 @@ -upstream/master +t/sugar-py @@ -1,6 +1,8 @@ From: Sascha Silbe <sascha@silbe.org> -Subject: [PATCH] Turn bin/sugar into a Python executable +Subject: [PATCH] bin/sugar: parse ~/.i18n -Turn bin/sugar into a Python executable. +The control panel stores locale settings in ~/.i18n, but currently this file +is only read by Fedora scripts and sugar-emulator. Parsing it in sugar will +make language selection work in "native" sessions on all distros. Signed-off-by: Sascha Silbe <sascha@silbe.org> @@ -28,8 +28,8 @@ import sys import jarabe.config -def _parse_debug(): - """Apply settings from ~/.sugar/debug. +def _parse_environment(path): + """Set environment variables from given file if it exists. Format of the file: @@ -39,7 +39,10 @@ def _parse_debug(): var2="double quotes are just $NOISE" var3=without $NOISE """ - for line in file(os.path.expanduser('~/.sugar/debug')): + if not os.path.exists(path): + return + + for line in file(path): old_style = False line = line.strip() if not line or line.startswith('#'): @@ -87,6 +90,9 @@ def _setup_environment(): os.environ['PATH'] += ':/sbin:/usr/sbin' + _parse_environment(os.path.expanduser('~/.i18n')) + _parse_environment(os.path.expanduser('~/.sugar/debug')) + def _start_window_manager(): """Start the window manager in the background.""" @@ -102,7 +108,6 @@ def main(): """Script-level operations""" try: _setup_environment() - _parse_debug() _start_window_manager() _run_session() diff --git a/bin/sugar-emulator b/bin/sugar-emulator index 7f06609..ca7614e 100644 --- a/bin/sugar-emulator +++ b/bin/sugar-emulator @@ -104,27 +104,6 @@ def _setup_env(): os.environ['STREAM_ENGINE_LOGFILE'] = os.path.join( env.get_profile_path(), 'logs', 'telepathy-stream-engine.log') - path = os.path.join(os.environ.get("HOME"), '.i18n') - if os.path.exists(path): - fd = open(path, "r") - lines = fd.readlines() - fd.close() - - language_env_variable = None - lang_env_variable = None - - for line in lines: - if line.startswith("LANGUAGE="): - lang = line[9:].replace('"', '') - language_env_variable = lang.strip() - elif line.startswith("LANG="): - lang_env_variable = line[5:].replace('"', '') - - # There might be cases where .i18n may not contain a LANGUAGE field - if language_env_variable is not None: - os.environ['LANGUAGE'] = language_env_variable - if lang_env_variable is not None: - os.environ['LANG'] = lang_env_variable def main(): """Script-level operations""" |