This project is in early alpha stage, please use it at your own risk
LingaScript is the TypeScript with multilingal support, which enable users to write code with non-English languages.
Basically LingaScript is derived from TypeScript (and Javascript). LingaScript can be compiled to Javascript and be used across the Javascript ecosystem.
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.
You can find available built version with lingascript-[lang] in npm.
- English (en, derived from TypeScript, Package: Typescript
)
- 简体中文 (Simplified Chinese, cn, 支援的关键字, 套件: lingascript-cn
)
- 正體中文 (Traditional Chinese, tw, 支援的關鍵字, 套件: lingascript-tw
)
Install LingaScript via command
npm install -g lingascript-[lang]
Then you get the tsc
command. (same as TypeScript
)
Create test.ts
file.
let isDone = false
or you can use TypeScript-style type check format:
let isDone:boolean = false
Then run command
tsc test.ts
to compile and get output test.js
let isDone = false
To show with locale diagnostic messages, pass the --locale [lang]
param in tsc
, ex:
tsc --locale zh-cn test.ts
More [native language] code examples in https://github.com/gasolin/lingascript/tree/master/examples/[lang] .
$ git clone https://github.com/gasolin/lingascript.git
$ cd lingascript
$ npm install -g jake
$ npm install
$ npm run build:cn
build:cn
will build for Simplified Chinese support and build:tw
will build for Traditional Chinese support.
Once build is complete, you can run command node /built/local/tsc.js
to compile source code in examples/cn with simplified chinese.
node typescript/built/local/tsc.js -p examples/cn
The example comes from TypeScript's Basic types tutorial.
You can config the tsconfig.json file for different output target (es5, es6, es2018...).
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es6",
"diagnostics": true,
"locale": "zh-CN"
},
"include": [
"./src/**/*"
]
}
LingaScript use file-patch
to patch TypeScript's compiler.
Check TypeScript Build Instruction for more detail about building TypeScript.
The npm run build:cn
will do
-
patch clean TypeScript with .diff files in src/. The related scripts are stored in scripts/ folder.
-
npm run build
will be used to build the patched TypeScript -
Run
npm run test:cn
to make sure the built tool works.
For example, to test Traditional Chinese, you can run commands:
$ npm run clean
$ npm run build:tw
$ npm run test:tw
You need to remove TypeScript for a clean patch. To re-build from the clean TypeScript, you can run
$ npm run clean
$ npm run build:cn
check the clean
and build:cn
script package.json
's scripts
section for the execute detail.
-
You can disable patch process by removing the
prebuild
script inpackage.json
'sscripts
section. If you plan to change default keywords, removecp src/[lang]/language.ts typescript/src/compiler/language.ts &&
from thebuild:[lang]
script inpackage.json
'sscripts
section to avoid overwrite fromsrc/[lang]
. -
Follow Normal Validation phase, if the modifications works, we can backup the modified files from
typescript/src
tosrc/
via
npm run backup
Edit scripts/backup.sh to include the new modified files.
- To generate
.diff
files, compare the backup-ed modified files with the cleantypescript/src
folder via
npm run diff
Edit scripts/diff.sh to include the new modified files.
To upgrade the TypeScript's version (to v3.4.0 for example):
$ npm run upgrade-ts
$ cd typescript
$ git checkout v3.4.0
$ cd ..
$ git add typescript
The TypeScript version follows https://github.com/Microsoft/TypeScript/releases
Modify the build:ts
script in package.json
's scripts
section. Replace jake LKG
(replace lib/ with last known good build) to jake local
(for local build, not replaced lib/).
Check CHANGELOG for more detail.
Apache-2.0 License