skolmer / es2015-i18n-tag

ES2015 template literal tag for i18n and l10n (translation and internationalization)
http://i18n-tag.kolmer.net
MIT License
191 stars 13 forks source link

throwing Error if template literal with null placeholder #65

Closed nor3 closed 5 years ago

nor3 commented 5 years ago

current behavior

following code raise exception "Cannot read property 'toLocaleString' of undefined "

const mayNullOrUndefined = null;
i18n`${mayNullOrUndefined}`

https://codesandbox.io/s/priceless-tdd-4nw3z

expacted behavior

extract with "null" or "undefined" value for placeholder, which is normal template literal behavior. It may work for detect bug, but unexpected in case the variable may take null/undefined value.

workaround

i18n`${mayNullOrUndefined || ""}`

I hate this...

skolmer commented 5 years ago

sure, we all hate undefined ;) I will accept pull requests on this topic.

skolmer commented 5 years ago

thanks for your contribution. change is released in v1.6.1