Skip to content
Multilingual Javascript (support non-English languages), based on Typescript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE
examples
scripts
src
tests
typescript @ b145eaf
.gitignore
.gitmodules
CHANGELOG.md
LICENSE
README.md
package.json

README.md

LingaScript

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.

Current Support Languages

You can find available built version with lingascript-[lang] in npm.

Usage

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] .

Build

$ 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/**/*"
  ]
}

Develop

LingaScript use file-patch to patch TypeScript's compiler.

Check TypeScript Build Instruction for more detail about building TypeScript.

Normal Validation phase

The npm run build:cn will do

  1. patch clean TypeScript with .diff files in src/. The related scripts are stored in scripts/ folder.

  2. npm run build will be used to build the patched TypeScript

  3. Run npm run test:cn to make sure the built tool works.

Test different languages

For example, to test Traditional Chinese, you can run commands:

$ npm run clean
$ npm run build:tw
$ npm run test:tw

Rebuild from a clean typescript/ folder

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.

Debugging phase

  1. 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].

  2. 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.

  1. To generate .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.

Upgrade TypeScript Version

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

Build faster

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/).

Changelog

Check CHANGELOG for more detail.

License

Apache-2.0 License

Credit

LingaScript is inspired by zhpy(周蟒) and CTS

You can’t perform that action at this time.