0.3.4 • Published 6 months ago

@types/express-simple-locale v0.3.4

Weekly downloads
1
License
MIT
Repository
github
Last release
6 months ago

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.

index.d.ts

// Type definitions for express-simple-locale 0.3
// Project: https://github.com/n26/express-simple-locale#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
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

  • Last updated: Thu, 08 Jul 2021 12:01:22 GMT
  • Dependencies: @types/express
  • Global values: none

Credits

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