1.4.1 • Published 9 months ago

@fe9527/i18n-helper v1.4.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

i18n-helper

install

npm i @fe9527/i18n-helper -D

功能

i18nDownload

下载国际化平台的翻译文件

usage

创建一个 js 文件,参考下边的代码

import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { i18nDownload } from '@fe9527/i18n-helper'

const __filename = fileURLToPath(import.meta.url) // get the resolved path to the file
const __dirname = path.dirname(__filename) // get the name of the directory
const dirPath = path.join(__dirname, '../src/lang/json')
// 第一个参数为项目名称(在国际化平台中的名称),第二个参数为翻译文件存放路径
i18nDownload('star-ib', dirPath)

在 package.json 中添加一个 script,执行这个 js 文件

{
  "scripts": {
    "gen:i18n": "node ./scripts/i18n.mjs"
  }
}

data2Excel

通过传入的数据转换为 excel 文件

usage

创建一个 js 文件,参考下边的代码

import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { data2Excel, readModules } from '@fe9527/i18n-helper'

const __filename = fileURLToPath(import.meta.url) // get the resolved path to the file
const __dirname = path.dirname(__filename) // get the name of the directory
const dirPath = path.join(__dirname, '../src/lang/au')

readModules(dirPath).then((data) => {
  data2Excel(data)
})

在 package.json 中添加一个 script,执行这个 js 文件

{
  "scripts": {
    "gen:i18n-excel": "esno ./scripts/gen-i18n-excel.js"
  }
}

注意:readModules 读取的是js文件,且是通过 export default 导出的对象 如果是其他格式,请自行导入数据,只使用 data2Excel 进行转换

1.2.0

9 months ago

1.4.1

9 months ago

1.4.0

9 months ago

1.3.0

9 months ago

1.1.0

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago