Closed garethrees closed 4 years ago
Doesn't effect other locales, can be reproduced with:
[1] pry(main)> AlaveteliLocalization.with_locale('rw') { FastGettext.n_("{{number_of_comments}} comment", "{{number_of_comments}} comments", "0").html_safe }
=> "{{number_of_comments}} comments"
[2] pry(main)> AlaveteliLocalization.with_locale('fr') { FastGettext.n_("{{number_of_comments}} comment", "{{number_of_comments}} comments", "0").html_safe }
ArgumentError: comparison of String with 1 failed
from (eval):1:in `>'
Full stack trace:
(eval):1:in `>'
(eval):1:in `block (2 levels) in pluralisation_rule'
fast_gettext (2.0.2) lib/fast_gettext/mo_file.rb:34:in `eval'
fast_gettext (2.0.2) lib/fast_gettext/mo_file.rb:34:in `block (2 levels) in pluralisation_rule'
fast_gettext (2.0.2) lib/fast_gettext/translation.rb:24:in `n_'
lib/i18n_fixes.rb:21:in `n_'
This doesn't seem to be related to translations done via Transifex as its erroring before the gettext interpolation.
Guessing that we're getting string numbers rather than integers that we're using to compare against https://github.com/mysociety/alaveteli/blob/develop/app/views/general/blog.html.erb#L24 – probably just needs a #to_i
.
Guessing that we're getting string numbers rather than integers that we're using to compare against https://github.com/mysociety/alaveteli/blob/develop/app/views/general/blog.html.erb#L24 – probably just needs a
#to_i
.
Yeah that'll do it. I have looked into why fr
works differently to other locales and it seems its down to https://github.com/mysociety/sobanukirwa-theme/blob/master/locale-theme/fr/app.po#L22 where its doing n > 1
where as other locales have plural forms such as n != 1
which would return false when given a string.
Ha! TIL
Reopening as this has not been deployed yet