hapi-l10n-gettext
A localization plug-in for HapiJS
Installation:
npm i hapi-l10n-gettext
Plug-in options and setup:
// register as you would any other hapi plug-inserverpack;
Localization methods provided to JS code
requestl10n = gettext // get a bit of text pgettex // get text within a context ngettext // get singular or plural text npgettext // get singular or plural text within a context // An array of locales found in the parsed PO/MO files locales: locale: 'en' name: 'English' selected: true selectedLocale: locale: 'en' name: 'English' selected: true // the currently selected locale // whether or not PO/MO files were found devMode: false
Localization methods provided to view templates
(Added to response.source.context)
// An array of locales found in the parsed PO/MO fileslocales: locale: 'en' name: 'English' selected: trueselectedLocale: locale: 'en' name: 'English' selected: true // the currently selected localegettext // get a bit of textpgettex // get text within a contextngettext // get singular or plural textnpgettext // get singular or plural text within a context
There's also an example app to get more of an idea how to use this plug-in.