Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    connect-moment-i18npublic

    connect-moment-i18n

    Creates a localized moment instance for connect/express

    Installation

    npm install connect-moment-i18n

    Usage

    Initialize the middleware with:

    var express = require('express'),
        connectMomentI18n = require('connect-moment-i18n'),
        app = express();
     
    app.use(connectMomentI18n());

    By default, the middleware creates a localized moment instance set to the language locale specified at req.locale and attaches it to req.moment. You may pass an options hash, described below, to the constructor in order to alter the middleware's behavior.

    Options

    localeKey

    Specifies the key on the request object the locale can be found. Defaults to locale.

    momentKey

    Specifies the key on the request object at which the localized moment will be attached. Defaults to moment.

    defaultLocale

    Specifies the default locale to fallback to if a request does not include a value at localeKey. Defaults to en.

    setDefaultLocale

    When true, this will set the global default moment language (e.g.: moment.lang('en');) on instantiation. If false, moment will set the global language after the first server request which is likely unintended behavior. Defaults to true which is highly recommended.

    Keywords

    none

    install

    npm i connect-moment-i18n

    Downloadsweekly downloads

    481

    version

    0.2.0

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar