From: Sascha Silbe <sascha@silbe.org>
Subject: [PATCH] move ~/.i18n parsing from sugar-emulator to sugar (#1441)
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>
---
bin/sugar.in | 5 ++++-
src/jarabe/util/emulator.py | 21 ---------------------
2 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/bin/sugar.in b/bin/sugar.in
index fea79a9..55a085e 100644
a
|
b
|
if ! test -f "$GTK2_RC_FILES"; then |
45 | 45 | exit 1 |
46 | 46 | fi |
47 | 47 | |
48 | | # Source debug definitions |
| 48 | # Source language settings and debug definitions |
| 49 | if [ -f ~/.i18n ]; then |
| 50 | . ~/.i18n |
| 51 | fi |
49 | 52 | if [ -f ~/.sugar/debug ]; then |
50 | 53 | . ~/.sugar/debug |
51 | 54 | fi |
diff --git a/src/jarabe/util/emulator.py b/src/jarabe/util/emulator.py
index d2dacb5..ab713ba 100644
a
|
b
|
def _setup_env(): |
104 | 104 | os.environ['STREAM_ENGINE_LOGFILE'] = os.path.join( |
105 | 105 | env.get_profile_path(), 'logs', 'telepathy-stream-engine.log') |
106 | 106 | |
107 | | path = os.path.join(os.environ.get("HOME"), '.i18n') |
108 | | if os.path.exists(path): |
109 | | fd = open(path, "r") |
110 | | lines = fd.readlines() |
111 | | fd.close() |
112 | | |
113 | | language_env_variable = None |
114 | | lang_env_variable = None |
115 | | |
116 | | for line in lines: |
117 | | if line.startswith("LANGUAGE="): |
118 | | lang = line[9:].replace('"', '') |
119 | | language_env_variable = lang.strip() |
120 | | elif line.startswith("LANG="): |
121 | | lang_env_variable = line[5:].replace('"', '') |
122 | | |
123 | | # There might be cases where .i18n may not contain a LANGUAGE field |
124 | | if language_env_variable is not None: |
125 | | os.environ['LANGUAGE'] = language_env_variable |
126 | | if lang_env_variable is not None: |
127 | | os.environ['LANG'] = lang_env_variable |
128 | 107 | |
129 | 108 | def main(): |
130 | 109 | """Script-level operations""" |