summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-05-10 14:35:41 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2011-05-10 14:35:41 +0200
commit6565f523e31cc7befbd7b473a2e9bc006559ad6c (patch)
treecfdb8d567a81e3ab860a38f036b903625f239323
parent2adaa27b0259a19d6fae19e27ec6f81a3db14738 (diff)
downloadtransliterator-6565f523e31cc7befbd7b473a2e9bc006559ad6c.tar.gz
improved Serbian exception handling
-rw-r--r--tex/context/third/transliterator/trans_tables_sr.lua17
1 files changed, 13 insertions, 4 deletions
diff --git a/tex/context/third/transliterator/trans_tables_sr.lua b/tex/context/third/transliterator/trans_tables_sr.lua
index 0a601e3..0f9eae4 100644
--- a/tex/context/third/transliterator/trans_tables_sr.lua
+++ b/tex/context/third/transliterator/trans_tables_sr.lua
@@ -91,16 +91,25 @@ if not translit.done_serbian then
translit.sr_tocy_lower = translit.make_add_dict(__inverse_tab(translit.sr_tolt_lower))
translit.sr_tocy_upper = translit.make_add_dict(__inverse_tab(translit.sr_tolt_upper))
- translit.serbian_exceptions = {
+ local except = {
["nadživeti"] = "надживети",
- ["Nadživeti"] = "Надживети",
}
local P = lpeg.P
- for lat, _ in next, translit.serbian_exceptions do
- translit.p_serbian_exceptions = translit.p_serbian_exceptions and translit.p_serbian_exceptions + P(lat) or P(lat)
+ local sub, upper = unicode.utf8.sub, unicode.utf8.upper
+
+ local sre, p_sre = {}
+ for lat, cyr in next, except do
+ local Lat = upper(sub(lat, 1, 1)) .. sub(lat, 2)
+ local Cyr = upper(sub(cyr, 1, 1)) .. sub(cyr, 2)
+ local LAT, CYR = upper(lat), upper(cyr)
+ p_sre = p_sre and p_sre + P(lat) + Lat + LAT or P(lat) + Lat + LAT
+ sre[lat], sre[Lat], sre[LAT] = cyr, Cyr, CYR
end
+ translit.serbian_exceptions = sre
+ translit.p_serbian_exceptions = p_sre
+
translit.done_serbian = true
end