summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <megas.kapaneus@gmail.com>2011-08-06 19:34:44 +0200
committerPhilipp Gesang <megas.kapaneus@gmail.com>2011-08-06 19:34:44 +0200
commitb61d906e512a1ff167c674f38b22a1650a49f1a3 (patch)
tree52101b8a9290bf93bb49e7d75924df61769daf2c
parentebebb1a66fa7500ca1644a868d8378bccaf281ca (diff)
downloadtransliterator-b61d906e512a1ff167c674f38b22a1650a49f1a3.tar.gz
preliminary tables for Bulgarian
-rw-r--r--tex/context/third/transliterator/trans_tables_bg.lua105
-rw-r--r--tex/context/third/transliterator/transliterator.lua2
2 files changed, 107 insertions, 0 deletions
diff --git a/tex/context/third/transliterator/trans_tables_bg.lua b/tex/context/third/transliterator/trans_tables_bg.lua
new file mode 100644
index 0000000..ed1ddc2
--- /dev/null
+++ b/tex/context/third/transliterator/trans_tables_bg.lua
@@ -0,0 +1,105 @@
+--===========================================================================--
+-- Bulgarian --
+--===========================================================================--
+
+if not translit.done_bg then
+ ---------------------------------------------------------------------------
+ -- Uppercase Bulgarian -> „scientific“ transliteration --
+ ---------------------------------------------------------------------------
+
+ translit.bg_upp = translit.make_add_dict{
+ ["А"] = "A",
+ ["Б"] = "B",
+ ["В"] = "V",
+ ["Г"] = "G",
+ ["Д"] = "D",
+ ["Е"] = "E",
+ ["Ж"] = "Ž",
+ ["З"] = "Z",
+ ["И"] = "I",
+ ["Й"] = "J",
+ ["К"] = "K",
+ ["Л"] = "L",
+ ["М"] = "M",
+ ["Н"] = "N",
+ ["О"] = "O",
+ ["П"] = "P",
+ ["Р"] = "R",
+ ["С"] = "S",
+ ["Т"] = "T",
+ ["У"] = "U",
+ ["Ф"] = "F",
+ ["Х"] = "Ch",
+ ["Ц"] = "C",
+ ["Ч"] = "Č",
+ ["Ш"] = "Š",
+ ["Щ"] = "Št",
+ ["Ъ"] = "Ă",
+ ["Ь"] = "",
+ ["Ю"] = "Ju",
+ ["Я"] = "Ja",
+ }
+ translit.tables["Bulgarian \\quotation{scientific} transliteration uppercase"] = translit.bg_upp
+
+ ---------------------------------------------------------------------------
+ -- Lowercase Bulgarian -> „scientific“ transliteration --
+ ---------------------------------------------------------------------------
+ translit.bg_low = translit.make_add_dict{
+ ["а"] = "a",
+ ["б"] = "b",
+ ["в"] = "v",
+ ["г"] = "g",
+ ["д"] = "d",
+ ["е"] = "e",
+ ["ж"] = "ž",
+ ["з"] = "z",
+ ["и"] = "i",
+ ["й"] = "j",
+ ["к"] = "k",
+ ["л"] = "l",
+ ["м"] = "m",
+ ["н"] = "n",
+ ["о"] = "o",
+ ["п"] = "p",
+ ["р"] = "r",
+ ["с"] = "s",
+ ["т"] = "t",
+ ["у"] = "u",
+ ["ф"] = "f",
+ ["х"] = "ch",
+ ["ц"] = "c",
+ ["ч"] = "č",
+ ["ш"] = "š",
+ ["щ"] = "št",
+ ["ъ"] = "ă",
+ ["ь"] = "",
+ ["ю"] = "ju",
+ ["я"] = "ja",
+ }
+
+ translit.tables["Bulgarian \\quotation{scientific} transliteration lowercase"] = translit.bg_low
+
+ translit.done_bg = true
+end
+
+local P, Cs, lmatch = lpeg.P, lpeg.Cs, lpeg.match
+local addrules = translit.addrules
+local utfchar = translit.utfchar
+
+local memo = { }
+local function bulgarian (mode, text)
+ local bulgarian_parser
+ if memo[mode] then
+ return lmatch(memo[mode], text)
+ end
+ if mode == "de" then
+ local bg = translit.bg_upp + translit.bg_low
+ local p_bg = addrules(bg)
+ bulgarian_parser = Cs((p_bg / bg + utfchar)^0)
+ end
+ memo[mode] = bulgarian_parser
+ return bulgarian_parser and lmatch(bulgarian_parser, text) or ""
+end
+
+translit.methods["bg_de"] = function (text) return bulgarian("de", text) end
+
diff --git a/tex/context/third/transliterator/transliterator.lua b/tex/context/third/transliterator/transliterator.lua
index b64f888..ac3beb3 100644
--- a/tex/context/third/transliterator/transliterator.lua
+++ b/tex/context/third/transliterator/transliterator.lua
@@ -259,6 +259,8 @@ function translit.transliterate (method, text)
environment.loadluafile ("trans_tables_scntfc")
elseif method:match("^sr_") then
environment.loadluafile ("trans_tables_sr")
+ elseif method:match("^bg_") then -- only bg_de for now
+ environment.loadluafile ("trans_tables_bg")
elseif method == "gr" or
method == "gr_n" then
environment.loadluafile ("trans_tables_gr")