tinganho / l10ns

Internationalization workflow and formatting
http://l10ns.org
Apache License 2.0
234 stars 24 forks source link

Cannot format value of 0 as currency #134

Closed laurie71 closed 8 years ago

laurie71 commented 8 years ago

Passing value: { amount: 0, code: '...' } into currency formatting results in an error, TypeError:valuemust be an object that has properties amount and code. The problem is that the amount property is checked for truthiness where the intent of the code was to check for presence: the check should be 'amount' in value instead of value.amount.

This is probably an easy fix, but a serious bug as 0 is a valid input and the result is a catastrophic error (app crash in my case). In my opinion a thrown error is an unacceptable outcome from a localization library; some reasonable fallback string should always come back from l(), or I have to wrap every localization site in a try-catch to preserve the integrity of my codebase...

tinganho commented 8 years ago

I just published a new verison l10ns@2.4.6 to fix this problem.