diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-10-15 15:00:20 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-10-15 15:18:10 +0100 |
commit | 7ff54542f29751b465b4580bac8bfd622eb296da (patch) | |
tree | eb5f1091f5e8b73b2eee9c23e0be361eb1e6c267 /t/i18n.t | |
parent | 3eacb63bccd893ddd77de63303e0cb085ae250c4 (diff) |
Pass in headers from Catalyst if present for HTTP language negotiation.
Diffstat (limited to 't/i18n.t')
-rw-r--r-- | t/i18n.t | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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"; |