]> git.sesse.net Git - wloh/commitdiff
Add a function to fish out the locale from the URL.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 30 May 2012 18:24:20 +0000 (20:24 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 30 May 2012 18:24:20 +0000 (20:24 +0200)
www/index.pl

index 54c0b716461593b5a2d155e53d5118b9c1b91219..6a869a934f6d7ee054b51296c7d22e3ac331a5c3 100755 (executable)
@@ -340,6 +340,13 @@ sub print_header {
 EOF
 }
 
+sub get_locale {
+       my $cgi = shift;
+       my $url = $cgi->url(-absolute => 1);
+       $url =~ m#^/([a-z][a-z]-[A-Z][A-Z])/# or die "Invalid locale!";
+       return $1;
+}
+
 sub print_footer {
        print <<"EOF";
   </body>