local export = {}
local gsub = mw.ustring.gsub
local match = mw.ustring.match
function export.tr(word, lang, sc)
word = gsub(word, "%<%/?r%>", "")
word = gsub(word, "%<%/?ruby%>", "")
-- remove hanja from (ex.) 사전(辭典) and 辭典(사전)
-- Hani regex is a reasonable subset of Hani from ],
-- last checked on 20220221
word = gsub(word, "%(+%)", "")
word = gsub(word, "%(*'''+'''*%)", "")
word = gsub(word, "+%((.-)%)", "%1")
-- transform em-dash to plain hyphen-minus
word = gsub(word, "—", "-")
if match(word, "^+$") then
return (gsub(word,
"", {
= "g", = "kk", = "ks", = "n", = "nj", = "nh", = "d", = "tt", = "l", = "lg",
= "lm", = "lb", = "ls", = "lt", = "lp", = "lh", = "m", = "b", = "pp", = "ps",
= "s", = "ss", = "'", = "j", = "jj", = "ch", = "k", = "t", = "p", = "h",
= "a", = "ae", = "ya", = "yae", = "eo", = "e", = "yeo",
= "ye", = "o", = "wa", = "wae", = "oe", = "yo", = "u",
= "wo", = "we", = "wi", = "yu", = "eu", = "ui", = "i" }
))
end
if not match(word, "+") then
return nil
end
local m_pron = require("Module:ko-pron")
local revised = m_pron.romanise(word, 2, {}, true)
if not revised then
return nil
end
if match(revised, "") then
revised = mw.ustring.upper(mw.ustring.sub(revised, 1, 1)) .. mw.ustring.sub(revised, 2, -1)
revised = gsub(revised, "() ()", "%1 ^%2")
revised = gsub(revised, "^%'%'%'", "'''^")
end
revised = gsub(revised, "()%-%'()", "%1-%2")
revised = gsub(revised, "%^%'%'%'", "'''^")
revised = gsub(revised, "%^%l", mw.ustring.upper)
revised = gsub(revised, '%^', '')
revised = gsub(revised, "%-'''%-", "'''-")
revised = gsub(revised, "%-%-", "-")
return revised
end
export.tr_revised = export.tr
return export