i18n-lookup
Utility node module for doing lookups from translation documents
Install
npm install [--save] i18n-lookup
Usage
A lookup function is returned by passing in the translation method as an argument. We normally use i18next.
/**Locale: { another: { translation: { key: 'Text' } }}**/var t = t; var lookup = t; var translated = ; console;// This will output the first key which has a corresponding translation defined.// => "Text"
Additionally, a template compilation method can be provided for cases where the translated key also includes template syntax.
/**Locale: { greeting: 'Hello {{name}}'}**/var t = t Mustache = ; var lookup = t Mustacherender; var translated = ; console;// This will output the returned lookup compiled with the provided context// "Hello John"