[f18-alpha] [PATCH] Add UTF-8 enconding suffix to our language strings (#854688)
Vratislav Podzimek
vpodzime at redhat.com
Thu Sep 6 13:32:36 UTC 2012
When using e.g. 'cs' as $LANG value, gettext tries to encode translated
strings with latin-1 encoding which leads to tracebacks. Using 'cs.UTF-8'
works.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/localization.py | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/pyanaconda/localization.py b/pyanaconda/localization.py
index d3dda8a..c18ce36 100644
--- a/pyanaconda/localization.py
+++ b/pyanaconda/localization.py
@@ -84,7 +84,12 @@ class LocaleInfo(object):
if self.variant is not None:
formatstr += '#{0.variant}'
- return formatstr.format(self)
+ langcode = formatstr.format(self)
+ if "." not in langcode:
+ # add enconding suffix
+ langcode = langcode + ".UTF-8"
+
+ return langcode
def __str__(self):
return self.english_name.encode('ascii', 'replace')
@@ -133,9 +138,9 @@ def get_available_translations(domain=None, localedir=None):
messagefiles = gettext.find(domain, localedir, langdict.keys(), all=True)
languages = [path.split(os.path.sep)[-3] for path in messagefiles]
- # usually there are no message files for en_US
- if 'en_US' not in languages:
- languages.append('en_US')
+ # usually there are no message files for en
+ if 'en' not in languages:
+ languages.append('en')
for langcode in languages:
try:
@@ -243,8 +248,8 @@ class Language(object):
def __init__(self, preferences={}, territory=None):
self.translations = {repr(locale):locale for locale in get_available_translations()}
self.locales = {repr(locale):locale for locale in get_all_locales()}
- self.preferred_translation = self.translations['en_US']
- self.preferred_locales = [self.locales['en_US']]
+ self.preferred_translation = self.translations['en_US.UTF-8']
+ self.preferred_locales = [self.locales['en_US.UTF-8']]
self.preferred_locale = self.preferred_locales[0]
self.all_preferences = preferences
--
1.7.11.4
More information about the anaconda-patches
mailing list