New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-l10n-gettext

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-l10n-gettext

A hapijs plug-in for l10n via gettext

  • 0.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

hapi-l10n-gettext

A localization plug-in for HapiJS

NPM

Build Status Dependency Status

Installation:

npm i hapi-l10n-gettext

Plug-in options and setup:

// 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);
    });
});

Localization methods provided to JS code

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
}

Localization methods provided to view templates

(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.

Contributors

Here's a list, thanks for your help!

Keywords

FAQs

Package last updated on 08 Jan 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc