Convert word from one layout to another

15 views
Skip to first unread message

Amir Ghassemi Nasr

unread,
Jan 12, 2022, 4:54:52 AMJan 12
to persian-...@googlegroups.com
Hi everybody,

This is not about Persian writing in particular, but about keyboard
mapping. Since I know here a few people who had contributed to keyboard
mappings, I ask my questions here, sorry for the off-topic :)

I am interested in converting a word written, inadvertently, in one
language to another one. Let's say I wanted to write "Linux", but my
keyboard layout was ir_IR, i.e. ISIRI-2901, and I got "«هدعط"; I want to
convert that garbage to "Linux".

My questions:

1. At first, I thought my best bet is to use XKB tools/libraries as
it seemed to me there are more standardized. I learned `xkbcomp` [1] can
convert between two file formats, .xkm and .xkb, but couldn't find any
such file in my Linux installation. Do you know where they reside?


2. Then I went with Linux keymap files and kbd. It seems more
straightforward. I just wonder if there is any compiled or processed
form of mapping files ("/usr/share/keymaps/i386/qwerty/fa.map.gz") that
I could use in my program. I'm also curious if `dumpkeys` [2] can read
those files.


3. Last and least! Does any open-source tool exist that does what I
want to do? I know If I search "ذذز.زخپ" in Google, it shows "bbc.com"
for the first result and it is not in the website's meta, as far as I
can see. Is there any published software for this kind of translation?

Thanks for reading,
Amir

1: https://linux.die.net/man/1/xkbcomp
2: https://man7.org/linux/man-pages/man1/dumpkeys.1.html

Masoud Abkenar

unread,
Jan 12, 2022, 11:19:14 AMJan 12
to persian-...@googlegroups.com, Amir Ghassemi Nasr
Hello Amir, hello everyone,

About 10 years ago, I used to use a Firefox extension that did exactly
this (and I loved it :). Unfortunately, I don't remember its name. I know
that it existed before Firefox changed its extension framework/API, so it
might be that the extension doesn't work on current Firefox versions.

You can start by searching Firefox extension directory.

Best wishes,
Masoud Abkenar
https://masoud.abkenar.net


On January 12, 2022 10:54:47 AM GMT+01:00, Amir Ghassemi Nasr
>--
>--
>http://persian-computing.org/
>http://groups.google.com/group/persian-computing/
>
>---
>You received this message because you are subscribed to the Google Groups
"Persian Computing" group.
>To unsubscribe from this group and stop receiving emails from it, send an
email to persian-comput...@googlegroups.com.
>To view this discussion on the web visit
https://groups.google.com/d/msgid/persian-computing/2325da6e-87c2-04a1-b8b2-736ca627c671%40gmail.com
.

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Bersam Karbasion

unread,
Jan 12, 2022, 11:19:17 AMJan 12
to Amir Ghassemi Nasr, persian-...@googlegroups.com
Hi Amir,

There's one tool available in javascript that does what you need. Search for `switchKey` on the following page:

Cheers,
Bersam

--
--
http://persian-computing.org/
http://groups.google.com/group/persian-computing/

---
You received this message because you are subscribed to the Google Groups "Persian Computing" group.
To unsubscribe from this group and stop receiving emails from it, send an email to persian-comput...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/persian-computing/2325da6e-87c2-04a1-b8b2-736ca627c671%40gmail.com.


--
Bersam Karbasion
Resume: https://www.bersam.org

Behnam Esfahbod

unread,
Jan 14, 2022, 1:12:09 AMJan 14
to Amir Ghassemi Nasr, Persian Computing
Hi Amir,

Good questions!


Re 1)

Here's the upstream repository of the keyboard layouts for FreeDesktop.Org projects: <https://cgit.freedesktop.org/xkeyboard-config/tree/symbols> Specifically, here's the IR file, covering Persian, Kurdish and Avestan: <https://cgit.freedesktop.org/xkeyboard-config/tree/symbols/ir>

Another related resource is Unicode Consortium's CLDR which has a keyboard layout repository, although limited to the big corps: <https://unicode-org.github.io/cldr-staging/charts/latest/keyboards/layouts/index.html> Specifically, here's the file for ISIRI-2901 (!), as provided in Mac OS: <https://github.com/unicode-org/cldr/blob/main/keyboards/osx/fa-t-k0-osx-isiri.xml>

Re 2)

If I recall correctly, there are some libraries that can process (and digest) the xkeyboard-config spec files, providing you with "resolved" concrete layouts. They must be in related repos, but I can't recall any script names, or specific languages (C, Perl, Python, ...).

Re 3)

I believe Gboard does have similar functionalities (like suggesting a FA word if you type the same "key positions" under an EN layout); however I'm afraid most of the code for Gboard is probably closed-source. (If I'm wrong, everyone, please do share here a link to relevant parts of the source!)


Good luck!
-b



-- 
Behnam Esfahbod | بهنام اسفهبد | Q4880939 Q2064908 | behnam.es



Amir Ghassemi Nasr

unread,
Jan 16, 2022, 5:56:05 PMJan 16
to Persian Computing
On 1/14/22 9:41 AM, Behnam Esfahbod wrote:
> Re 1)
>
> Here's the upstream repository of the keyboard layouts for FreeDesktop.Org projects: <https://cgit.freedesktop.org/xkeyboard-config/tree/symbols> Specifically, here's the IR file, covering Persian, Kurdish and Avestan: <https://cgit.freedesktop.org/xkeyboard-config/tree/symbols/ir>
>
> Another related resource is Unicode Consortium's CLDR which has a keyboard layout repository, although limited to the big corps: <https://unicode-org.github.io/cldr-staging/charts/latest/keyboards/layouts/index.html> Specifically, here's the file for ISIRI-2901 (!), as provided in Mac OS: <https://github.com/unicode-org/cldr/blob/main/keyboards/osx/fa-t-k0-osx-isiri.xm

Thank you a lot Behnam. Those are pretty much what I was looking for!
Reply all
Reply to author
Forward
0 new messages