Set locale properly in Apache configuration
authorDan Scott <dscott@laurentian.ca>
Tue, 18 Dec 2012 12:39:18 +0000 (07:39 -0500)
committerDan Scott <dscott@laurentian.ca>
Wed, 19 Dec 2012 14:55:59 +0000 (09:55 -0500)
A RewriteCond only applies to the next RewriteRule, while our config was
attempting to apply multiple rules for a single condition. Fix that up
by using skip (S) rules to apply blocks of rules for the condition in
question.

Also, use the HTTP:Accept-Language value directly, rather than relying
on a backreference (which did not seem to be working as desired).

These fixes enable screens like the Register Patron interface to present
field labels from the IDL in the correct locale, whereas previously they
would always default to en-US.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Pasi Kallinen <pasi.kallinen@pttk.fi>
Open-ILS/examples/apache/eg_vhost.conf

index 81903c9..b797832 100644 (file)
@@ -216,19 +216,17 @@ RewriteRule ^/opac/[a-z]{2}-[A-Z]{2}/extras/slimpac/(.*)$ /opac/%1/extras/slimpa
 # ----------------------------------------------------------------------------------
 # Run server-side XUL and XHTML through xmlent to load the correct XML entities
 # ----------------------------------------------------------------------------------
-RewriteCond %{HTTP:Accept-Language} ([a-z]{2}-[A-Z]{2})
-RewriteRule ^/xul/     -       [E=locale:%1]
-RewriteRule ^/reports/ -       [E=locale:%1]
-
+RewriteCond %{HTTP:Accept-Language} ^([a-z]{2}-[A-Z]{2})$
 # Default to en-US if we haven't matched a locale of the form xx-YY 
-RewriteCond %{HTTP:Accept-Language} !([a-z]{2}-[A-Z]{2})
-RewriteRule ^/xul/     -       [E=locale:en-US]
-RewriteRule ^/reports/ -       [E=locale:en-US]
-
-# Default to en-US if we are just given en
-RewriteCond %{ENV:locale} ^$ [OR]
-RewriteCond %{ENV:locale} ^en$
-RewriteRule . - [E=locale:en-US]
+RewriteRule .? - [S=4]
+RewriteRule ^/xul/      -       [E=locale:en-US]
+RewriteRule ^/reports/  -       [E=locale:en-US]
+RewriteRule .? - [E=locale:en-US]
+RewriteRule .? - [S=3]
+# Otherwise, set our real locale
+RewriteRule ^/xul/      -       [E=locale:%{HTTP:Accept-Language}]
+RewriteRule ^/reports/  -       [E=locale:%{HTTP:Accept-Language}]
+RewriteRule .? - [E=locale:%{HTTP:Accept-Language}]
 
 <LocationMatch /xul/.*\.x?html$>
     Options +Includes