Skip to content

A ISO 639 language codes WebAssembly module.

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE
Notifications You must be signed in to change notification settings

yiwen-ai/isolang-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

isolang-wasm

A WebAssembly module with ISO 639 language codes base on https://github.com/humenda/isolang-rs

Usage

https://github.com/yiwen-ai/isolang-wasm/blob/main/example/app.js

To load an ES module, set "type": "module" in the package.json, then run node with --experimental-wasm-modules flag.

node --experimental-wasm-modules ./app.js

Run the example in node.js:

import assert from 'node:assert/strict';
import { ISOLang } from "isolang-wasm";

let all = ISOLang.all();
console.log(all);

let lang = ISOLang.from_str('zho');
console.log(lang.to_name());    // Chinese
console.log(lang.to_autonym()); // 中文
console.log(lang.to_639_3());   // zho

let lang2 = ISOLang.from_str(all[0]);
console.log(lang2.to_name());    // Afar
console.log(lang2.to_autonym()); // Qafar
console.log(lang2.to_639_3());   // aar

assert.equal(ISOLang.from_str("zh").to_name(), "Chinese");
assert.equal(ISOLang.from_str("Zho").to_name(), "Chinese");
assert.equal(ISOLang.from_str("Chinese").to_name(), "Chinese");
assert.equal(ISOLang.from_str("chinese").to_name(), "Chinese");
assert.equal(ISOLang.from_str("中文").to_name(), "Chinese");

Webpack-specific

https://rustwasm.github.io/docs/wasm-bindgen/examples/hello-world.html

About

A ISO 639 language codes WebAssembly module.

Topics

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE

Stars

Watchers

Forks

Packages

No packages published