From b61d906e512a1ff167c674f38b22a1650a49f1a3 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 6 Aug 2011 19:34:44 +0200 Subject: preliminary tables for Bulgarian --- .../third/transliterator/trans_tables_bg.lua | 105 +++++++++++++++++++++ .../third/transliterator/transliterator.lua | 2 + 2 files changed, 107 insertions(+) create mode 100644 tex/context/third/transliterator/trans_tables_bg.lua 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") -- cgit v1.2.3