vscode-i18n
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

vscode-i18n

一个用于vscode插件的i18n简易方案,可以用于vscode环境和普通node环境

安装

npm install vscode-i18n --save

使用

const i18n = require('vscode-i18n')

初始化i18n目录和默认语言

i18n.Localize(i18nDirPath, defaultLanguage)

  • i18nDirPath 必选,i18n目录,默认为当前进程目录下的“i18n”文件夹
  • defaultLanguage 可选,默认语言,默认为“en”
  • 返回localize方法
const localize = i18n.Localize(path.join(__dirname, 'i18n'))

获取当前语言

i18n.locale

本地化字符串

localize(key)

localize('hello')

注意事项

  • 本地化文件仅支持json格式,文件名全小写,分隔符为“-”,例如:zh.json或zh-cn.json
  • 字符串查询返回优先级:语言全名(例如:zh-cn) -> 主语言(例如:zh) -> 默认语言(en) -> KEY

Readme

Keywords

Package Sidebar

Install

npm i vscode-i18n

Weekly Downloads

1

Version

0.2.0

License

ISC

Unpacked Size

7.43 kB

Total Files

6

Last publish

Collaborators

  • guoshengqiang