;; yi-yivo.mim -- Yiddish input method with YIVO transliteration
;; Copyright (C) 2010
;; Raghav Krishnapriyan (raghav.k11n@gmail.com)

;; 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., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

(input-method yi yivo)
											
(description "Yiddish input method using YIVO transliteration.
A short description of the YIVO transliteration scheme can be found here: http://www.ibiblio.org/pub/academic/languages/yiddish/mendele/vol4.170
A description of the YIVO orthography can be found in Mordkhe Schaechter, _Der eynheytlekher Yidisher oysleyg: Takones fun yidishn oysleyg_, New York: Yivo and Yiddish Language Resource Center of the League for Yiddish (6th ed. 1999).
")
											
(title "ייִדיש")
(map
  (initials
	("i" "אי")
	("u" "או")
	("u|" ?ו)
	("ey" "אײ")
	("ay" "אײַ")
	("oy" "אױ")
	("ayo" "אַיאָ")
  )
  (initdiph
	("e" ?ע)
	("a" "אַ")
	("o" "אָ")
  )
  (otherchars
	("A") ("b") ("c") ("d") ("f") ("g") ("h") ("H") ("k") ("l") ("m") ("n") ("p") ("P") ("r") ("s") ("S") ("t") ("u") ("v") ("x") ("y") ("z") ("B") ("K") ("T") ("w") ("W") 
  )
  (allchars
	("A") ("b") ("c") ("d") ("f") ("g") ("h") ("H") ("k") ("l") ("m") ("n") ("p") ("P") ("r") ("s") ("S") ("t") ("u") ("v") ("x") ("y") ("z") ("B") ("K") ("T") ("w") ("W") ("a") ("e") ("o") ("i") ("u") ("|") ("`")
  )
  (medials
	("A" ?א)
	("b" ?ב)
	("c" ?ץ)
	("d" ?ד)
	("e" ?ע)
	("ey" "ײ")
	("f" ?ף)
	("g" ?ג)
	("h" ?ה)
	("H" ?ח)
	("i" ?י)
	("k" ?ק)
	("kh" ?ך)
	("k|h" "קה")
	("l" ?ל)
	("m" ?ם)
	("n" ?ן)
	("oy" "ױ")
	("P" ?פ)
	("r" ?ר)
	("s" ?ס)
	("sh" ?ש)
	("s|h" "סה")
	("S" ?ת)
	("t" ?ט)
	("ts" ?ץ)
	("t|s" "טס")
	("u" ?ו)
	("v" "װ")
	("x" ?ך)
	("y" ?י)
	("z" ?ז)
	("a" "אַ")
	("B" "בֿ")
	("ay" "ײַ")
	("w" ?ש)
	("K" "כּ")
	("o" "אָ")
	("p" "פּ")
	("T" "תּ")
	("tsh" "טש")
	("W" "שׂ")
	("zh" "זש")
	("uv" "וּװ")
	("vu" "װוּ")
	("yi" "ייִ")
	("ui" "ויִ")
	("eyi" "ײיִ")
	("ie" "יִע")
	("ei" "עיִ")
	("iu" "יִו")
	("ii" "יִיִ")
	("ayi" "ײַיִ")
	("ayo" "אַיאָ")
	("iy" "יִי") 
	("ia" "יִאַ")
	("io" "יִאָ")
	("uu" "וּו")
	("uvu" "וּװוּ")	; For words like "tsuvuks!"
  )
  (abbreviations
	("s'" "ס'")
	("m'" "מ'")
	("kh'" "כ'")
  )
  (openquotes
	("\"" "„")
	(",," "„")
	)
  (closequotes 
	("\"" "‟")
	("?\"" "?‟")
	(".\"" ".‟")
	("!\"" "!‟")
	("''" "‟")
  )
  (parentheses
	("\(" "\)")
	("\)" "\(")
  )
  (normal ("|"))
  (makef ("-" "־") ("--" "-"))
  (gershayim
	("`" "׳")
	("``" "״")
  )
  (bidi
	("L" "‎")
	("R" "‏")
  ) 
  (backspace
	((BackSpace) (undo)))
)
											
(state 
  (init
	(initials (shift subsq))
	(initdiph)
	(openquotes)
	(otherchars (pushback 1) (shift subsq))
	(backspace)
	(bidi)
	(parentheses)
  )
  (subsq
	(allchars 
		(pushback 1)
		(cond
			((= @-1 ?ף) (delete @-1) (insert "פֿ"))
			((= @-1 ?ך) (delete @-1) (insert ?כ))
			((= @-1 ?ם) (delete @-1) (insert ?מ))
			((= @-1 ?ן) (delete @-1) (insert ?נ))
			((= @-1 ?ץ) (delete @-1) (insert ?צ))
		)
		(shift letters))
	(closequotes)
	(makef (shift init))
	(backspace)
	(nil (shift init))
  )
  (letters
	(normal (shift subsq))
	(medials (shift subsq))
	(abbreviations (shift init))
	(gershayim)
	(nil (shift subsq))
  )
)
