From: Steinar H. Gunderson Date: Wed, 30 May 2012 18:24:20 +0000 (+0200) Subject: Add a function to fish out the locale from the URL. X-Git-Url: https://git.sesse.net/?p=wloh;a=commitdiff_plain;h=933440f50f4ac2267adfca3442a4d8e9aebd6d8b Add a function to fish out the locale from the URL. --- diff --git a/www/index.pl b/www/index.pl index 54c0b71..6a869a9 100755 --- a/www/index.pl +++ b/www/index.pl @@ -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";