Gujarati Transliteration
— Kaushal ModiYou can phonetically write a non-English language on an English keyword in Emacs, and that transforms into that non-English script. This is called transliteration, and I demonstrate that for the Gujarati language in this post.
This is a post in the “Gujarati in Emacs” series.
2022-06-27 | Gujarati Transliteration |
2022-06-19 | Gujarati fonts in Emacs |
Emacs provides the transliteration feature using the set-input-method command. I’ll introduce that and few related functions in this post to get to help get started with transliteration quickly.
Enabling transliteration #
Emacs uses the “input method” feature to do character conversion from
ASCII to the target language or script. The “input method”, stored in
current-input-method
, is nil by default. In this state, you see
the exact ASCII in Emacs buffer, that you typed on the
keyboard1.
In this post, my target non-English language is Gujarati. So I want to type on my English keyboard and have Gujarati script letters show up in the buffer.
Emacs provides the set-input-method
command to change the current
input method. This command is bound to C-x RET
C-\ by default. Pick the new input method after calling
that command.
To see the available input methods, do M-x list-input-methods
.
As I want to do Gujarati transliteration, I pick the gujarati-itrans
method.
If you don’t know Gujarati, don’t fret! The commands shown here will
work when transliterating to other languages too — only the
Gujarati-specific input method gujarati-itrans
will change to the
input method of your choice.
Toggling the input method #
I often need to switch between the Gujarati and English languages in
the same document. You can see me doing that in this post next section
onwards. The toggle-input-method
command bound by default to
C-\ is helpful here.
So if I am already in the “Gujarati transliteration mode” calling this
command will set current-input-method
back to nil. Repeating that
same call will again set current-input-method
to gujarati-itrans
,
and I will once again be in the “Gujarati transliteration mode”.
Caveats with Gujarati and other Indic language transliteration #
Apologies, but this section is meaningful only if you know how to read Gujarati. So you can safely skip to the next section.
Below table is a quick glimpse of some nuances in Gujarati transliteration. I will save my explanation and instead show some of the mistakes I made in transliteration using examples.
ASCII input | Gujarati Transliteration | Rough Translation |
---|---|---|
ram | રમ્ | (incorrect spelling, no meaning) |
rama | રમ | play |
raama | રામ | a popular name Raama (as in Lord Raama) |
angreji | અન્ગ્રેજિ | (incorrect spelling) |
hu.n | હું | I |
chhu.n | છું | am |
a.ngrejii | અંગ્રેજી2 | English (language) |
Ime.cksa | ઈમૅક્સ | this literally reads “Emacs” |
“Input method” cheat sheet #
Thankfully Emacs provides full help through the
describe-input-method
command bound to C-h
C-\
If you haven’t already noticed the consistency in these bindings, the
default bindings with C-\ in them are related to “input
method” commands.
by default.
For example, M-x describe-input-method gujarati-itrans
gives this:
The ∗Help∗ that shows up looks formidable at the first glance. Though, I found comfort in the fact that roughly half of the key sequences were obvious and roughly half resulted in Gujarati characters that I have never found the need of! 😃
Closing #
Typing this in the “transliteration mode”:
maaru naama kaushala chhe. mane e jaaNii ne aana.nda thaaya chhe ke hu.n aa sahelaaI thI lakhI shaku chhu.n. (joDanI-bhula maapha.)
will result in:
મારુ નામ કૌશલ છે. મને એ જાણી ને આનંદ થાય છે કે હું આ સહેલાઈ થી લખી શકુ છું. (જોડણી-ભુલ માફ.)
Translation: My name is Kaushal. I am happy knowing that I can write this easily.
References #
- Emacs Info: Input Methods
M-x describe-input-method gujarati-itrans