Jump to content

Module:Hepburner

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by DarmaniLink (talk | contribs) at 13:54, 2 March 2024 (hepburner v1 - lazy implementation). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

-- Converts romanji input to modified hepburn, I recommend subst:ing
local p = {}

-- standard long vowel patterns
local diacritics = {
    ["aa"] = "ā",
    ["ii"] = "ī",
    ["uu"] = "ū",
    ["ee"] = "ē",
    ["oo"] = "ō",
    ["ou"] = "ō",
    ["Aa"] = "Ā",
    ["Ii"] = "Ī",
    ["Uu"] = "Ū",
    ["Ee"] = "Ē",
    ["Oo"] = "Ō",
    ["Ou"] = "Ō",
    ["AA"] = "Ā",
    ["II"] = "Ī",
    ["UU"] = "Ū",
    ["EE"] = "Ē",
    ["OO"] = "Ō",
    ["OU"] = "Ō"
}

--input: 1:1 transliterated romanji
function p.toHepburn(romanji) 
	for target, replacement in pairs(diacritics) do
        romanji = romanji:gsub(target, replacement) 
    end
    return romanji
end

return p