ruby-gettext / gettext

Gettext gem is a pure Ruby Localization(L10n) library and tool which is modeled after the GNU gettext package.
https://ruby-gettext.github.io/
69 stars 28 forks source link

n_('singular', 'plural', 2) won't return nil anymore if PO contains msgstr[1] ""' #60

Closed MichaelHoste closed 5 years ago

MichaelHoste commented 5 years ago

Hello,

We noticed a small bug where n_("singular", "plural", 2) returned nil when the PO contains something like this:

msgid "singular"
msgid_plural "plural"
msgstr[0] "singular translation"
msgstr[1] ""

Usually it's not a big deal, but with n_ we usually do constructions like this:

n_('%{seconds} second', '%{seconds} seconds', 2) % { seconds: 2 }

And it raises undefined method % for nil., so it certainly need to be fixed.

I hope it will be merged. Have a nice day!

kou commented 5 years ago

Good catch!