Skip to content

💖 Javascript Library for Swapping Languages with Custom Layouts

License

Notifications You must be signed in to change notification settings

wrong-lang/wl.js

Repository files navigation

WrongLang.js (wl.js)

Javascript library for swapping languages when you forgor 💀 ...and faster than ever! (Faster than G;ode.js 40%)

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):

  1. Download the source code from wrong-lang/wl.js
  2. Build the source code with the following command:
npm run build # or your preferred package manager
  1. Include the built file in your HTML:
<script src="index.min.js"></script>
  1. 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); // ".... . -.-- -.-- --- / .-- --- .-. -.-- -.."