-
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
Add translatePlural filter #122
base: master
Are you sure you want to change the base?
Conversation
Why not use Having two different syntaxes is really troublesome: it would given an error if you have this situation:
Not the mismatching values for the plural string. There's no way we can handle that. This cannot go in unless we find a way to make this work:
|
I just noticed that I made the mistake of putting it wrong in #104. Sorry for that. |
@@ -112,6 +112,16 @@ describe("Catalog", function () { | |||
assert.equal(catalog.getPlural(1, "There is {{count}} bird", "There are {{count}} birds", { count: 1 }), "There is 1 bird"); | |||
}); | |||
|
|||
it("Can return an interpolated plural string for special {} pattern", function () { | |||
assert.deepEqual(catalog.strings, {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to have this assertion.
Apart from the points above: excellent work! If we can fix the things above, I see no reason not to merge this. |
result in parse error. I think that's why |
Ok, that is a problem. Guess we'll have to take that constraint as a given. But it's not just an option to use a new interpolation syntax as-such. Consider the case where we opt to use
In combination with a different occurrence: <span translate translate-n="n" translate-plural="{{$count}} apples">1 apple</span> This would fail during message extraction since we have two different plural strings for
One option (and this might be crazy-talk) is to support
I'm inclined towards Something to think about. Adding @gabegorelick to CC, he might have input too. |
Yeah, |
We may want to do something like rubenv/angular-gettext-tools#63 (comment) instead. |
Nevermind. $compile parses {{}} inside string literals. |
Issue #104
This adds
translatePlural
filter with syntaxThis is a bit different with what @rubenv suggested
{}
instead of$count
. That's because the probability of collision of$count
is higher than{}
I think. Matching{}
is also much easier.