diff options
Diffstat (limited to 't/i18n.t')
-rw-r--r-- | t/i18n.t | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/t/i18n.t b/t/i18n.t new file mode 100644 index 000000000..e11589d8b --- /dev/null +++ b/t/i18n.t @@ -0,0 +1,32 @@ +use strict; +use warnings; + +use Test::More; + +use FixMyStreet; +use mySociety::Locale; + +# check that the mo files have been generated +die "You need to run 'commonlib/bin/gettext-makemo --quiet FixMyStreet' " + . "to generate the *.mo files needed." + unless -e FixMyStreet->path_to( + 'locale/cy_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.mo'); + +# Example strings +my $english = "Sorry! Something's gone wrong."; +my $welsh = "Ymddiheuriadau! Mae rhywbeth wedi mynd o'i le."; + +# set english as the language +mySociety::Locale::negotiate_language( # + 'en-gb,English,en_GB|cy,Cymraeg,cy_GB', 'en_GB' +); + +mySociety::Locale::gettext_domain( 'FixMyStreet-EmptyHomes', 1 ); +mySociety::Locale::change(); +is _($english), $english, "english to english"; + +# set to welsh and check for translation +mySociety::Locale::change('cy'); +is _($english), $welsh, "english to welsh"; + +done_testing(); |