-
Notifications
You must be signed in to change notification settings - Fork 154
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
Improve fallback #236
Improve fallback #236
Conversation
Pretty much what I had in mind! One more needed change: it needs to use the fallback language in |
And with that in mind, it's probably better to name it As in "Dutch is the base language for Dutch (Netherlands)". :-) |
Some notes about the changes:
|
Closes rubenv#210
- baseLanguage is private because it conflicts with catalog's attribute with the same name - plural detection is pretty hardcoded, there's no clear way to know if plural is defined or not
43e1c9f
to
3fdb714
Compare
+1 please merge :) |
Had a quick look at this (thanks for the ping @rubenswieringa). One way to make this cleaner is to add an extra function getStringForm: function (string, n, context) {
return this.getStringFormFor(this.currentLanguage, string, n, context) ||
this.getStringFormFor(this.baseLanguage(), string, n, context);
} The call to This would reduce the need to hardcode A fallback here would amount to: // pt_BR Brazilian Portuguese nplurals=2; plural=(n > 1);
// pt Portuguese nplurals=2; plural=(n != 1);
// Assuming n = 0
return this.getStringFormFor("pt_BR", string, n, context) || // gettextPlurals("pt_BR", n) -> 0
this.getStringFormFor("pt", string, n, context); // gettextPlurals("pt", n) -> 1 Does that make sense? |
@rubenv I'm looking into it, if I manage to come up with anything I'll open up a new PR. |
@rubenv are you sure we can move that function-call from When Are my assumptions correct? |
I was implying that we should change this behavior, but since Either way: any value of |
So I suppose |
Well, I don't think |
Alright, so do you want to completely get rid of |
We can always add it back if people complain, but given the way fallback support works, it probably doesn't even make sense to have a method that behaves like the current It'll be slightly annoying for the few people that depend on it, but we'll be saving them from pluralization bugs in Portuguese :-) |
…ew function Removes getStringForm(). See discussion here: rubenv#236 (comment)
New PR: #250 |
Cool, let's close this one. |
Closes #210
@rubenv Let me know if I should add more tests. The implementation is pretty straightforward.