https://github.com/namesmt/unplugin-sheet-i18n
https://github.com/namesmt/unplugin-sheet-i18n
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/namesmt/unplugin-sheet-i18n
- Owner: NamesMT
- License: mit
- Created: 2023-11-23T08:08:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-19T05:47:12.000Z (over 1 year ago)
- Last Synced: 2024-10-20T11:09:56.147Z (over 1 year ago)
- Language: TypeScript
- Size: 360 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# unplugin-sheet-i18n 
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Codecov][codecov-src]][codecov-href]
[![Bundlejs][bundlejs-src]][bundlejs-href]
[![jsDocs.io][jsDocs-src]][jsDocs-href]
**unplugin-sheet-i18n** enables doing your i18n in a [spread]sheet for a better collaborative experience with non-coders and maintainability.
## Features
- Supports CSV, TSV, DSV, Excel/Spreadsheets (XLS[XMB], ODT), powered by [SheetJS](https://sheetjs.com/) and [papaparse](https://www.papaparse.com/)
- File-to-file convert: `en.csv -> en.json`
- File-to-multiple convert: `i18n.csv -> en.json, vi.json, fr.json,...`
- Output merging: `i18n_a.csv + i18n_b.csv -> en.json`
- Preserve structure: `a/i18n.csv -> a/en.json | a/i18n/en.json | a/i18n_en.json`
- File generation: `i18n_files.csv -> cloud_en.json, cloud_fr.json, template_en.html, template_fr.html`
- And more!
## Usage
[>See a few examples usage here<](./playground)
### Install package:
```sh
# npm
npm install unplugin-sheet-i18n
# yarn
yarn add unplugin-sheet-i18n
# pnpm (recommended)
pnpm install unplugin-sheet-i18n
```
### Setup:
Vite
```ts
// vite.config.ts
import SheetI18n from 'unplugin-sheet-i18n/vite'
export default defineConfig({
plugins: [
SheetI18n({ /* options */ }),
],
})
```
Rollup
```ts
// rollup.config.js
import SheetI18n from 'unplugin-sheet-i18n/rollup'
export default {
plugins: [
SheetI18n({ /* options */ }),
],
}
```
Webpack
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-sheet-i18n/webpack')({ /* options */ })
]
}
```
Nuxt
```ts
// nuxt.config.js
export default defineNuxtConfig({
modules: [
['unplugin-sheet-i18n/nuxt', { /* options */ }],
],
})
```
> This module works for both Nuxt 2 and [Nuxt Vite](https://github.com/nuxt/vite)
Vue CLI
```ts
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-sheet-i18n/webpack')({ /* options */ }),
],
},
}
```
esbuild
```ts
// esbuild.config.js
import { build } from 'esbuild'
import SheetI18n from 'unplugin-sheet-i18n/esbuild'
build({
plugins: [SheetI18n()],
})
```
unbuild
```ts
// build.config.ts
import { defineBuildConfig } from 'unbuild'
import SheetI18n from 'unplugin-sheet-i18n/rollup'
export default defineBuildConfig({
hooks: {
'rollup:options': function (ctx, options) {
options.plugins = [options.plugins, SheetI18n({
})]
},
},
})
```
programmatic
See it in action [at `starter-fullstack`](https://github.com/NamesMT/starter-fullstack/blob/main/packages/locales/index.ts)
```ts
// index.ts
import { createContext } from 'unplugin-sheet-i18n'
createContext({
outDir: 'dist',
}).scanConvert()
```
### Options:
[See Options](./src/types.ts)
## Roadmap
- [ ] Add example repos
- [ ] Add tests
## License
[MIT](./LICENSE) License © 2024 [NamesMT](https://github.com/NamesMT)
[npm-version-src]: https://img.shields.io/npm/v/unplugin-sheet-i18n?labelColor=18181B&color=F0DB4F
[npm-version-href]: https://npmjs.com/package/unplugin-sheet-i18n
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin-sheet-i18n?labelColor=18181B&color=F0DB4F
[npm-downloads-href]: https://npmjs.com/package/unplugin-sheet-i18n
[codecov-src]: https://img.shields.io/codecov/c/gh/namesmt/unplugin-sheet-i18n/main?labelColor=18181B&color=F0DB4F
[codecov-href]: https://codecov.io/gh/namesmt/unplugin-sheet-i18n
[license-src]: https://img.shields.io/github/license/namesmt/unplugin-sheet-i18n.svg?labelColor=18181B&color=F0DB4F
[license-href]: https://github.com/namesmt/unplugin-sheet-i18n/blob/main/LICENSE
[bundlejs-src]: https://img.shields.io/bundlejs/size/unplugin-sheet-i18n?labelColor=18181B&color=F0DB4F
[bundlejs-href]: https://bundlejs.com/?q=unplugin-sheet-i18n
[jsDocs-src]: https://img.shields.io/badge/Check_out-jsDocs.io---?labelColor=18181B&color=F0DB4F
[jsDocs-href]: https://www.jsdocs.io/package/unplugin-sheet-i18n