angular-gettext
angular-gettext copied to clipboard
fix(Plural): A logic bug in plural
Guys, I found a plural bug when I was developing with your library.
In your original code there is a line:
prefixDebug(n === 1 ? string : stringPlural);
That means the 'n' must be a Number rather than a String or something else.
But how did you get the 'n'? I found that you did something like this:
$parse(attrs.translateN)(scope)
That means if the translateN on attrs is a String, the 'n' will be String as well. Then you will never get a right plural result when the count changing.
So I just made the change to ensure the logic is safe.
And I think maybe it also fixed the issue https://github.com/rubenv/angular-gettext/issues/305 and the similar other ones.
@abruzzihraig I'm pretty sure that functionality works. Nonetheless, if we want to get this in, you'll need to add a unit test, which fails without the fix applied.
So if you pretty sure that functionality works, why I can get this:
I was totally followed by the developer guide.
On Wed, Sep 21, 2016 at 18:25 Ruben Vermeersch [email protected] wrote:
@abruzzihraig https://github.com/abruzzihraig I'm pretty sure that functionality works. Nonetheless, if we want to get this in, you'll need to add a unit test, which fails without the fix applied.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rubenv/angular-gettext/pull/313#issuecomment-248544761, or mute the thread https://github.com/notifications/unsubscribe-auth/ADM3a0qMohq_oMoDaNyyr5dBIeCF3Vtcks5qsOnwgaJpZM4KCgYo .
Yang He
Note that we have a test that tests exactly this: https://github.com/rubenv/angular-gettext/blob/7d7ac672ad660eb3cba3366d76cb75cc4eef0979/test/unit/directive.js#L134-L143
@rubenv when input bind to something like activity.length as in #305, after the value changed, typeof activity.length would become string rather than number.
i think angular-gettext should handle this situation.
you can have a look at the page below https://gist.github.com/zhuangya/38476c504d29d39d8d2bfae5e11b5060
:)
also cc @sebrojas14
update: living demo on jsfiddle goes here: https://jsfiddle.net/hxv260y6/