モジュール:mnw-translit for japan
このモジュールについての説明文ページを モジュール:mnw-translit for japan/doc に作成できます
local export = {}
local gsub = mw.ustring.gsub
local u = mw.ustring.char
local letter_with_mark = "(.["..u(0x0300).."-"..u(0x036F).."]?)"
local pre = {
["ျ"] = "္ယ", ["ြ"] = "္ရ", ["ွ"] = "္ဝ", ["ှ"] = "္ဟ",
["ၞ"] = "္န", ["ၟ"] = "္မ", ["ၠ"] = "္လ",
}
local tt1 = {
-- consonants ; Unicode doesn't have exclusive great nya, that looks like ည with another curve, so use ည္ည as it should be.
["က"] = "カ", ["ခ"] = "カー", ["ဂ"] = "ガ", ["ဃ"] = "ガー", ["င"] = "ンガ", ["ၚ"] = "ンガ",
["စ"] = "チャ", ["ဆ"] = "チャー", ["ဇ"] = "ジャ", ["ၛ"] = "ジャー", ["ဉ"] = "ニャ", ["ည"] = "ニャー", -- ññ -> ñ later
["ဋ"] = "タ", ["ဌ"] = "ター", ["ဍ"] = "ダ", ["ဎ"] = "ダー", ["ဏ"] = "ナ",
["တ"] = "タ", ["ထ"] = "ター", ["ဒ"] = "ダ", ["ဓ"] = "ダ", ["န"] = "ナ",
["ပ"] = "パ", ["ဖ"] = "パー", ["ဗ"] = "バ", ["ဘ"] = "バー", ["မ"] = "マ",
["ယ"] = "ヤ", ["ရ"] = "ラ", ["လ"] = "ァー", ["ဝ"] = "ヴァ", ["သ"] = "サ", ["ဿ"] = "ッサ",
["ဟ"] = "ハ", ["ဠ"] = "ァ", ["ၜ"] = "パー", ["အ"] = "ア", ["ၝ"] = "パー",
-- independent vowels (1 char)
["ဣ"] = "イ", ["ဥ"] = "ウ",
["ဨ"] = "エー", ["ဩ"] = "オー",
-- dependent vowels and diacritics (1 char)
["ါ"] = "アー", ["ာ"] = "アー", ["ိ"] = "イ", ["ီ"] = "いー", ["ဳ"] = "イー", ["ု"] = "ウ", ["ူ"] = "ウー", ["ဲ"] = "アイ",
["ဴ"] = "あお", ["ေ"] = "エー", ["ဵ"] = "エー",
["ံ"] = "ン", ["း"] = "フ", ["္"] = "い", ["်"] = "¤",
-- punctuation 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)] = "‼", [u(0x200C)] = "‼", [u(0x200D)] = "‼",
}
local tt2 = {
-- vowels (2 chars)
["ဣဳ"] = "イー", ["ဥု"] = "ウー",
["ေါ"] = "お", ["ော"] = "お",
}
function export.tr(text, lang, sc, debug_mode)
if type(text) == "table" then -- called directly from a template
text = text.args[1]
end
text = gsub(text, ".", pre)
text = gsub(text, "ဲါ", "ါဲ") -- fixed ay+aa to aa+ay; it often occurs
for k, v in pairs(tt2) do
text = gsub(text, k, v)
end
text = gsub(text, ".", tt1)
text = gsub(text, "([aeiuoāīū])ʸ", "%1y")
text = gsub(text, "ᵃʸ", "oa")
text = gsub(text, "ᵃ([¡¤]+)", "")
text = gsub(text, "([aeiuoāīū])¤", "%1k")
text = gsub(text, "ᵃ([aeiuoāīū])", "%1")
text = gsub(text, "ᵃ", "a")
text = gsub(text, "iṃu", "iuṃ")
if lang == "mnw" then --Modern Mon
text = gsub(text, "ññ", "ñ")
end
return text
end
return export