Multilingual Javascript (support non-English languages), based on Typescript
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.
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 in package.json
‘s scripts
section. If you plan to change default keywords, remove cp src/[lang]/language.ts typescript/src/compiler/language.ts &&
from the build:[lang]
script in package.json
‘s scripts
section to avoid overwrite from src/[lang]
.
Follow Normal Validation phase, if the modifications works, we can backup the modified files from typescript/src
to src/
via
npm run backup
Edit scripts/backup.sh to include the new modified files.
.diff
files, compare the backup-ed modified files with the clean typescript/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