Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hunghg255/next-i18next-typesafe
next-i18next typesafe
https://github.com/hunghg255/next-i18next-typesafe
i18n npm type-safe
Last synced: 2 months ago
JSON representation
next-i18next typesafe
- Host: GitHub
- URL: https://github.com/hunghg255/next-i18next-typesafe
- Owner: hunghg255
- License: mit
- Created: 2023-06-05T10:16:25.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-03T11:46:28.000Z (9 months ago)
- Last Synced: 2024-05-03T15:45:30.773Z (9 months ago)
- Topics: i18n, npm, type-safe
- Language: TypeScript
- Homepage:
- Size: 70.3 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# i18next typesafe
[![npm version](https://badge.fury.io/js/next-i18next-typesafe.svg)](https://badge.fury.io/js/next-i18next-typesafe) [![npm](https://img.shields.io/npm/dw/next-i18next-typesafe.svg?logo=npm)](https://www.npmjs.com/package/next-i18next-typesafe) [![npm](https://img.shields.io/bundlephobia/minzip/next-i18next-typesafe)](https://www.npmjs.com/package/next-i18next-typesafe)
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)## Demo
[i18next Typesafe Demo](https://github.com/hunghg255/next-i18next-typesafe-demo)## Install
```bash
npm i next-i18next-typesafe@latest --save-dev
```With `yarn`
```bash
yarn add next-i18next-typesafe@latest -D
```## Setup
### Create file: `i18n-typesafe.config.ts` or `i18n-typesafe.config.mjs` or `i18n-typesafe.config.js`
```js
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
```## CLI (file package.json)
```
-p: Port
-w: Watch
-c: Config
``````json
{
...
"scripts": {
...
// development
"next-i18next-typesafe": "next-i18next-typesafe -w",
// OR
"next-i18next-typesafe-port": "next-i18next-typesafe -p 1234 -w",
},
...
}
```### Custom config file
- You can also use a custom config file instead of `i18n-typesafe.config.ts`. Just create `.config.ts` to build command
```js
Exp: awesome.config.ts
``````json
{
...
"scripts": {
...
// development
"next-i18next-typesafe": "next-i18next-typesafe -w -c awesome",
// OR
"next-i18next-typesafe-port": "next-i18next-typesafe -p 1234 -w -c awesome",
},
...
}
```## Compile
```bash
npm run next-i18next-typesafe
```# Demo
![demo](https://res.cloudinary.com/hunghg255/image/upload/v1685974466/i18n-typesafe_qjxibu.png)