wl.js
v2.1.2
Published
Javascript library for swapping languages
Downloads
9
Readme
Table of Contents
Installation
With node package manager:
npm i wl.js@latest # or your preferred package manager
With a script tag:
<script src="https://unpkg.com/wl.js"></script>
With pain (self-hosting):
- Download the source code from wrong-lang/wl.js
- Build the source code with the following command:
npm run build # or your preferred package manager
- Include the built file in your HTML:
<script src="index.min.js"></script>
- Have fun!
Language Swap
// File: ./examples/languageSwap.js
import { WrongLang } from "wl.js";
const wrongLang = new WrongLang();
const output = wrongLang.languageSwap({
layout: {
primary: "Kedmanee", // Default: Kedmanee
secondary: "Qwerty", // Default: Qwerty
},
text: "l;ylfu8iy[",
});
console.log(output); // "สวัสดีครับ"
Unshift
// File: ./examples/unshift.js
import { WrongLang } from "wl.js";
const wrongLang = new WrongLang();
let output = wrongLang.unshift({
layout: "Kedmanee",
text: "ศซํศโ๊๕ณํฐ(ุ็๙ฒ",
});
console.log(output); // "สวัสดีครับผู้ชม"
output = wrongLang.unshift({
layout: "Qwerty",
text: "hELLO EVERYNYAN. hOW ARE YOU? fINE, SANKYUU.",
realShift: false, // Default: true
});
console.log(output); // "Hello everynyan. How are you? Fine, sankyuu."
Custom Layouts
// File: ./examples/customLayout.js
import { WrongLang } from "wl.js";
const wrongLang = new WrongLang();
wrongLang.addCustomLayout({
customLayout: {
name: "Morse",
keys: {
normal:
".- |-... |-.-. |-.. |. |..-. |--. |.... |.. |.--- |-.- |.-.. |-- |-. |--- |.--. |--.- |.-. |... |- |..- |...- |.-- |-..- |-.-- |--.. |/ ".split(
"|",
),
shift:
".- |-... |-.-. |-.. |. |..-. |--. |.... |.. |.--- |-.- |.-.. |-- |-. |--- |.--. |--.- |.-. |... |- |.-- |...- |.-- |-..- |-.-- |--.. |/ ".split(
"|",
),
},
},
defineKeyLength: 54,
});
wrongLang.addCustomLayout({
customLayout: {
name: "Alphabet",
keys: {
normal: "abcdefghijklmnopqrstuvwxyz ".split(""),
shift: "abcdefghijklmnopqrstuvwxyz ".toUpperCase().split(""),
},
},
defineKeyLength: 54,
});
const output = wrongLang.languageSwap({
layout: {
primary: "Alphabet",
secondary: "Morse",
},
text: "Hello World",
});
console.log(output); // ".... . -.-- -.-- --- / .-- --- .-. -.-- -.."