From 1715d3538c21108c61cf82774c543c44cf69e56c Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 24 Jan 2024 21:27:06 +0000 Subject: [PATCH] =?UTF-8?q?de=3D=E0=B8=81=E0=B8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- toEnglish.js | 31 +++++++++++++++++++++++++++++++ toThai.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 toEnglish.js create mode 100644 toThai.js diff --git a/toEnglish.js b/toEnglish.js new file mode 100644 index 0000000..a5736bb --- /dev/null +++ b/toEnglish.js @@ -0,0 +1,31 @@ +/** + { + "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...") + } +} diff --git a/toThai.js b/toThai.js new file mode 100644 index 0000000..dfd53fb --- /dev/null +++ b/toThai.js @@ -0,0 +1,31 @@ +/** + { + "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...") + } +}