diff --git a/extensions/cpsection/language/model.py b/extensions/cpsection/language/model.py
index e714dad..9c75f59 100644
|
a
|
b
|
|
| 21 | 21 | # |
| 22 | 22 | |
| 23 | 23 | import os |
| 24 | | from gettext import gettext as _ |
| | 24 | import gettext |
| 25 | 25 | import subprocess |
| | 26 | import operator |
| 26 | 27 | |
| 27 | 28 | _default_lang = 'en_US.utf8' |
| 28 | | _standard_msg = _("Could not access ~/.i18n. Create standard settings.") |
| | 29 | _standard_msg = \ |
| | 30 | gettext.gettext("Could not access ~/.i18n. Create standard settings.") |
| | 31 | |
| | 32 | def _translate_locale_info(language, territory, locale_code): |
| | 33 | ''' |
| | 34 | Returns translated name of language and territory for |
| | 35 | locale specified by code |
| | 36 | ''' |
| | 37 | lang_trans = gettext.translation('iso_639', languages=[locale_code], \ |
| | 38 | fallback = True) |
| | 39 | territory_trans = gettext.translation('iso_3166', languages=[locale_code], \ |
| | 40 | fallback = True) |
| | 41 | return (lang_trans.gettext(language), territory_trans.gettext(territory)) |
| | 42 | |
| 29 | 43 | |
| 30 | 44 | def read_all_languages(): |
| 31 | 45 | fdp = subprocess.Popen(['locale', '-av'], stdout=subprocess.PIPE) |
| … |
… |
def read_all_languages(): |
| 40 | 54 | elif line.find('territory |') != -1: |
| 41 | 55 | territory = line.lstrip('territory |') |
| 42 | 56 | if locale.endswith('utf8') and len(lang): |
| 43 | | locales.append((lang, territory, locale)) |
| | 57 | trans_lang, trans_territory = _translate_locale_info(lang, \ |
| | 58 | territory, locale) |
| | 59 | locales.append((trans_lang, trans_territory, locale, lang)) |
| 44 | 60 | |
| 45 | 61 | #FIXME: This is a temporary workaround for locales that are essential to |
| 46 | 62 | # OLPC, but are not in Glibc yet. |
| 47 | | locales.append(('Kreyol', 'Haiti', 'ht_HT.utf8')) |
| 48 | | locales.append(('Dari', 'Afghanistan', 'fa_AF.utf8')) |
| 49 | | locales.append(('Pashto', 'Afghanistan', 'ps_AF.utf8')) |
| | 63 | locales.append(('Kreyol', 'Haiti', 'ht_HT.utf8', 'Kreyol')) |
| | 64 | locales.append(('Dari', 'Afghanistan', 'fa_AF.utf8', 'Dari')) |
| | 65 | locales.append(('Pashto', 'Afghanistan', 'ps_AF.utf8', 'Pashto')) |
| 50 | 66 | |
| 51 | | locales.sort() |
| | 67 | locales.sort(key=operator.itemgetter(3)) |
| 52 | 68 | return locales |
| 53 | 69 | |
| 54 | 70 | def _initialize(): |
| … |
… |
def print_languages(): |
| 121 | 137 | found_lang = True |
| 122 | 138 | break |
| 123 | 139 | if not found_lang: |
| 124 | | print (_("Language for code=%s could not be determined.") % code) |
| | 140 | print (gettext.gettext("Language for code=%s could not \ |
| | 141 | be determined.") % code) |
| 125 | 142 | |
| 126 | 143 | def set_languages(languages): |
| 127 | 144 | """Set the system language. |
| … |
… |
def set_languages(languages): |
| 141 | 158 | if code == languages: |
| 142 | 159 | _write_i18n(locale) |
| 143 | 160 | return 1 |
| 144 | | print (_("Sorry I do not speak \'%s\'.") % languages) |
| | 161 | print (gettext.gettext("Sorry I do not speak \'%s\'.") % languages) |
| 145 | 162 | else: |
| 146 | 163 | _write_i18n(languages) |
| 147 | 164 | |
diff --git a/extensions/cpsection/language/view.py b/extensions/cpsection/language/view.py
index 5b7e292..ae4c869 100644
|
a
|
b
|
from sugar.graphics.icon import Icon |
| 24 | 24 | from jarabe.controlpanel.sectionview import SectionView |
| 25 | 25 | from jarabe.controlpanel.inlinealert import InlineAlert |
| 26 | 26 | |
| 27 | | _translate_language = lambda msg: gettext.dgettext('iso_639', msg) |
| 28 | | _translate_country = lambda msg: gettext.dgettext('iso_3166', msg) |
| 29 | | |
| 30 | 27 | CLASS = 'Language' |
| 31 | 28 | ICON = 'module-language' |
| 32 | 29 | TITLE = gettext.gettext('Language') |
| … |
… |
class Language(SectionView): |
| 82 | 79 | |
| 83 | 80 | |
| 84 | 81 | store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) |
| 85 | | for language, country, code in self._available_locales: |
| 86 | | description = '%s (%s)' % (_translate_language(language), \ |
| 87 | | _translate_country(country)) |
| | 82 | for tr_lang, tr_territory, code, lang in self._available_locales: |
| | 83 | description = '%s (%s)' % (tr_lang, tr_territory) |
| 88 | 84 | store.append([code, description]) |
| 89 | 85 | |
| 90 | 86 | combobox = gtk.ComboBox(model=store) |