diff options
Diffstat (limited to 'tex/context')
10 files changed, 138 insertions, 14 deletions
diff --git a/tex/context/interface/third/t-transliterator.xml b/tex/context/interface/third/t-transliterator.xml index db62f09..f2ec522 100644 --- a/tex/context/interface/third/t-transliterator.xml +++ b/tex/context/interface/third/t-transliterator.xml @@ -19,6 +19,7 @@ <cd:constant type="all"/> <cd:constant type="sr_tolt"/> <cd:constant type="sr_tocy"/> + <cd:constant type="bg_de"/> <cd:constant type="iso9_ocs"/> <cd:constant type="ocs"/> <cd:constant type="ocs_gla"/> diff --git a/tex/context/third/transliterator/t-transliterator.mkiv b/tex/context/third/transliterator/t-transliterator.mkiv index b6b841c..1f73c43 100644 --- a/tex/context/third/transliterator/t-transliterator.mkiv +++ b/tex/context/third/transliterator/t-transliterator.mkiv @@ -36,14 +36,14 @@ \def\set_serbian_exceptions{% \doifelse{\transliterateparameter{sr_exceptions}}\v!yes - {\ctxlua{translit.sr_except = true}} - {\ctxlua{translit.sr_except = false}}% + {\ctxlua{thirddata.translit.sr_except = true}} + {\ctxlua{thirddata.translit.sr_except = false}}% } \def\set_hinting{% \doifelse{\transliterateparameter{hinting}}\v!yes - {\ctxlua{translit.hinting = true}} - {\ctxlua{translit.hinting = false}}% + {\ctxlua{thirddata.translit.hinting = true}} + {\ctxlua{thirddata.translit.hinting = false}}% } \appendtoks \set_serbian_exceptions \to \everysetuptransliterate @@ -93,9 +93,9 @@ environment.loadluafile ("trans_tables_trsc") environment.loadluafile ("trans_tables_glag") environment.loadluafile ("trans_tables_gr") - translit.gen_rules_en() - translit.gen_rules_de() - translit.show_tab(translit["\luaescapestring{#1}"]) + thirddata.translit.gen_rules_en() + thirddata.translit.gen_rules_de() + thirddata.translit.show_tab(translit["\luaescapestring{#1}"]) \stopluacode } @@ -103,12 +103,12 @@ %D \type{\showTranslitTabs}. \define\showTranslitTabs{% - \ctxlua{translit.show_all_tabs()}% + \ctxlua{thirddata.translit.show_all_tabs()}% } \def\translitDebug#1{% \doif{\transliterateparameter{debug}}{yes}{% - {\ss\inmargin{\ctxlua{translit.debug_next()}} #1}% + {\ss\inmargin{\ctxlua{thirddata.translit.debug_next()}} #1}% }% } @@ -134,7 +134,7 @@ \setuptransliterate[#1]% \fi \language[\transliterateparameter{hyphenate}]% - \ctxlua{translit.transliterate("\transliterateparameter{mode}","\luaescapestring{#2}")}% + \ctxlua{thirddata.translit.transliterate("\transliterateparameter{mode}","\luaescapestring{#2}")}% \egroup% } @@ -152,7 +152,7 @@ \setuptransliterate[#1]% \fi \language[\transliterateparameter{hyphenate}]% - \ctxlua{translit.transliterate("\transliterateparameter{mode}","\luaescapestring{#2}")}% + \ctxlua{thirddata.translit.transliterate("\transliterateparameter{mode}","\luaescapestring{#2}")}% \egroup% } 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..c20e0c8 --- /dev/null +++ b/tex/context/third/transliterator/trans_tables_bg.lua @@ -0,0 +1,107 @@ +--===========================================================================-- +-- Bulgarian -- +--===========================================================================-- + +local translit = thirddata.translit + +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/trans_tables_glag.lua b/tex/context/third/transliterator/trans_tables_glag.lua index 0c6c0bf..41974fd 100644 --- a/tex/context/third/transliterator/trans_tables_glag.lua +++ b/tex/context/third/transliterator/trans_tables_glag.lua @@ -3,6 +3,8 @@ -- Glagolica -- --===========================================================================-- +local translit = thirddata.translit + ------------------------------------------- -- Lowercase Glagolitic Transliteration -- ------------------------------------------- diff --git a/tex/context/third/transliterator/trans_tables_gr.lua b/tex/context/third/transliterator/trans_tables_gr.lua index 31637b8..55b4c54 100644 --- a/tex/context/third/transliterator/trans_tables_gr.lua +++ b/tex/context/third/transliterator/trans_tables_gr.lua @@ -2,6 +2,7 @@ -- Greek -- --===========================================================================-- +local translit = thirddata.translit -- Note that the Greek transliteration mapping isn't bijective so transliterated -- texts won't be reversible. (Shouldn't be impossible to make one up using diff --git a/tex/context/third/transliterator/trans_tables_iso9.lua b/tex/context/third/transliterator/trans_tables_iso9.lua index 9007b20..5f7c6d8 100644 --- a/tex/context/third/transliterator/trans_tables_iso9.lua +++ b/tex/context/third/transliterator/trans_tables_iso9.lua @@ -2,6 +2,8 @@ -- ISO 9.1995(E) standardized transliteration for cyrillic -- --===========================================================================-- +local translit = thirddata.translit + if not translit.done_iso9 then ----------------------------------------- -- Lowercase russian cyrillic alphabet -- diff --git a/tex/context/third/transliterator/trans_tables_scntfc.lua b/tex/context/third/transliterator/trans_tables_scntfc.lua index 9de4b96..904db71 100644 --- a/tex/context/third/transliterator/trans_tables_scntfc.lua +++ b/tex/context/third/transliterator/trans_tables_scntfc.lua @@ -2,6 +2,7 @@ -- Other transliterations -- --===========================================================================-- +local translit = thirddata.translit -- The following are needed because ISO 9 does not cover old Slavonic -- characters that became obsolete before the advent of гражданский шрифт. diff --git a/tex/context/third/transliterator/trans_tables_sr.lua b/tex/context/third/transliterator/trans_tables_sr.lua index 0371b75..2b1bdee 100644 --- a/tex/context/third/transliterator/trans_tables_sr.lua +++ b/tex/context/third/transliterator/trans_tables_sr.lua @@ -3,6 +3,9 @@ -- Serbian -- --===========================================================================-- +local translit = thirddata.translit + + -- Special thanks to Mojca Miklavec and Arthur Reutenauer for their -- assistance in creating these transliteration routines. diff --git a/tex/context/third/transliterator/trans_tables_trsc.lua b/tex/context/third/transliterator/trans_tables_trsc.lua index 355f735..e80048a 100644 --- a/tex/context/third/transliterator/trans_tables_trsc.lua +++ b/tex/context/third/transliterator/trans_tables_trsc.lua @@ -1,6 +1,9 @@ --===========================================================================-- -- Legacy national transliterations -- --===========================================================================-- + +local translit = thirddata.translit + --------------------------------- -- German simple transcription -- --------------------------------- diff --git a/tex/context/third/transliterator/transliterator.lua b/tex/context/third/transliterator/transliterator.lua index b64f888..c046ffb 100644 --- a/tex/context/third/transliterator/transliterator.lua +++ b/tex/context/third/transliterator/transliterator.lua @@ -9,9 +9,11 @@ -------------------------------------------------------------------------------- -- -translit = translit or {} -translit.tables = translit.tables or {} -translit.methods = translit.methods or {} +thirddata = thirddata or { } +thirddata.translit = thirddata.translit or { } +local translit = thirddata.translit +translit.tables = translit.tables or { } +translit.methods = translit.methods or { } -------------------------------------------------------------------------------- -- Predefining vowel lists @@ -259,6 +261,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") |