Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
hapi-l10n-gettext
Advanced tools
A localization plug-in for HapiJS
npm i hapi-l10n-gettext
// register as you would any other hapi plug-in
server.pack.register([
// additional plug-ins here
{
plugin: require('hapi-l10n-gettext'),
options: {
// the name of the cookie this plug-in will set to store locale
cookieName: '_locale',
// optional: where your PO/MO files live, if no filesa are found, a debugging
// "test" locale will be used.
l10nDirectory: path.resolve(__dirname, 'locales'),
// optional (default 'en') - language used when neither the cookie nor the
// accept-language header are present
defaultLocale: 'en',
// optional: routes to exclude from localization
excludedRoutes: [assetRoute],
// optional: routes to include in localization
includedRoutes: appRoutes
}
}
], function (err) {
if (err) throw err;
server.start(function () {
server.log('info', 'Server running at: ' + server.info.uri);
});
});
request.l10n = {
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
}
(Added to response.source.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
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
There's also an example app to get more of an idea how to use this plug-in.
FAQs
A hapijs plug-in for l10n via gettext
The npm package hapi-l10n-gettext receives a total of 9 weekly downloads. As such, hapi-l10n-gettext popularity was classified as not popular.
We found that hapi-l10n-gettext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.