0.1.0 • Published 5 years ago

@huohua/huohua-plugin-locale v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

huohua-plugin-locale

火花插件 国际化组件

Build Status NPM version Downloads Standard Version styled with prettier Conventional Commits


✨ Features

插件国际化分两个部分

  • 软件界面国际化, 所有插件的界面文字需要在 /lang/zh-cn.json 文件中,打包时需要一并打入 dist 根目录. 在代码读取 zh-cn.json 时需要调用 Locale 组件 来获取正确的 json 语言包

    const uiDir = 'D:\\widget\\lang\\'
    // D:\\widget\\lang\\zh-cn.json
    const uiJson = Locale.getUIConfigPath(uiDir)
  • 插件生成的 json 数据国际化,插件生成的数据文件与界面国际化定义规则不同,插件生成默认命名规则时/xxx.json, 国际化时需要在文件名上追加编码 如 /xxx_en-US.json ,如果编码是 zh-cn 则默认会省略

    const path = 'D:\\widget\\data.json'
    // D:\\widget\\data_en-US.json
    const actual = Locale.getContentDataPath(path)

🔧 Installation

yarn add @huohua/huohua-plugin-locale

🎓 Guides

  • 生成的语言编码均为小写
  • 默认语言为 zh-cn, 各个插件需要判断文件是否存在

🥂 License

MIT as always