elysia-i18next
v4.0.3
Published
Internationalization (i18n) for Elysia.js via i18next
Downloads
1,328
Readme
Elysia i18next
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.