[Sugar-devel] [PATCH browse] Display pages based on locale specific information
Simon Schampijer
simon at schampijer.de
Fri Jan 13 06:35:18 EST 2012
This displays pages based on your locale information e.g. 'google.com'
will be in French when your locale is set to 'fr'. We use our
associated SoupSession to set the "accept-language-auto" property [1]
which will set the 'accept-language' header when making requests based
on the return value of g_get_language_names() [2]. This does
replace our custom code that did determine the locale information
and the 'intl.accept_languages' [3] property before.
[1] http://developer.gnome.org/libsoup/stable/SoupSession.html#SoupSession--accept-language-auto
[2] http://developer.gimp.org/api/2.0/glib/glib-I18N.html#g-get-language-names
[3] http://kb.mozillazine.org/About:config_entries#Intl.
Signed-off-by: Simon Schampijer <simon at laptop.org>
---
webactivity.py | 21 +++++----------------
1 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/webactivity.py b/webactivity.py
index 7f2eafa..8b8db59 100644
--- a/webactivity.py
+++ b/webactivity.py
@@ -27,6 +27,8 @@ GObject.threads_init()
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
+from gi.repository import WebKit
+
import base64
import time
import shutil
@@ -138,20 +140,6 @@ def _set_char_preference(name, value):
branch.setCharPref(name, value)
-def _set_accept_languages():
- """Set intl.accept_languages preference based on the locale"""
-
- lang = locale.getdefaultlocale()[0]
- if not lang:
- _logger.debug("Set_Accept_language: unrecognised LANG format")
- return
- lang = lang.split('_')
-
- # e.g. es-uy, es
- pref = lang[0] + "-" + lang[1].lower() + ", " + lang[0]
- _set_char_preference('intl.accept_languages', pref)
- logging.debug('LANG set')
-
from browser import TabbedView
from webtoolbar import PrimaryToolbar
from edittoolbar import EditToolbar
@@ -179,6 +167,9 @@ class WebActivity(activity.Activity):
_logger.debug('Starting the web activity')
+ session = WebKit.get_default_session()
+ session.set_property('accept-language-auto', True)
+
# FIXME
# downloadmanager.remove_old_parts()
@@ -186,8 +177,6 @@ class WebActivity(activity.Activity):
self._tabbed_view = TabbedView()
self._tabbed_view.connect('focus-url-entry', self._on_focus_url_entry)
- # FIXME
- # _set_accept_languages()
_seed_xs_cookie()
# HACK
--
1.7.7.5
More information about the Sugar-devel
mailing list