notfixed 570142 2.29.5-1
tags 570142 +patch
thanks

Hi,

given that Debian's own website is one of the rare websites actually
relying on HTTP's content negotiation for language selection, it's
really shame that this does not work as of writing.

Therefore I've extracted a patch from GNOME's bugzilla
(https://bugzilla.gnome.org/show_bug.cgi?id=602547 not yet committed),
and tested it so that it applies and works for me(TM).

diff -urN epiphany-browser-2.30.2/debian/patches/15_accept_language.patch epiphany-browser-2.30.2.mine//debian/patches/15_accept_language.patch
--- epiphany-browser-2.30.2/debian/patches/15_accept_language.patch	1970-01-01 02:00:00.000000000 +0200
+++ epiphany-browser-2.30.2.mine//debian/patches/15_accept_language.patch	2010-06-29 22:34:09.000000000 +0300
@@ -0,0 +1,98 @@
+From 8c6de6244609ade75abc3830bd9a1d9904618743 Mon Sep 17 00:00:00 2001
+From: Mario Sanchez Prada <msanc...@igalia.com>
+Date: Thu, 18 Mar 2010 17:35:44 +0100
+Subject: [PATCH] Set the quality values (qv) for the accept-languages string
+
+Make sure every item in the list of preferred languages gets an
+appropriate qv value according to the RFC2616, to better define the
+actual selection made by the user.
+
+Bug #602547
+---
+ embed/ephy-embed-prefs.c |   51 ++++++++++++++++++++++++++++++++++++++++++---
+ 1 files changed, 47 insertions(+), 4 deletions(-)
+
+diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
+index 125cdde..cf79309 100644
+--- a/embed/ephy-embed-prefs.c
++++ b/embed/ephy-embed-prefs.c
+@@ -278,6 +278,48 @@ webkit_pref_callback_font_family (GConfClient *client,
+   }
+ }
+ 
++/* Part of this code taken from libsoup (soup-session.c) */
++static gchar *
++build_accept_languages_header (GArray *languages)
++{
++  gchar **langs = NULL;
++  gchar *langs_str = NULL;
++  gint delta;
++  gint i;
++
++  g_return_val_if_fail (languages != NULL, NULL);
++
++  /* Calculate deltas for the quality values */
++  if (languages->len < 10)
++    delta = 10;
++  else if (languages->len < 20)
++    delta = 5;
++  else
++    delta = 1;
++
++  /* Set quality values for each language */
++  langs = (gchar **) languages->data;
++  for (i = 0; langs[i] != NULL; i++) {
++    gchar *lang = (gchar *) langs[i];
++    gint quality = 100 - i * delta;
++
++    if (quality > 0 && quality < 100) {
++      double qvalue = quality / 100.0;
++      langs[i] = g_strdup_printf ("%s;q=%.2g", lang, qvalue);
++    } else {
++      /* Just dup the string in this case */
++      langs[i] = g_strdup (lang);
++    }
++    g_free (lang);
++  }
++
++  /* Get the result string */
++  if (languages->len > 0)
++    langs_str = g_strjoinv (", ", langs);
++
++  return langs_str;
++}
++
+ /* Based on Christian Persch's code from gecko backend of epiphany
+    (old transform_accept_languages_list() function) */
+ static void
+@@ -290,7 +332,7 @@ webkit_pref_callback_accept_languages (GConfClient *client,
+   GConfValue *gcvalue;
+   GArray *array;
+   GSList *languages, *l;
+-  char **langs;
++  char **array_data;
+   char *langs_str;
+   char *webkit_pref;
+ 
+@@ -318,14 +360,15 @@ webkit_pref_callback_accept_languages (GConfClient *client,
+ 
+   ephy_langs_sanitise (array);
+ 
+-  langs = (char **) g_array_free (array, FALSE);
+-  langs_str = g_strjoinv (", ", langs);
++  langs_str = build_accept_languages_header (array);
+ 
+   /* Update Soup session */
+   session = webkit_get_default_session ();
+   g_object_set (G_OBJECT (session), webkit_pref, langs_str, NULL);
+ 
+-  g_strfreev (langs);
++  /* Free memory */
++  array_data = (char **) g_array_free (array, FALSE);
++  g_strfreev (array_data);
+   g_free (langs_str);
+ }
+ 
+-- 
+1.7.0
+
diff -urN epiphany-browser-2.30.2/debian/patches/series epiphany-browser-2.30.2.mine//debian/patches/series
--- epiphany-browser-2.30.2/debian/patches/series	2010-06-29 22:31:13.000000000 +0300
+++ epiphany-browser-2.30.2.mine//debian/patches/series	2010-06-29 22:40:41.000000000 +0300
@@ -6,5 +6,6 @@
 07_bookmarks.patch
 10_smart_bookmarks.patch
 12_safetypes.patch
+15_accept_language.patch
 99_autoreconf.patch
 99_ltmain_as-needed.patch
-- 
Tommi Vainikainen

Reply via email to