@types/express-simple-locale
TypeScript icon, indicating that this package has built-in type declarations

0.3.4 • Public • Published

Installation

npm install --save @types/express-simple-locale

Summary

This package contains type definitions for express-simple-locale (https://github.com/n26/express-simple-locale#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express-simple-locale.

import express = require("express");
import { RequestHandler } from "express";

declare module "express-serve-static-core" {
    interface Request {
        userLocale: locale.ShortLocale;
    }
}

/**
 * A simple Express middleware to guess the short-locale of a user.
 * It then saves the found locale on the request for further usage.
 */
declare function locale(options?: locale.Options): RequestHandler;

declare namespace locale {
    /**
     * @see {@link https://github.com/n26/express-simple-locale#options}
     */
    interface Options {
        /**
         * the key to save locale to on the request
         * @default 'locale'
         */
        key?: string | undefined;
        /**
         * available locales for the app
         * @default []
         */
        supportedLocales?: string[] | undefined;
        /**
         * locale to fallback to
         * @default 'en'
         */
        defaultLocale?: string | undefined;
        /**
         * cookie to try getting the locale from
         * @default 'locale'
         */
        cookieName?: string | undefined;
        /**
         * the query parameter(s) to look the locale from
         * @default ['locale']
         */
        queryParams?: string | string[] | undefined;
    }

    /** The short-locale of a user */
    type ShortLocale = string;
}

export = locale;

Additional Details

Credits

These definitions were written by Piotr Błażejewicz.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/express-simple-locale

Weekly Downloads

0

Version

0.3.4

License

MIT

Unpacked Size

5.63 kB

Total Files

5

Last publish

Collaborators

  • types