diff --git a/launcher/cog-launcher.c b/launcher/cog-launcher.c index 4c8cdb5a..e3a35556 100644 --- a/launcher/cog-launcher.c +++ b/launcher/cog-launcher.c @@ -270,6 +270,8 @@ on_automation_started(WebKitWebContext *context, WebKitAutomationSession *sessio static void cog_launcher_startup(GApplication *application) { + const gchar *const *locales; + G_APPLICATION_CLASS(cog_launcher_parent_class)->startup(application); /* @@ -318,6 +320,24 @@ cog_launcher_startup(GApplication *application) g_object_set(self->shell, "device-scale-factor", s_options.device_scale_factor, NULL); + /* build Accept-Language from locale, filtering out encodings */ + locales = g_get_language_names(); + if (locales) { + guint i, n, length = g_strv_length((gchar **) locales); + gchar **languages = g_new0(gchar *, length); + + for (n = 0, i = 0; locales[i]; i++) { + const gchar *lang = locales[i]; + if (!strcmp(lang, "C") || !strcmp(lang, "POSIX") || strchr(lang, '.')) + continue; + languages[n++] = g_strdup(lang); + } + + webkit_web_context_set_preferred_languages(cog_shell_get_web_context(self->shell), + (const gchar *const *) languages); + g_strfreev(languages); + } + if (s_options.handler_map) { GHashTableIter i; void *key, *value;