From 70101f59fa313daf0520647e04dbc2231b33d698 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Sat, 4 Aug 2012 10:10:48 -0400 Subject: [PATCH] TPAC: Add the ability to set a different default locale Installations with multiple sites might desire different default locales for their skins. This adds the Apache config directive "OILSWebDefaultLocale", which enables you to set the default locale on a global and a per-skin basis. Note that this prevents the browser Accept-language header from having any effect; sadly that header is not often used in real life. Signed-off-by: Dan Scott --- Open-ILS/examples/apache/eg_vhost.conf | 11 +++++++---- Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Open-ILS/examples/apache/eg_vhost.conf b/Open-ILS/examples/apache/eg_vhost.conf index 0265d6666a..ecefc04e4d 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf +++ b/Open-ILS/examples/apache/eg_vhost.conf @@ -577,11 +577,14 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT] # Locale messages files #PerlAddVar OILSWebLocale "en" #PerlAddVar OILSWebLocale "/openils/var/data/locale/messages.en.po" - #PerlAddVar OILSWebLocale "en_ca" - #PerlAddVar OILSWebLocale "/openils/var/data/locale/messages.en_ca.po" - #PerlAddVar OILSWebLocale "fr_ca" - #PerlAddVar OILSWebLocale "/openils/var/data/locale/messages.fr_ca.po" + #PerlAddVar OILSWebLocale "en-CA" + #PerlAddVar OILSWebLocale "/openils/var/data/locale/en-CA.po" + #PerlAddVar OILSWebLocale "fr-CA" + #PerlAddVar OILSWebLocale "/openils/var/data/locale/fr-CA.po" + # Set the default locale: defaults to en-US + #PerlAddVar OILSWebDefaultLocale "fr-CA" + # Templates will be loaded from the following paths in reverse order. PerlAddVar OILSWebTemplatePath "/openils/var/templates" #PerlAddVar OILSWebTemplatePath "/openils/var/templates_localskin" diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm index 1baf0abeeb..6bfae7a788 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm @@ -144,6 +144,7 @@ sub load_context { $ctx->{skin} = $cgi->cookie(OILS_HTTP_COOKIE_SKIN) || 'default'; $ctx->{theme} = $cgi->cookie(OILS_HTTP_COOKIE_THEME) || 'default'; $ctx->{proto} = $cgi->https ? 'https' : 'http'; + my $default_locale = $r->dir_config('OILSWebDefaultLocale') || 'en_us'; my @template_paths = uniq $r->dir_config->get('OILSWebTemplatePath'); $ctx->{template_paths} = [ reverse @template_paths ]; @@ -167,8 +168,8 @@ sub load_context { } $ctx->{locale} = $set_locale || - $cgi->cookie(OILS_HTTP_COOKIE_LOCALE) || - parse_accept_lang($r->headers_in->get('Accept-Language')) || 'en_us'; + $cgi->cookie(OILS_HTTP_COOKIE_LOCALE) || $default_locale || + parse_accept_lang($r->headers_in->get('Accept-Language')); my $mprefix = $ctx->{media_prefix}; if($mprefix and $mprefix !~ /^http/ and $mprefix !~ /^\//) { -- 2.11.0