This package has been deprecated

Author message:

Moved to @os-team/i18next-express-middleware

@os-utils/i18next-express-middleware
TypeScript icon, indicating that this package has built-in type declarations

0.0.15 • Public • Published

@os-utils/i18next-express-middleware

Middleware for i18next and express to detect the language. Supports TypeScript.

Getting started

Installation

yarn add @os-utils/i18next-express-middleware

Also install cookie-parser if you need to detect the language from a cookie.

Usage Example

import express from 'express'
import cookieParser from 'cookie-parser'
import i18next from 'i18next'
import { i18nextMiddleware, LanguageDetector } from '@os-utils/i18next-express-middleware'

// Initialize i18next
i18next
  .use(LanguageDetector) // Pass the LanguageDetector middleware
  .init({
    fallbackLng: 'en',

    // Pass the custom options if necessary
    detection: {
      // In what order will the detectors be started
      order: ['cookie', 'header'], // default: ['header']
      
      // Keys used by the detectors
      cookie: 'custom-cookie', // default: i18next
      header: 'custom-header', // default: Accept-Language
    },
  })


const app = express()
app.use(cookieParser())
app.use(i18nextMiddleware(i18next))

Readme

Keywords

none

Package Sidebar

Install

npm i @os-utils/i18next-express-middleware

Weekly Downloads

1

Version

0.0.15

License

MIT

Unpacked Size

18 kB

Total Files

31

Last publish

Collaborators

  • oxilor