npm i next-i18next-typesafe@latest --save-dev
With yarn
yarn add next-i18next-typesafe@latest -D
import { defineConfig } from 'next-i18next-typesafe';
export default defineConfig({
input: 'public/locales/en/**/*.json',
output: 'src/i18n',
library: 'next-i18next' | 'react-i18next'
});
// Nextjs use next-i18next
// React use react-i18next
-p: Port
-w: Watch
-c: Config
{
...
"scripts": {
...
// development
"next-i18next-typesafe": "next-i18next-typesafe -w",
// OR
"next-i18next-typesafe-port": "next-i18next-typesafe -p 1234 -w",
},
...
}
- You can also use a custom config file instead of
i18n-typesafe.config.ts
. Just create<FILE_NAME>.config.ts
to build command
Exp: awesome.config.ts
{
...
"scripts": {
...
// development
"next-i18next-typesafe": "next-i18next-typesafe -w -c awesome",
// OR
"next-i18next-typesafe-port": "next-i18next-typesafe -p 1234 -w -c awesome",
},
...
}
npm run next-i18next-typesafe