Can someone please provide an example on how to use plural forms in a Yaml translation file for Rails i18n API. Basically this is about moving from a gettext based app to Rails.
Plural forms for a18n in Rails is documented here http://guides.rubyonrails.org/i18n.html#pluralization but with limited detail.
Say for example I have this sample from a gettext .po file that uses plural forms:
msgid "found %d fatal error"
msgid_plural "found %d fatal errors"
msgstr[0] "s'ha trobat %d error fatal"
msgstr[1] "s'han trobat %d errors fatals"
How would that look in a .yml file for the Rails i18n API. I understand that Rails i18n uses unique id keys rather than the messages themselves for translation keys - so lets say the key for the above plural messages is found_x_fatal_error.
The other thing is the plural forms selection formula, where does it go in the .yml file and how does it look - say for example we have this selection formula from a gettext .po file header:
Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;
How would it look in the YAML file.
You can configure more options:
error_msg:
zero: none
one: 1 error
other: %{count} errors
t('error_msg', :count => 15)
=> 15 errors
Depending on the version of I18n it will be {{count}} or %{count} in the yml file. More explanation can be found here:
http://guides.rubyonrails.org/i18n.html#pluralization
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With