lingascript-cn
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

LingaScript-cn

LingaScript-cn 是支持简体中文关键字的 TypeScript 编译器。语法衍生自 TypeScript (和 Javascript)。

LingaScript-cn 可以将以简体中文撰写的脚本编译成 Javascript,可在任意支持Javascript的环境中执行。

欢迎探索非英语编程语言 的朋友一同参与,我们可以通过改进共用的核心,來提供更好用的非英语编程语言工具。具体请查看LingaScript源码库

Non-english programming adventurers can easily add your local language, work together to improve the same core, and get benifit for the shared programming tools with better local language support. Check out the LingaScript repo.

支持的本地语言

LingaScript-cn 支持简体中文与英文关键字(Keywords),要支持別的语言需分別安裝不同套件。

使用说明

可使用npm命令安裝 LingaScript:

npm install -g lingascript-cn

安裝后可得到tsc命令. (和TypeScript相同)

建立测试.ts文件如下

变量 一切 = 假的;

或加上 TypeScript 声明

变量 一切:真假 = 假的;

然后使用以下命令编译

tsc 测试.ts

则会输出测试.js

var 一切 = false;

LingaScript 支持所有 TypeScript 编译器的命令,所以也可以用如下指令

tsc examples/cn/src/测试.ts --outFile test.js

测试.ts输出成test.js

To show with locale diagnostic messages, pass the --locale [lang] param in tsc, ex: 要显示中文的错误信息,可以在运行tsc命令时加上--locale zh-tw参数, 如:

tsc --locale zh-cn test.ts

更多范例可参考 https://github.com/gasolin/lingascript/tree/master/examples/cn .

本地安裝 (而非全局安裝)

先创建源码文件夹,并安裝 lingascript-cn

$ mkdir demo && cd demo && npm init
$ npm install lingascript-cn

编辑package.json加入以下设置,并更新 lingascript-cn 版本号

"scripts"{
  "compile": "./node_modules/lingascript-cn/bin/tsc 测试.ts"
},
"devDependencies"{
  "lingascript-cn": "^0.2.0",
},

即可在源码中使用中文关键字开发程序,使用npm run compile进行编译。

版本历程

查看 https://github.com/gasolin/lingascript/blob/master/CHANGELOG.md

授权

Apache-2.0 License

Package Sidebar

Install

npm i lingascript-cn

Weekly Downloads

1

Version

0.3.0

License

Apache-2.0

Unpacked Size

43.1 MB

Total Files

78

Last publish

Collaborators

  • gasolin