From 16e4920a632a4a7981381955bb4f35ae46565c96 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 17 Apr 2010 17:16:05 +0200 Subject: =?UTF-8?q?using=20metatables=20for=20table=20generation,=20allowi?= =?UTF-8?q?ng=20=E2=80=9Caddition=E2=80=9D=20of=20dictionaries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../third/transliterator/trans_tables_iso9.lua | 53 ++++++++++------------ 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'tex/context/third/transliterator/trans_tables_iso9.lua') diff --git a/tex/context/third/transliterator/trans_tables_iso9.lua b/tex/context/third/transliterator/trans_tables_iso9.lua index 4518466..e5fa980 100644 --- a/tex/context/third/transliterator/trans_tables_iso9.lua +++ b/tex/context/third/transliterator/trans_tables_iso9.lua @@ -1,3 +1,4 @@ +translit.tables = translit.tables or {} --===========================================================================-- -- ISO 9.1995(E) standardized transliteration for cyrillic -- @@ -6,7 +7,7 @@ ----------------------------------------- -- Lowercase russian cyrillic alphabet -- ----------------------------------------- -translit.ru_low = { +translit.ru_low = translit.make_add_dict({ ["а"] = "a", -- U+0430 -> U+0061 ["б"] = "b", -- U+0431 -> U+0062 ["в"] = "v", -- U+0432 -> U+0076 @@ -40,7 +41,7 @@ translit.ru_low = { ["э"] = "è", -- U+044d -> U+00e8 ["ю"] = "û", -- U+044e -> U+00fb ["я"] = "â" -- U+044f -> U+00e2 -} +}) translit.tables["russian lowercase ISO~9"] = translit.ru_low @@ -48,7 +49,7 @@ translit.tables["russian lowercase ISO~9"] = translit.ru_low -- Uppercase russian cyrillic alphabet -- ----------------------------------------- -translit.ru_upp = { +translit.ru_upp = translit.make_add_dict({ ["А"] = "A", -- U+0410 -> U+0041 ["Б"] = "B", -- U+0411 -> U+0042 ["В"] = "V", -- U+0412 -> U+0056 @@ -82,7 +83,7 @@ translit.ru_upp = { ["Э"] = "È", -- U+042d -> U+00c8 ["Ю"] = "Û", -- U+042e -> U+00db ["Я"] = "Â" -- U+042f -> U+00c2 -} +}) translit.tables["russian uppercase ISO~9"] = translit.ru_upp @@ -91,7 +92,7 @@ translit.tables["russian uppercase ISO~9"] = translit.ru_upp ---------------------------------------------------------- -- cf. http://www.russportal.ru/index.php?id=oldorth.decret1917 -translit.ru_old_low = { +translit.ru_old_low = translit.make_add_dict{ ["ѣ"] = "ě", -- U+048d -> U+011b -- 2-byte ["і"] = "ì", -- U+0456 -> U+00ec -- 2-byte ["ѳ"] = "f", -- U+0473 -> U+0066 -- 2-byte @@ -100,14 +101,14 @@ translit.ru_old_low = { translit.tables["russian pre-1918 lowercase ISO~9 2 byte"] = translit.ru_old_low -translit.ru_old_upp = { +translit.ru_old_upp = translit.make_add_dict{ ["Ѣ"] = "Ě", -- U+048c -> U+011a -- 2-byte ["І"] = "Ì", -- U+0406 -> U+00cc -- 2-byte ["Ѳ"] = "F", -- U+0424 -> U+0046 -- 2-byte ["Ѵ"] = "Ỳ", -- U+0474 -> U+1ef2 -- 3-byte } -translit.ru_jer_hack = { +translit.ru_jer_hack = translit.make_add_dict{ ["ь"] = "'", ["Ь"] = "'", ["ъ"] = "''", @@ -122,7 +123,7 @@ translit.tables["russian pre-1918 uppercase ISO~9 2 byte"] = translit.ru_old_upp -- Lowercase characters from other cyrillic alphabets -- --------------------------------------------------------- -translit.non_ru_low = { +translit.non_ru_low = translit.make_add_dict{ ["ӑ"] = "ă", -- U+04d1 -> U+0103 ["ӓ"] = "ä", -- U+04d3 -> U+00e4 ["ә"] = "a̋", -- u+04d9 -> U+0061+030b @@ -184,7 +185,7 @@ translit.tables["cyrillic other lowercase ISO~9"] = translit.non_ru_low -- Uppercase characters from other cyrillic alphabets -- --------------------------------------------------------- -translit.non_ru_upp = { +translit.non_ru_upp = translit.make_add_dict{ ["Ӑ"] = "Ă", -- U+04d0 -> U+0102 ["Ӓ"] = "Ä", -- U+04d2 -> U+00c4 ["Ә"] = "A̋", -- U+04d8 -> U+0041+030b @@ -241,11 +242,12 @@ translit.non_ru_upp = { ["Ӏ"] = "‡" -- U+04c0 -> U+2021 } +translit.tables["cyrillic other uppercase ISO~9"] = translit.non_ru_upp + --===========================================================================-- -- End Of Tables -- --===========================================================================-- -translit.tables["cyrillic other uppercase ISO~9"] = translit.non_ru_upp function translit.iso9 (mode, text) local P, R, S, V, Cs = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.Cs @@ -267,30 +269,25 @@ function translit.iso9 (mode, text) return rules end - local iso9 = {} - iso9 = translit.add_table( iso9, - translit.ru_upp, - translit.ru_low - ) + local iso9 = translit.make_add_dict{} + iso9 = translit.ru_upp + translit.ru_low + if mode == "ru_old" or mode == "all" then - iso9 = translit.add_table(iso9, - translit.ru_old_upp, - translit.ru_old_low - ) + + iso9 = iso9 + translit.ru_old_upp + translit.ru_old_low + if mode == "all" then - iso9 = translit.add_table(iso9, - translit.non_ru_upp, - translit.non_ru_low - ) + iso9 = iso9 + + translit.non_ru_upp + + translit.non_ru_low end end if mode == "ru_old_jer_hack" then - iso9 = translit.add_table(iso9, - translit.ru_old_upp, - translit.ru_old_low, - translit.ru_jer_hack - ) + iso9 = iso9 + + translit.ru_old_upp + + translit.ru_old_low + + translit.ru_jer_hack end local p_iso9 -- cgit v1.2.3