jeresig / i18n-node-2

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
507 stars 79 forks source link

Check whether entry exists #103

Open iStooge opened 7 years ago

iStooge commented 7 years ago

Is there a way to check whether an entry is existing?

I am using i18n for a Chatbots natural language classification. When a certain case can not be handled with the saved i18n statements I want either to check wether it exists or return a default statement.

Just like this: i18n.__('i18n_statement_missing', {default: 'default.statement'})

or like this:

if !i18n.__('i18n_statement_missing').exists ...

gjuchault commented 7 years ago

I guess you can use something like if (typeof i18n.__('i18n_statement_missing') !== 'string')