3.0.1 • Published 8 months ago

elysia-i18next v3.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Elysia i18next test status

I18n for Elysia.js via i18next.

Install

bun add elysia-i18next i18next

Usage

Check out full samples at examples or check out the tests tests.

import { Elysia } from "elysia";
import { i18next } from "elysia-i18next";

new Elysia()
  .use(
    i18next({
      initOptions: {
        lng: "nl",
        resources: {
          en: {
            translation: {
              greeting: "Hi",
            },
          },
          nl: {
            translation: {
              greeting: "Hallo",
            },
          },
        },
      },
    }),
  )
  .get("/", ({ t }) => t("greeting")) // returns "Hallo"
  .listen(3000);

Configuration

initOptions

i18next.InitOptions

Default: {}

Check out the i18next documentation for more information.

detectLanguage

LanguageDetector

default:

newLanguageDetector({
  searchParamName: 'lang',
  storeParamName: 'language',
  headerName: 'accept-language',
  cookieName: 'lang',
  pathParamName: 'lang',
})

A language detection function based on the current request context. By default, it checks the language property on the store, lang param in the query string, a cookie named lang, a path parameter named lang or the accept-language header.

instance

null | i18next.i18n

Default: null

An existing i18next instance. If not provided, the global (module level) i18next instance will be used. The instance will be initialized if it not already was initialized.

3.0.1

8 months ago

3.0.0

8 months ago

2.2.0

8 months ago

2.1.1

8 months ago

2.1.0

8 months ago

2.0.0

8 months ago

2.0.0-pre.1

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago