Emacs, scripting and anything text oriented.

Gujarati Transliteration

Kaushal Modi

You 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-27Gujarati Transliteration
2022-06-19Gujarati 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 inputGujarati TransliterationRough 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અંગ્રેજી2English (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:

Figure 1: Partial screen capture of Gujarati transliteration cheat sheet C-h C- gujarati-itrans

Figure 1: Partial screen capture of Gujarati transliteration cheat sheet C-h C- gujarati-itrans

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 #


  1. I am assuming an English keyboard here. ↩︎

  2. This spelling might still render incorrectly on your browser depending on the unicode character set available for Gujarati on your system. ↩︎