มอดูล:Orya-translit
This module will transliterate text in the อักษรโอริยา. It is used to transliterate สันสกฤต (sa
), Kuvi (kxv
), Kui (India) (kxu
), โอริยา (or
), Pengo (peg
), Manda (India) (mha
), Konda-Dora (kfc
), and Ollari (gdb
).
The module should preferably not be called directly from templates or other modules. To use it from a template, use {{xlit}}
. Within a module, use Module:languages#Language:transliterate.
For testcases, see Module:Orya-translit/testcases.
Functions[แก้ไข]
tr(text, lang, sc)
- Transliterates a given piece of
text
written in the script specified by the codesc
, and language specified by the codelang
. When the transliteration fails, returnsnil
.
local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local letter_with_mark = "(.["..u(0x0300).."-"..u(0x036F).."]?)"
local tt = {
-- consonants
["କ"] = "ก", ["ଖ"] = "ข", ["ଗ"] = "ค", ["ଘ"] = "ฆ", ["ଙ"] = "ง",
["ଚ"] = "จ", ["ଛ"] = "ฉ", ["ଜ"] = "ช", ["ଝ"] = "ฌ", ["ଞ"] = "ญ",
["ଟ"] = "ฏ", ["ଠ"] = "ฐ", ["ଡ"] = "ฑ", ["ଢ"] = "ฒ", ["ଣ"] = "ณ",
["ତ"] = "ต", ["ଥ"] = "ถ", ["ଦ"] = "ท", ["ଧ"] = "ธ", ["ନ"] = "น",
["ପ"] = "ป", ["ଫ"] = "ผ", ["ବ"] = "พ", ["ଭ"] = "ภ", ["ମ"] = "ม",
["ଯ"] = "ย", ["ର"] = "ร", ["ଲ"] = "ล", ["ଳ"] = "ฬ", ["ଵ"] = "ว",
["ଶ"] = "ศ", ["ଷ"] = "ษ", ["ସ"] = "ส", ["ହ"] = "ห",
[u(0x0B5C)] = "ฑ̱", [u(0x0B5D)] = "ฒ̱", ["ୟ"] = "ย̱", ["ୱ"] = "ว̱",
-- independent vowels
["ଅ"] = "อ", ["ଆ"] = "อา", ["ଇ"] = "อิ", ["ଈ"] = "อี", ["ଉ"] = "อุ", ["ଊ"] = "อู",
["ଋ"] = "ฤ", ["ୠ"] = "ฤๅ", ["ଌ"] = "ฦ", ["ୡ"] = "ฦๅ",
["ଏ"] = "เอ", ["ଐ"] = "ไอ", ["ଓ"] = "โอ", ["ଔ"] = "เอา",
-- dependent vowels and diacritics (excluding front type)
["ା"] = "า", ["ି"] = "ิ", ["ୀ"] = "ี", ["ୁ"] = "ุ", ["ୂ"] = "ู",
["ୃ"] = "ฺฤ", ["ୄ"] = "ฺฤๅ", ["ୢ"] = "ฺฦ", ["ୣ"] = "ฺฦๅ",
["ୖ"] = "~", ["ୗ"] = "~", ["ଂ"] = "ํ", ["ଃ"] = "ห์", ["୍"] = "ฺ",
["଼"] = u(0x0331), -- macron below
["ଁ"] = "ม̐", -- candrabindu
-- marks
["ଽ"] = "-",
-- numerals
["୦"] = "0", ["୧"] = "1", ["୨"] = "2", ["୩"] = "3", ["୪"] = "4",
["୫"] = "5", ["୬"] = "6", ["୭"] = "7", ["୮"] = "8", ["୯"] = "9",
-- zero-width space (display it if it hides in a word)
[u(0x200B)] = "‼",
}
local adjust0 = {
-- for convenience
["ଡ".."଼"] = u(0x0B5C), ["ଢ".."଼"] = u(0x0B5D),
["େ".."ୖ"] = "ୈ", ["େ".."ା"] = "ୋ", ["େ".."ୗ"] = "ୌ",
}
local adjust1 = {
-- dependent vowels (front type)
["େ"] = "เ%1", ["ୈ"] = "ไ%1", ["ୋ"] = "โ%1", ["ୌ"] = "เ%1า",
}
-- About fractions: http://www.unicode.org/L2/L2008/08199r-3471-oriyafractions.pdf
local numerator = { ["୲"] = 4, ["୳"] = 8, ["୴"] = 12, ["୵"] = 1, ["୶"] = 2, ["୷"] = 3, }
local fraction = {
{"1","16"}, {"1","8"}, {"3","16"}, {"1","4"}, {"5","16"}, {"3","8"}, {"7","16"}, {"1","2"},
{"9","16"}, {"5","8"}, {"11","16"}, {"3","4"}, {"13","16"}, {"7","8"}, {"15","16"},
}
function export.convertFraction(text)
local sum = 0
local c
for c in mw.ustring.gmatch(text, "[୲-୷]") do
sum = sum + numerator[c]
end
return mw.getCurrentFrame():expandTemplate{ title = "เศษ", args = fraction[sum] }
end
function export.tr(text, lang, sc, debug_mode)
if type(text) == "table" then -- called directly from a template
text = text.args[1]
end
for k, v in pairs(adjust0) do
text = gsub(text, k, v)
end
text = gsub(text, ".", tt)
-- แปลงเศษส่วน
text = gsub(text, "[୲-୷][୲-୷]?", export.convertFraction)
for k, v in pairs(adjust1) do
text = gsub(text, letter_with_mark..k, v)
end
text = gsub(text, "([เแไโ])อฺ", "อฺ%1")
-- ย้ายสัญลักษณ์ขึ้นบน เมื่อมีสระล่าง (ยกเว้นตัวที่ไม่มี)
text = gsub(text, u(0x0331).."([ุ-ฺ])", u(0x0304).."%1") -- macron below > macron above
return text
end
return export