# Internal Server Error caused by I18n::InvalidPluralizationData

**URL:** https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573
**Category:** Bug
**Created:** [September 22, 2015, 10:34am UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573 "2015-09-22T10:34:25Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![jaromir](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jaromir/32/114930_2.png) [@jaromir](https://meta.discourse.org/u/jaromir)
#### Post date: [September 22, 2015, 10:34am UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/1 "2015-09-22T10:34:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 22, 2015, 11:22am UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/2 "2015-09-22T11:22:51Z")

</div>

Translation error, as indicated in the error log message.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [September 22, 2015, 11:56am UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/3 "2015-09-22T11:56:36Z")

</div>

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](http://www.unicode.org/cldr/charts/25/supplemental/language_plural_rules.html#en) 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](https://github.com/svenfuchs/i18n/blob/master/lib/i18n/backend/base.rb#L133-L135).

> <https://github.com/discourse/discourse/blob/main/config/locales/server.en.yml#L156-L159>

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`](https://github.com/discourse/discourse/blob/master/config/locales/plurals.rb#L16).

> <https://github.com/discourse/discourse/blob/main/config/locales/server.cs.yml#L110-L113>

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.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [September 22, 2015, 12:27pm UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/4 "2015-09-22T12:27:59Z")

</div>

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

`no_links_allowed`  
`too_many_links`

problem solved 🙂

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [September 22, 2015, 12:31pm UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/5 "2015-09-22T12:31:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jaromir](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jaromir/32/114930_2.png) [@jaromir](https://meta.discourse.org/u/jaromir)
#### Post date: [September 24, 2015, 7:23am UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/6 "2015-09-24T07:23:31Z")

</div>

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.’._

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [September 24, 2015, 10:07am UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/7 "2015-09-24T10:07:05Z")

</div>

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

> <https://github.com/discourse/discourse/blob/main/config/locales/server.cs.yml#L94-L113>

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.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [September 25, 2015, 10:28pm UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/8 "2015-09-25T22:28:12Z")

</div>

I submitted a PR:  
[https://github.com/discourse/discourse/pull/3817](https://github.com/discourse/discourse/pull/3817)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [July 28, 2016, 11:16am UTC](https://meta.discourse.org/t/internal-server-error-caused-by-i18n-invalidpluralizationdata/33573/9 "2016-07-28T11:16:49Z")

</div>


