ruby-i18n/ruby-cldr

Remove special `one` key handling in `Currencies#currency`

Closed this issue · 0 comments

As noted in this comment, Currencies#currency artificially adds a translation for the one key, even though there is no corresponding translation in the upstream CLDR.

Tactical issues

  • It adds a one key for languages that don't have a one pluralization rule (e.g., zh); slightly bloating the data files

  • This is missing all of the other pluralization keys that might be needed in the locale.

    I18n.with_locale(:af) do
      I18n.t("currencies.LVL", count: 0)
    end
    I18n::InvalidPluralizationData: translation data {:one=>"Lettiese lats", :name=>"Lettiese lats", :symbol=>"LVL"} can not be used with :count => 0. key 'other' is missing.
    

Philosophical issue

My guess without context is that this was done to give a "reasonable" default for the currency in cases where CLDR doesn't have pluralization translation information for the currency.

The logic is present all the way back to at least 2009-12-30:

count = node.attribute('count') ? node.attribute('count').value.to_sym : :one

IMO, in some sense this is fabricating information that isn't in the upstream CLDR dataset.
Unless ruby-cldr's mission is to augment CLDR with its own, I feel that this logic belongs downstream of ruby-cldr in the consumer's code.

Solutions?

Remove this special casing of the one key.
If that's not an option, then add keys for each pluralization key IFF the language uses that pluralization key.