Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale.GetND should return singular default when N=1 #34

Closed
alexedwards opened this issue Oct 20, 2019 · 2 comments
Closed

Locale.GetND should return singular default when N=1 #34

alexedwards opened this issue Oct 20, 2019 · 2 comments
Assignees

Comments

@alexedwards
Copy link

alexedwards commented Oct 20, 2019

I'm very new to this package, so sorry if I'm misunderstanding something!

But it seems like the GetND and GetNDC methods in locale.go only return the plural default, not the singular when N=1.

I had quick look through the issues, and it looks like the same problem in the po.go file was fixed in #8, but the corresponding methods in locale.go weren't fixed at the same time.

@leonelquinteros leonelquinteros self-assigned this Oct 21, 2019
@leonelquinteros
Copy link
Owner

@alexedwards I've been looking into this issue, and while it's a bug, the solution is more complex than just N=1.

What's happening here is that the Locale object you're using doesn't have the Domain (Po object) you're requesting loaded, so it defaulted to the plural.
That said, the current implementation was using the n == 1 rule to identify singular cases, and that's kind of incorrect, because it would depend on the plurals definition from the .po file.

So I'm working on a solution in the Po object that will fallback to the corresponding default value based on the plural forms definitions in the .po file.
When it fallbacks to an non-existing translation string, but on an existing domain (.po file) it will use this new approach.
Otherwise, as if the domain isn't loaded and it doesn't knows how plural definitions are, it will fallback using the western n == 1 rule, just to make a convention here.

I'll be pushing a fix to master branch soon.

@alexedwards
Copy link
Author

Thanks for the time looking into this and the fast fix. I really appreciate it 👍

Dexus pushed a commit to Dexus-Forks/gotext that referenced this issue Dec 7, 2019
…lable. Use western rule n==1 convention only on Locale object without Domain. Fixes leonelquinteros#34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants