aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-10-15 15:00:20 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-10-15 15:18:10 +0100
commit7ff54542f29751b465b4580bac8bfd622eb296da (patch)
treeeb5f1091f5e8b73b2eee9c23e0be361eb1e6c267 /t
parent3eacb63bccd893ddd77de63303e0cb085ae250c4 (diff)
Pass in headers from Catalyst if present for HTTP language negotiation.
Diffstat (limited to 't')
-rw-r--r--t/i18n.t11
1 files changed, 11 insertions, 0 deletions
diff --git a/t/i18n.t b/t/i18n.t
index 4179dd8d0..f1cc86985 100644
--- a/t/i18n.t
+++ b/t/i18n.t
@@ -7,6 +7,7 @@ use FixMyStreet;
use mySociety::Locale;
use Encode;
use Data::Dumper;
+use HTTP::Headers;
use Sort::Key qw(keysort);
use POSIX 'strcoll';
local $Data::Dumper::Sortkeys = 1;
@@ -18,6 +19,16 @@ die "You need to run 'commonlib/bin/gettext-makemo --quiet FixMyStreet' "
unless -e FixMyStreet->path_to(
'locale/cy_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.mo');
+# Test the language negotiation works
+my $lang = mySociety::Locale::negotiate_language(
+ 'en-gb,English,en_GB|cy,Cymraeg,cy_GB|es,Spanish,es_ES',
+ undef,
+ HTTP::Headers->new(
+ Accept_Language => 'es,en-gb;q=0.6,en;q=0.4'
+ )
+);
+is $lang, 'es', 'Language negotiation works okay';
+
# Example strings
my $english = "Please enter a valid email";
my $welsh = "Cofnodwch gyfeiriad e-bost dilys";