32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
/**
|
|
{
|
|
"api":1,
|
|
"name":"to Thai",
|
|
"description":"I accidently typed Thai Kedmanee text on Qwerty keyboard",
|
|
"author":"Tang Mo",
|
|
"icon":"translation",
|
|
"tags":"thai,ะ"
|
|
}
|
|
**/
|
|
|
|
// https://github.com/wrong-lang/spark/blob/main/src/layout.ahk
|
|
var kedmanee = 'ๅ/-ภถุึคตจขชๆไำพะัีรนยบลฃฟหกดเ้่าสวงผปแอิืทมใฝ+๑๒๓๔ู฿๕๖๗๘๙๐"ฎฑธํ๊ณฯญฐ,ฅฤฆฏโฌ็๋ษศซ.()ฉฮฺ์?ฒฬฦ';
|
|
var qwerty = `1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?`;
|
|
|
|
// Qwerty to Kedmanee
|
|
var source = qwerty;
|
|
var dest = kedmanee;
|
|
|
|
function main(state) {
|
|
try {
|
|
const charMap = new Map();
|
|
for (let i = 0; i < source.length; i++) {
|
|
charMap.set(source[i], dest[i]);
|
|
}
|
|
state.text = state.text.split('').map(char => charMap.get(char) || char).join('');
|
|
}
|
|
catch(error) {
|
|
state.postError("Something strange happened here...")
|
|
}
|
|
}
|