Ticket #979: sugar-979.patch

File sugar-979.patch, 1.4 KB (added by alsroot, 12 years ago)
  • webactivity.py

    From 6e1ce26c4d7c72d48d6088388f94ca299025edde Mon Sep 17 00:00:00 2001
    From: Aleksey Lim <alsroot@member.fsf.org>
    Date: Tue, 28 Jul 2009 19:54:24 +0000
    Subject: Browse activity does not start if LANG=C #979
    
    ---
     webactivity.py |   14 ++++++--------
     1 files changed, 6 insertions(+), 8 deletions(-)
    
    diff --git a/webactivity.py b/webactivity.py
    index a7c55bb..07469c1 100644
    a b import shutil 
    3030import sqlite3
    3131import cjson
    3232import gconf
     33import locale
    3334
    3435# HACK: Needed by http://dev.sugarlabs.org/ticket/456
    3536import gnome
    from xpcom import components 
    134135def _set_accept_languages():
    135136    ''' Set intl.accept_languages based on the locale
    136137    '''
    137     try:
    138         lang = os.environ['LANG'].strip('\n') # e.g. es_UY.UTF-8
    139     except KeyError:
    140         return
    141138
    142     if (not lang.endswith(".utf8") or not lang.endswith(".UTF-8")) \
    143             and lang[2] != "_":
     139    lang = locale.getdefaultlocale()[0]
     140    if not lang:
    144141        _logger.debug("Set_Accept_language: unrecognised LANG format")
    145         return
     142        return
     143    lang = lang.split('_')
    146144
    147145    # e.g. es-uy, es
    148     pref = lang[0:2] + "-" + lang[3:5].lower()  + ", " + lang[0:2]
     146    pref = lang[0] + "-" + lang[1].lower()  + ", " + lang[0]
    149147    cls = components.classes["@mozilla.org/preferences-service;1"]
    150148    prefService = cls.getService(components.interfaces.nsIPrefService)
    151149    branch = prefService.getBranch('')