adaltas / node-http-status

Utility to interact with HTTP status code in Node.js
Other
435 stars 55 forks source link

intl #32

Open shunkongcheung opened 5 years ago

shunkongcheung commented 5 years ago

Any plan on supporting multi-language? Thanks

wdavidw commented 5 years ago

The idea was never brought up but I am not against it. We've got english, I could handle the French and if you provide a 3rd language, that could be a good start.

Have you thought about the API. Currently, it is one large object literal with the "{code}_NAME" and "{code}_MESSAGE" properties. I am not sure "{code}_NAME" should and would be easy to translate, I consider them more as code than name. An easy way to handle this issue is to create an alternative "{code}_MESSAGE" property in the form of "{code}MESSAGE{lang}". An other way would be to expose a function which take the lang as argument and which contextualize the return object. The latter approach is dynamic and could provide more flexibility to handle locale with subcodes (eg: fr-CA) and default values.