Ticket #51: sl_51.patch

File sl_51.patch, 4.0 KB (added by sayamindu, 12 years ago)

Patch (with a couple of Pylint fixes)

  • extensions/cpsection/language/model.py

    diff --git a/extensions/cpsection/language/model.py b/extensions/cpsection/language/model.py
    index e714dad..9c75f59 100644
    a b  
    2121#
    2222
    2323import os
    24 from gettext import gettext as _
     24import gettext
    2525import subprocess
     26import operator
    2627
    2728_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
     32def _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
    2943
    3044def read_all_languages():
    3145    fdp = subprocess.Popen(['locale', '-av'], stdout=subprocess.PIPE)
    def read_all_languages(): 
    4054        elif line.find('territory |') != -1:
    4155            territory = line.lstrip('territory |')
    4256            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))
    4460
    4561    #FIXME: This is a temporary workaround for locales that are essential to
    4662    # 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'))
    5066
    51     locales.sort()
     67    locales.sort(key=operator.itemgetter(3))
    5268    return locales
    5369
    5470def _initialize():     
    def print_languages(): 
    121137                found_lang = True
    122138                break
    123139        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)
    125142   
    126143def set_languages(languages):
    127144    """Set the system language.
    def set_languages(languages): 
    141158                if code == languages:
    142159                    _write_i18n(locale)
    143160                    return 1
    144             print (_("Sorry I do not speak \'%s\'.") % languages)
     161            print (gettext.gettext("Sorry I do not speak \'%s\'.") % languages)
    145162    else:
    146163        _write_i18n(languages)
    147164
  • extensions/cpsection/language/view.py

    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 
    2424from jarabe.controlpanel.sectionview import SectionView
    2525from jarabe.controlpanel.inlinealert import InlineAlert
    2626
    27 _translate_language = lambda msg: gettext.dgettext('iso_639', msg)
    28 _translate_country = lambda msg: gettext.dgettext('iso_3166', msg)
    29 
    3027CLASS = 'Language'
    3128ICON = 'module-language'
    3229TITLE = gettext.gettext('Language')
    class Language(SectionView): 
    8279       
    8380               
    8481        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)
    8884            store.append([code, description])
    8985
    9086        combobox = gtk.ComboBox(model=store)