32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
/**
|
|
{
|
|
"api":1,
|
|
"name":"to English",
|
|
"description":"I accidently typed English Qwerty text on Thai Kedmanee keyboard",
|
|
"author":"Tang Mo",
|
|
"icon":"translation",
|
|
"tags":"english,ำืเสรห้,เสรห้"
|
|
}
|
|
**/
|
|
|
|
// 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 = kedmanee;
|
|
var dest = qwerty;
|
|
|
|
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...")
|
|
}
|
|
}
|