Module:Hepburner: Difference between revisions
DarmaniLink (talk | contribs) forgot to restore local |
DarmaniLink (talk | contribs) 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 |
||
⚫ | |||
-- standard long vowel patterns |
-- standard long vowel patterns |
||
local diacritics = { |
local diacritics = { |
||
Line 24: | Line 24: | ||
} |
} |
||
⚫ | |||
--input: 1:1 transliterated romanji |
--input: 1:1 transliterated romanji |
||
function p.toHepburn(frame |
function p.toHepburn(frame) |
||
local romanji = frame.args[1] |
|||
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
Romanizes double vowels per the standard outlined in Hepburn Romanization.
Implemented in Template:Hepburn - Please use this instead of using this directly. It enforces subst for this *very* costly module.
Any double vowels will get converted to a long vowel, ou will get converted to ō.
{{#invoke:Hepburner|toHepburn|Kinou}} => Kinō
{{#invoke:Hepburner|toHepburn|Ooki}} => Ōki
{{#invoke:Hepburner|toHepburn|kara-age}} => kara-age
{{#invoke:Hepburner|toHepburn|sakkaa}} => sakkā
{{#invoke:Hepburner|toHepburn|raamen}} => rāmen
{{#invoke:Hepburner|toHepburn|ヴィデオ}} => ヴィデオ
{{#invoke:Hepburner|toHepburn|いこう}} => いこう
{{#invoke:Hepburner|toHepburn|やった}} => やった
{{#invoke:Hepburner|toHepburn|いきましょう}} => いきましょう
{{#invoke:Hepburner|toHepburn|ちゅうにびょう}} => ちゅうにびょう
{{#invoke:Hepburner|toHepburn|つづく}} => つづく
note: oU aA or the like will break it. You should never, ever, ever do this regardless, but note that is a limitation. If you need that, add it to the list, following the current pattern.
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