Module:ko-translit: Difference between revisions

Created page with "local export = {} local gsub = mw.ustring.gsub local match = mw.ustring.match function export.tr(text, lang, sc) if (not text) or text == "" then return text end local HaniChars = require("Module:scripts").getByCode("Hani"):getCharacters() text = gsub(text, "%<%/?r[pt]%>", "") text = gsub(text, "%<%/?ruby%>", "") -- remove hanja from (ex.) 사전(辭典) and 辭典(사전) text = gsub(text, "%([" .. HaniChars .. "]+%)", "") text = gsub(text, "%([" .. HaniChars..."
 
m 1 revision imported
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
local export = {}
local export = {}
local gsub = mw.ustring.gsub
 
local match = mw.ustring.match
local m_str_utils = require("Module:string utilities")
 
local gsub = m_str_utils.gsub


function export.tr(text, lang, sc)
function export.tr(text, lang, sc)
Line 10: Line 12:
text = gsub(text, "%<%/?r[pt]%>", "")
text = gsub(text, "%<%/?r[pt]%>", "")
text = gsub(text, "%<%/?ruby%>", "")
text = gsub(text, "%<%/?ruby%>", "")
-- remove hanja from (ex.) 사전(辭典) and 辭典(사전)
-- remove hanja from (ex.) 사전(辭典) and 辭典(사전) and 온돌(溫突/溫堗)
text = gsub(text, "%([" .. HaniChars .. "]+%)", "")
text = gsub(text, "%([" .. HaniChars .. "/]+%)", "")
text = gsub(text, "%([" .. HaniChars .. "]*'''[" .. HaniChars .. "]+'''[" .. HaniChars .. "]*%)", "")
text = gsub(text, "%([" .. HaniChars .. "]*'''[" .. HaniChars .. "]+'''[" .. HaniChars .. "]*%)", "")
text = gsub(text, "[" .. HaniChars .. "]+%((.-)%)", "%1")
text = gsub(text, "[" .. HaniChars .. "]+%((.-)%)", "%1")
Line 24: Line 26:
return text and text
return text and text
:gsub("([A-Za-z])%-%'([A-Za-z])", "%1-%2")
:gsub("(%a)%-%'(%a)", "%1-%2")
:gsub("%-'''%-", "'''-")
:gsub("%-'''%-", "'''-")
:gsub("%-%-", "-")
:gsub("%-%-", "-")