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

Fixing sorting of msgids when translations with context are present #55

Closed coffeebite closed 5 years ago

coffeebite commented 7 years ago

When there are some translations with context and some without, sort_by tries to compare string with nil and fails. This fix converts the nils to empty string before comparison.

kou commented 7 years ago

Please provide a rxgettext input Ruby code that reproduces the problem.

rgraff commented 5 years ago

I have a related PR https://github.com/ruby-gettext/gettext/pull/61 that simply always sorts by the msgid and disregards the msgctxt

kou commented 5 years ago

@rgraff Can we close this?

rgraff commented 5 years ago

PR #61 resolves the sorting error when a context is present. This PR also addresses the parsing of the context when the s_ method. I believe that's still an open issue. I don't know if this fix resolves it.

kou commented 5 years ago

OK. We need a test case to reproduce this case.

rgraff commented 5 years ago

@kou I believe the only change here that I didn't fix in PR #61 is that the parser will split calls to s_ to create a msgctxt and an msgid, similar to the p_ method. I believe that's a breaking change and is not desireable. I think you can close this PR.

kou commented 5 years ago

OK. I'll close this.