Page 1 of 5 123 ... LastLast
Results 1 to 10 of 44

Thread: Sanskrit input (Devanagari and transliteration)

  1. #1
    Join Date
    May 2006
    Location
    Boston
    Beans
    42
    Distro
    Ubuntu 11.04 Natty Narwhal

    Sanskrit input (Devanagari and transliteration)

    Update: In the new releases since this post was written, Ubuntu has come a very long way with preconfiguring the input method editor, now ibus (formerly SCIM), for us. It is now ready to go practically out of the box and setting up phonetic देवनागरी and Transliteration inputs is a trivial affair. For phonetic Devanāgarī, all you need to do is:
    1. Go to System > Administration > Language Support, and in the Language Tab select ibus for your "Keyboard Input Method System"
    2. Then click the button Install / Remove Languages..., click Hindi and Apply Changes


    That's it -- too simple! You may need to log out and log back in (i.e., restart X) for ibus to work. Once you hit ctrl-space, the ibus daemon should start up and you can begin typing in Devanagari by adding the Hindi Itrans input to your keyboard switcher. I'll leave the now-obsolete steps previously required for SCIM configuration in a quote below for those on older versions of Ubuntu (or other varieties of Debian), for the sake of reference. Scroll down below the quote for specific instructions on my recommendations for better Sanskrit input.

    For anyone having difficulty setting up their system to handle Sanskrit input, I'd like to point you to the relevant documentation and provide a few tips to save you a few hours of googling and trial and error. General disclaimer: I am still a linux beginner and I've never written an official "tips and tricks" post before, so 1. caveat emptor and 2. all suggestions / feedback / improvements welcome!

    Devanagari - देवनागरी

    This has worked well in Ubuntu for some time now, it just requires a little system configuration (less now than previously). Before beginning, you might want to check out the SCIM documentation for Ubuntu here and here.

    1. Go to: System > Administration > Language Support, check the box for Hindi, click Apply and then the select box for Enable support to enter complex characters. Proceed to Step 2.

      1. That should have pulled in both the Scim input method editor and the Devanagari fonts packages necessary for unicode input. For those on other Debian systems, who lack the helpful Ubuntu menu mentioned above, you can manually install the packages with the following:
        Code:
        sudo aptitude install ttf-devanagari-fonts scim-qtimm scim-tables-additional scim-bridge scim-m17n m17n-lib-bin m17n-db scim-bridge-client-qt4 skim im-switch
    2. Configure your system by entering the following commands in a terminal (for those not in the US, enter the appropriate language / country codes in place of "en_US"):
      Code:
      im-switch -z en_US -s scim
      export XMODIFIERS=@im=SCIM
      export GTK_IM_MODULE=scim
      export QT_IM_MODULE=scim
      Note: A more general alternative to the first command is simply "im-switch -z all_ALL -s scim" which may be preferable depending on your language setup. Also, it should no longer be necessary, but if in the end SCIM does not work properly at startup, you could also add the last three lines of code above to the .bashrc file in your home directory and restart X.
    3. Set up SCIM to run at startup by going to System > Preferences > Sessions > Startup Program > + Add > Command and enter
      Code:
      scim -d
    That should be it for the basic set up. If you were to restart X or reboot at this point, you should be able to type in Devanagari with ease using ibus / m17n. However, I would recommend first tweaking your input method, because although the hi-itrans transliteration scheme is by far the most user-friendly of those available (in being relatively phonetic), it has a few problems. One is that the combination "rh" is designed to yield ऱ् rather than र्ह् . Similarly there is no transliteration for the double daṇḍa (used at the end of stanzas, etc., i.e. — ॥ — requiring that one use the less elegant combination of two daṇḍas — ।। . Also, there are several keystroke combinations in the Itrans scheme which to me at least seem either unintuitive or a little unwieldy: e.g., "R^i" for ऋ .

    1. Exit ibus (if you've already rebooted) and save a backup of your original input file (in your home directory):
      Code:
      cp /usr/share/m17n/hi-itrans.mim ~/
    2. then open that file for editing: type in a terminal
      Code:
      sudo gedit /usr/share/m17n/hi-itrans.mim
    3. Overwrite the contents of the file with the quote below. Select all (Ctrl-a) in that file and copy / paste the following quote into the hi-itrans file:

      ;; hi-itrans.mim -- Hindi input method with ITRANS method
      ;; Copyright (C) 2003, 2004, 2005
      ;; National Institute of Advanced Industrial Science and Technology (AIST)
      ;; Registration Number H15PRO112

      ;; This file is part of the m17n database; a sub-part of the m17n
      ;; library.

      ;; The m17n library is free software; you can redistribute it and/or
      ;; modify it under the terms of the GNU Lesser General Public License
      ;; as published by the Free Software Foundation; either version 2.1 of
      ;; the License, or (at your option) any later version.

      ;; The m17n library is distributed in the hope that it will be useful,
      ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
      ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      ;; Lesser General Public License for more details.

      ;; You should have received a copy of the GNU Lesser General Public
      ;; License along with the m17n library; if not, write to the Free
      ;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
      ;; 02111-1307, USA.

      (input-method hi itrans)

      (description "Hindi input method by ITRANS transliteration.
      For the detail of ITRANS, see the page:
      <http://www.aczoom.com/itrans/>
      ")

      (title "क")

      (map
      (starter
      (".") ("~") ("#") ("$") ("^") ("*") ((S-\ )) ((C-@))
      ("0") ("1") ("2") ("3") ("4")
      ("5") ("6") ("7") ("8") ("9")
      ("A") ("C") ("D") ("G") ("H") ("I") ("J") ("K") ("L")
      ("M") ("N") ("O") ("R") ("S") ("T") ("U") ("Y")
      ("a") ("b") ("c") ("d") ("e") ("f") ("g") ("h") ("i")
      ("j") ("k") ("l") ("m") ("n") ("o") ("p") ("q") ("r")
      ("s") ("t") ("u") ("v") ("w") ("x") ("y") ("z"))

      (consonant
      ("k" "क्")
      ("kh" "ख्")
      ("g" "ग्")
      ("gh" "घ्")
      ("~N" "ङ्")
      ("c" "च्")
      ("ch" "छ्")
      ("j" "ज्")
      ("jh" "झ्")
      ("~n" "ञ्")
      (".t" "ट्")
      ("T" "ट्")
      (".th" "ठ्")
      ("Th" "ठ्")
      (".d" "ड्")
      ("D" "ड्")
      (".dh" "ढ्")
      ("Dh" "ढ्")
      (".n" "ण्")
      ("N" "ण्")
      ("t" "त्")
      ("th" "थ्")
      ("d" "द्")
      ("dh" "ध्")
      ("n" "न्")
      ("xn" "ऩ्")
      ("p" "प्")
      ("ph" "फ्")
      ("b" "ब्")
      ("bh" "भ्")
      ("m" "म्")
      ("y" "य्")
      ("r" "र्")
      ("xr" "ऱ्")
      ("l" "ल्")
      ("L" "ळ्")
      ("ld" "ळ्")
      ("v" "व्")
      ("w" "व्")
      ("sh" "श्")
      ("Sh" "ष्")
      (".s" "ष्")
      ("s" "स्")
      ("h" "ह्")
      ("q" "क़्")
      ("K" "ख़्")
      ("xg" "ग़्")
      ("xj" "ज़्")
      ("z" "ज़्")
      (".D" "ड़्")
      (".Dh" "ढ़्")
      ("f" "फ़्")
      ("Y" "य़्")
      ("yh" "य़्")
      ("GY" "ज्ञ्")
      ("dny" "ज्ञ्"))

      (independent
      ("a" "अ")
      ("aa" "आ")
      ("A" "आ")
      ("i" "इ")
      ("ii" "ई")
      ("I" "ई")
      ("u" "उ")
      ("uu" "ऊ")
      ("U" "ऊ")
      (".r" "ऋ")
      ("RRi" "ऋ")
      ("R^i" "ऋ")
      ("LLi" "ऌ")
      ("L^i" "ऌ")
      (".l" "ऌ")
      (".c" "ऍ")
      ("e.c" "ऍ")
      ("E" "ऎ")
      ("e" "ए")
      ("ai" "ऐ")
      ("o.c" "ऑ")
      ("O" "ऒ")
      ("o" "ओ")
      ("au" "औ")
      ("RRI" "ॠ")
      ("R^I" "ॠ")
      (".R" "ॠ")
      ("LLI" "ॡ")
      ("L^I" "ॡ")
      (".L" "ॡ")
      (".N" "ँ")
      (".m" "ं")
      ("M" "ं")
      ("H" "ः")
      (".a" "ऽ")
      (".h" "्")
      ("AUM" "ॐ")
      ("OM" "ॐ")
      (".." "।")
      (".," "॥")
      ("0" "०")
      ("1" "१")
      ("2" "२")
      ("3" "३")
      ("4" "४")
      ("5" "५")
      ("6" "६")
      ("7" "७")
      ("8" "८")
      ("9" "९")
      ("#" "्र")
      ("$" "र्")
      ("^" "त्र")
      ("*" "श्र")
      ("]" "़")
      ((S-\ ) "*")
      ((C-@) "*"))

      (dependent
      ("a" (delete @-) "")
      ("aa" (delete @-) "ा")
      ("A" (delete @-) "ा")
      ("i" (delete @-) "ि")
      ("ii" (delete @-) "ी")
      ("I" (delete @-) "ी")
      ("u" (delete @-) "ु")
      ("uu" (delete @-) "ू")
      ("U" (delete @-) "ू")
      ("RRi" (delete @-) "ृ")
      ("R^i" (delete @-) "ृ")
      (".r" (delete @-) "ृ")
      ("LLi" (delete @-) "ॢ")
      ("L^i" (delete @-) "ॢ")
      (".l" (delete @-) "ॢ")
      (".c" (delete @-) "ॅ")
      ("e.c" (delete @-) "ॅ")
      ("E" (delete @-) "ॆ")
      ("e" (delete @-) "े")
      ("ai" (delete @-) "ै")
      ("o.c" (delete @-) "ॉ")
      ("O" (delete @-) "ॊ")
      ("o" (delete @-) "ो")
      ("au" (delete @-) "ौ")
      ("RRI" (delete @-) "ॄ")
      ("R^I" (delete @-) "ॄ")
      (".R" (delete @-) "ॄ")
      ("LLI" (delete @-) "ॣ")
      (".L" (delete @-) "ॣ")
      ("L^I" (delete @-) "ॣ"))

      (return
      ((Return)))

      (backspace
      ((BackSpace) (undo))))

      (state
      (init
      (starter (pushback 1) (shift intermediate)))

      (intermediate
      (consonant (shift second))
      (independent (shift finish))
      (backspace)
      (return (shift init)))

      (second
      (consonant)
      (dependent (shift finish))
      (backspace)
      (return (shift init)))

      (finish
      (return)
      (t (shift init))))

      ;; Local Variables:
      ;; coding: utf-8
      ;; mode: lisp
      ;; End:
    4. Hold back m17n-db. One neat trick is to hold back the m17n library package so that it won't update and overwrite your edits (you'll be warned first before dist-upgrades). To do that, enter in a terminal:
      Code:
      echo "libm17n-0 hold" | sudo dpkg --set-selections
      and upgrades will bypass m17n, thus preserving your edits. If you opt not to hold that file, you'll just need to repeat the two steps above after updates to m17n to restore a more phonetic input in hi-itrans. For more information on holding and releasing packages, see here.
    5. You should feel free, btw, to tweak the above keyboard map to your tastes, just be sure not to create any conflicts in the process!


    Reboot for your changes to take effect and then configure ibus as necessary using "ibus Preferences" and select "hi-itrans" for phonetic Devanagari input. You can then select from among your newly installed Devanagari fonts (AksharYogini, Chandas, Gargi, Kalimati, Nakula, Sahadeva, Samanata and Sarai). For a very readable font with a decent set of ligatures, I like Kalimati, though for Sanskrit I tend to use Chandas/Uttara because of its unparalleled ligature set.


    Transliteration

    Unlike Devanagari, there seems to be a relative dearth of information available for an intuitive system-wide Sanskrit transliteration input method. I have now found several different ways of going about this, two of which are listed below: ibus/m17n or Xmodmap. I highly recommend the first alternative.

    1st Alternative: ibus/m17n

    The best way to enable an inutitive Sanskrit transliteration input method is to create a new one using ibus/m17n. The pdf referred to above has the necessary documentation. I will describe my setup below, by way of example. Update: I have updated this transliteration scheme to include the diacritics necessary for easy inputting of French and German as well. The hotkeys for those, as well as for the Sanskrit diacritics, may be easily gleaned by referring to the keymap in the quote below.

    1. Exit ibus.
    2. Create a new input method file, e.g.,
      Code:
      sudo gedit /usr/share/m17n/sa-translit.mim
      and enter the appropriate file preamble and desired keystroke combinations. The following is the complete content of my file which can be easily copied and pasted and tweaked according to your taste. Save it, before closing the file:
      ;;; <li> ;;; <li> sa-translit.mim
      ;;;
      ;;; Input method for Sanskrit transliteration using the ITRANS scheme.

      (title "sa-translit")

      (map
      (trans

      ("aa" "ā")
      ("AA" "Ā")
      ("ii" "ī")
      ("$e" "ē")
      ("$o" "ō")
      ("II" "Ī")
      ("uu" "ū")
      ("UU" "Ū")
      ("$E" "Ē")
      ("$O" "Ō")
      (".r" "ṛ")
      (".R" "Ṛ")
      (".rr" "ṝ")
      (".RR" "Ṝ")
      (".l" "ḷ")
      (".L" "Ḷ")
      (".ll" "ḹ")
      (".LL" "Ḹ")
      (".M" "ṁ")
      (".m" "ṃ")
      (".h" "ḥ")
      (".H" "Ḥ")
      (";n" "ṅ")
      (";N" "Ṅ")
      ("~n" "ñ")
      ("~N" "Ñ")
      (".t" "ṭ")
      (".T" "Ṭ")
      (".d" "ḍ")
      (".D" "Ḍ")
      (".n" "ṇ")
      (".N" "Ṇ")
      (";s" "ś")
      (";S" "Ś")
      (".s" "ṣ")
      (".S" "Ṣ")
      ("!a" "à")
      ("!e" "è")
      ("!i" "ì")
      ("!o" "ò")
      ("!u" "ù")
      ("!A" "À")
      ("!E" "È")
      ("!I" "Ì")
      ("!O" "Ò")
      ("!U" "Ù")
      ("?a" "á")
      ("?e" "é")
      ("?i" "í")
      ("?o" "ó")
      ("?u" "ú")
      ("?A" "Á")
      ("?E" "É")
      ("?I" "Í")
      ("?O" "Ó")
      ("?U" "Ú")
      ("^a" "â")
      ("^e" "ê")
      ("^i" "î")
      ("^o" "ô")
      ("^u" "û")
      ("^A" "Â")
      ("^E" "Ê")
      ("^I" "Î")
      ("^O" "Ô")
      ("^U" "Û")
      ("#a" "ä")
      ("#e" "ë")
      ("#i" "ï")
      ("#o" "ö")
      ("#u" "ü")
      ("#A" "Ä")
      ("#E" "Ë")
      ("#I" "Ï")
      ("#O" "Ö")
      ("#U" "Ü")
      ("%a" "ă")
      ("%i" "ĭ")
      ("%u" "ŭ")
      ("%e" "ĕ")
      ("%o" "ŏ")
      ("%A" "Ă")
      ("%I" "Ĭ")
      ("%U" "Ŭ")
      ("%E" "Ĕ")
      ("%O" "Ŏ")
      ("~a" "ã")
      ("~i" "ĩ")
      ("~u" "ũ")
      ("~e" "ẽ")
      ("~o" "õ")
      ("~A" "Ã")
      ("~I" "Ĩ")
      ("~U" "Ũ")
      ("~E" "Ẽ")
      ("~O" "Õ")
      ("-ae" "æ")
      ("-Ae" "Æ")
      ("-AE" "Æ")
      ("-oe" "œ")
      ("-Oe" "Œ")
      ("-OE" "Œ")
      (",c" "ç")
      (",C" "Ç")
      ))

      (state
      (init
      (trans)))
    3. Enter the name of our new input file in the m17n database file.
      1. In a terminal enter
        Code:
        sudo gedit /usr/share/m17n/mdb.dir
      2. change the following lines
        (input-method * "*.mim")
        ;;; </ul>
        to read
        (input-method * "*.mim")
        (input-method t sa-translit "sa-translit.mim")
        ;;; </ul>
      3. Save and exit.

    Simply restart ibus or if that fails, restart X or reboot. Your new transliteration input method should be available under the "Other" category of ibus' drop-down menu.

    2nd Alternative: XModmap

    If for whatever reason, you need another method for transliteration, you can use XModmap. I've given instructions for that here. This method uses less convenient dead keys, however, and is not convienently switchable, unlike m17n.

    I hope this post is of use to others in need of Devanagari and transliterated input on linux.

    शुभं भवतु । śubhaṃ bhavatu |
    Last edited by amerikkanu; May 9th, 2013 at 05:45 PM. Reason: altered ē/ō input to prevent conflicts when also used for English input

  2. #2
    Join Date
    Jun 2007
    Location
    india>maharastra>nashik
    Beans
    202
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Sanskrit input (Devanagari and transliteration)

    your post was very helpful to me. it has answered lots of questions and made some new questions
    i have 4 type of keyboard layout of Hindi
    phonetic
    inscript
    Remington
    and now hi-itrans
    but what i was searching is godrej and modular type of keyboard
    so should i make *.mim file in /usr/share/m17n with all the characters what i want.
    also there are no phonetic.mim, inscript.mim and remington.mim file in /usr/share/m17n/
    but i have Hindi-phonetic.bin Hindi-inscript.bin and dev.remington.bin file in /usr/share/scim/tables/ could i edit these keyboard to suite my needs as you have done hear

    http://www.dataflow.in/dl/godrej.pdf
    http://www.dataflow.in/dl/modular.pdf
    Last edited by rahul_bhise; February 28th, 2008 at 08:43 PM.

  3. #3
    Join Date
    May 2007
    Beans
    112

    Wink Re: Sanskrit input (Devanagari and transliteration)

    Thank you!

  4. #4
    MountainX's Avatar
    MountainX is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Jan 2008
    Location
    A place with no mountains
    Beans
    1,610
    Distro
    Kubuntu

    Re: Sanskrit input (Devanagari and transliteration)

    Thank you for this.

    FYI, I did not have to do step one.

    I simply did this:
    Code:
    Go to: System > Administration > Language Support, check the box for Hindi, click Apply and then the select box for Enable support to enter complex characters.
    I checked afterwards with:
    Code:
    dpkg -s ttf-devanagari-fonts
    It reports:
    Code:
    Package: ttf-devanagari-fonts
    Status: install ok installed
    And scim is running after reboot.

    Is there still a reason to use this?
    Code:
    sudo aptitude install ttf-devanagari-fonts scim-qtimm scim-tables-additional scim-bridge scim-m17n m17n-lib-bin

  5. #5
    MountainX's Avatar
    MountainX is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Jan 2008
    Location
    A place with no mountains
    Beans
    1,610
    Distro
    Kubuntu

    Re: Sanskrit input (Devanagari and transliteration)

    How do I enter आ in the older vedic style as shown in this document?

    http://www.scribd.com/doc/6057769/Yogasutras

    Thanks

  6. #6
    MountainX's Avatar
    MountainX is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Jan 2008
    Location
    A place with no mountains
    Beans
    1,610
    Distro
    Kubuntu

    Re: Sanskrit input (Devanagari and transliteration)

    Quote Originally Posted by MountainX View Post
    How do I enter आ in the older vedic style (in unicode)?
    It appears that the ancient vedic characters are not part of unicode yet:
    http://sanskritlibrary.org/VedicUnicode

  7. #7
    Join Date
    May 2006
    Location
    Boston
    Beans
    42
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Sanskrit input (Devanagari and transliteration)

    Thanks a lot for the feedback, I'll edit the post accordingly.

  8. #8
    Join Date
    May 2006
    Location
    Boston
    Beans
    42
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Sanskrit input (Devanagari and transliteration)

    Actually, if you use Uttara from this site, you can get that 'a' vowel-sign, and others. It's the most full featured नागरी font I know of; it's what I usually use, though I prefer the aesthetics / readability of a couple of others.

  9. #9
    MountainX's Avatar
    MountainX is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Jan 2008
    Location
    A place with no mountains
    Beans
    1,610
    Distro
    Kubuntu

    Re: Sanskrit input (Devanagari and transliteration)

    Quote Originally Posted by amerikkanu View Post
    Actually, if you use Uttara from this site, you can get that 'a' vowel-sign, and others.
    Thank you! I had that font on my system, but it was corrupted and I didn't know it. I went to the link you provided and downloaded the font again. I like it a lot. It fits my needs.

    And thanks again for such a great and helpful post.

  10. #10
    Join Date
    May 2008
    Location
    Bhopal, M.P., India
    Beans
    4
    Distro
    Edubuntu 10.04 Lucid Lynx

    Re: Sanskrit input (Devanagari and transliteration)

    Dear amerikkanu,
    Thanks and congrats for this great post.
    I have used this method on my several systems, but I have faced some problem in my two laptops.
    In my first laptop, the scim icon shown on top bar and there is a display drop down menu containing different languages and their keyboard layouts. But when I select "hi-trans" from the drop down menu the icon appears on the screen but the keyboard doesn't work accordingly.

    In my second laptop, I have installed it and it was working before rebooting. After rebooting, SCIM keyboard icon is shown on top bar but the icon is not displaying the drop down menu while clicking on it.

    Please guide me in this regard how to solve the above mentioned problems.
    Regards
    Ajit...

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •