@isekaimaouyoki-sama/fastify-i18njs
v1.0.0
Published
The wrapper for i18n-js being used in fastify framework
Downloads
10
Maintainers
Readme
@isekaimaouyoki-sama/fastify-i18njs
This is a small wrapper around i18n-js.
Install
npm install --save @isekaimaouyoki-sama/fastify-i18njs
Usage
Easy to use require/import this plugin as below
const path = require('path')
const fastify = require('fastify')()
fastify.register(
require('@isekaimaouyoki-sama/fastify-i18njs'),
{
locale: 'vi',
supportedLocales: ['en', 'de', 'vi'],
messages: {
de: require(path.join(__dirname, 'locales', 'de.js')),
en: require(path.join(__dirname, 'locales', 'en.js')),
vi: require(path.join(__dirname, 'locales', 'vi.js'))
}
}
)
fastify.get("/", async function(request, reply) {
reply.send(fastify.i18n.t('<....>'))
})
fastify.listen({ port: 3000 }, err => {
if (err) throw err
})