Jump to content

Module:Hepburner: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
forgot to restore local
there we (actually) go :)
Line 1: Line 1:
require('strict');
require('strict');
-- Converts romanji input to modified hepburn, I recommend subst:ing
-- Converts romanji input to modified hepburn, I recommend subst:ing

local p = {}
-- standard long vowel patterns
-- standard long vowel patterns
local diacritics = {
local diacritics = {
Line 24: Line 24:
}
}


local p = {}
--input: 1:1 transliterated romanji
--input: 1:1 transliterated romanji
function p.toHepburn(frame, romanji)
function p.toHepburn(frame)
local romanji = frame.args[1]
for target, replacement in pairs(diacritics) do
for target, replacement in pairs(diacritics) do
romanji = romanji:gsub(target, replacement)
romanji = romanji:gsub(target, replacement)
end
end
return romanji
return romanji
end
end



Revision as of 14:54, 2 March 2024

require('strict');
-- Converts romanji input to modified hepburn, I recommend subst:ing

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

local p = {}
--input: 1:1 transliterated romanji
function p.toHepburn(frame)
		local romanji = frame.args[1]
		for target, replacement in pairs(diacritics) do
        	romanji = romanji:gsub(target, replacement) 
    end
    return romanji	
end

return p