[open-ils-commits] r13098 - trunk/Open-ILS/src/perlmods/OpenILS/WWW (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu May 7 18:00:21 EDT 2009
Author: erickson
Date: 2009-05-07 18:00:17 -0400 (Thu, 07 May 2009)
New Revision: 13098
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm
Log:
support for parsing accept-language for locale
Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm 2009-05-07 21:29:31 UTC (rev 13097)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm 2009-05-07 22:00:17 UTC (rev 13098)
@@ -73,12 +73,23 @@
$ctx->{theme} = $cgi->cookie(OILS_HTTP_COOKIE_THEME) || 'default';
$ctx->{locale} =
$cgi->cookie(OILS_HTTP_COOKIE_LOCALE) ||
- $r->headers_in->get('Accept-Language') || 'en-US'; # this will need some trimming
+ parse_accept_lang($r->headers_in->get('Accept-Language')) || 'en-US'; # this will need some trimming
$r->log->debug('skin = ' . $ctx->{skin} . ' : theme = ' .
$ctx->{theme} . ' : locale = ' . $ctx->{locale});
return $ctx;
}
+# turn Accept-Language into sometihng EG can understand
+sub parse_accept_lang {
+ my $al = shift;
+ return undef unless $al;
+ my ($locale) = split(/,/, $al);
+ ($locale) = split(/;/, $locale);
+ return undef unless $locale;
+ $locale =~ s/-(.*)/eval '-'.uc("$1")/e;
+ return $locale;
+}
+
# Given a URI, finds the configured template and any extra page
# arguments (trailing path info). Any extra data is returned
# as page arguments, in the form of an array, one item per
More information about the open-ils-commits
mailing list