Internal Server Error caused by I18n::InvalidPluralizationData


(Jaromír Müller) #1

When new user tries to create new post with more then 2 links then he receives “Internal server error”.

I found in /var/discourse/shared/standalone/log/rails/production.log the following:

Completed 500 Internal Server Error in 76ms (ActiveRecord: 12.5ms)
I18n::InvalidPluralizationData (translation data {:zero=>"Bohužel, návštěvníci nemohou vkládat odkazy do příspěvků.", :one=>"Bohužel, návštěvníci mohou do jednoho příspěvku vložit jen jeden odkaz.", :other=>"Bohužel, návštěvníci mohou do jednoho příspěvku vložit maximálně %{count} odkazů."} can not be used with :count => 2)
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/i18n-0.7.0/lib/i18n/backend/pluralization.rb:35:in `pluralize'

I have installed the latest version of discourse (latest-release +140, 1.4.0.beta12).

Jaro.


(Jeff Atwood) #2

Translation error, as indicated in the error log message.


(Gerhard Schlager) #3

Well, actually it’s a problem in the English locale file that’s causing this.

server.en.yml contains the zero, one and other keys, but according to the official pluralization rules only one and other are allowed. It currently works for English (and all the other languages that use only one and other) because the Ruby I18n module has a special case for the zero key.

Unfortunately Transifex doesn’t handle the special case of zero, so it doesn’t detect any key as pluralized if there exists anything else than one and other in the English locale files.

That’s the reason why the server.cs.yml contains the zero, one and other keys instead of the required one, few and other.

There’s currently no easy way to fix this. I was planning on proposing a few solutions to this problem in the next few days.


(Sam Saffron) #4

Simplest fix is just splitting this translation, so zero has its own key

no_links_allowed
too_many_links

problem solved :slight_smile:


(Gerhard Schlager) #5

Yes, splitting would be the easiest option. There are about 20 keys with this problem, so that shouldn’t be that much work.


(Jaromír Müller) #6

How can I patch our code to address this problem? I would put there something really simple ‘Too much links in your post. Try to remove few of them. Sorry.’.


(Gerhard Schlager) #7

You’d need to manually add the missing few keys in server.cs.yml:

Don’t forget to use the %{count} placeholder for those translations.


I’ll try to create a patch for this in the next few days unless someone else wants to do it? I’ve already implemented some tests to guard against the usage of the zero key in English locale files.


(Gerhard Schlager) #8

I submitted a PR:


(Régis Hanol) #9