TPac: Default to en_us if no locales are configured
authorBill Erickson <berick@esilibrary.com>
Mon, 12 Sep 2011 18:13:42 +0000 (14:13 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 12 Sep 2011 18:13:42 +0000 (14:13 -0400)
Code will create an en_us handler that falls through to the strings in
the templates.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm

index b5812e6..20a2e4d 100644 (file)
@@ -229,6 +229,9 @@ sub load_locale_handlers {
 
     my @locale_tags = sort { length($a) <=> length($b) } keys %locales;
 
+    # If no locales are defined, fall back to en_us so that at least 1 handler exists
+    push(@locale_tags, 'en_us') unless @registered_locales or @locale_tags;
+
     for my $idx (0..$#locale_tags) {
 
         my $tag = $locale_tags[$idx];
@@ -247,8 +250,7 @@ sub load_locale_handlers {
             }
         }
 
-        my $messages = $locales{$tag};
-        $messages = '' if ref $messages; # empty {}
+        my $messages = $locales{$tag} || '';
 
         # TODO Can we do this without eval?
         my $eval = <<"        EVAL";