nicolai86 / rails-asset-localization

asset pipeline localization using i18next for rails 3.2 & 4
http://blog.nicolai86.eu
MIT License
11 stars 6 forks source link

Rails I18n plural forms don't work in i18next #4

Open lsimoneau opened 10 years ago

lsimoneau commented 10 years ago

Changing the interpolation configuration of i18next makes most translations from Rails compatible with i18next, but the libraries have fundamentally different approaches to plural forms, so translations with plurals can't be reused between Rails and JS.

Should this library include functionality to transform the plurals for i18next?

nicolai86 commented 9 years ago

I think it would be a good fit, but I've not tried to transfer those yet. Since I'm not using rails-asset-localization actively at the moment I might not get to adding that functionality any time soon.

fluxsaas commented 9 years ago

what about overriding i18n.pluralExtension.addRule(lng, obj)

from: http://i18next.com/pages/doc_features.html

You can override the existing rules via i18n.pluralExtension.addRule(lng, obj)

but i guess it's only to figure out which count option is plural rather than the key

an example for rails pluralization is:

date: {
    prompts: {
      x_month: {
        one: "Monat",
        other: "Monate",
      }
    }
}

i18next:

date: {
  prompts: {  
      x_month: {
        key: 'Monat',
        key_plural: 'Monate',
      }
  } 
};