FANDOM

!
19 Pages

local export = {}
local replace = mw.ustring.gsub
local match = mw.ustring.match
local split = mw.text.split
 
local function trim(text)
	text = mw.text.trim(text)
	text = replace(text, ' +$', '') -- don't remove U+3000 from the front of the string, it's sometimes used as indentation
	return text
end
 
function export.old(frame)
	local text = '\n' .. frame.args[1]
	text = replace(text, '\n', '\n|\n|-\n|')
	text = replace(text, '%|%-\n%|\n%|\n%|%-', '|-\n|<br />\n|-')
	text = replace(text, '^\n%|\n%|%-', '')
	return trim(text) .. '\n|\n\|}'
end
 
local vw_heads = {
	["ja"] = { "''Japanese'' (日本語歌詞)", "''Romaji'' (ローマ字)" },
	["zht"] = { "''Chinese'' (中文歌詞)", "''Pinyin'' (拼音)" },
	["zhs"] = { "''Chinese'' (中文歌词)", "''Pinyin'' (拼音)" },
	["ko"] = { "''Korean'' (한국어 가사)", "''Romaja'' (로마자)" },
	["yuet"] = { "''Cantonese'' (廣東話歌詞)", "''Jyutping'' (粵拼)" },
	["yues"] = { "''Cantonese'' (广东话歌词)", "''Jyutping'' (粤拼)" },
 
	["yue"] = { '<span class="error">Traditional (<code>yuet</code>) or simplified (<code>yues</code>)?</span>', '<span class="error">Traditional (<code>yuet</code>) or simplified (<code>yues</code>)?</span>' },
	["zh"] = { '<span class="error">Traditional (<code>zht</code>) or simplified (<code>zhs</code>)?</span>', '<span class="error">Traditional (<code>zht</code>) or simplified (<code>zhs</code>)?</span>' },
}
 
local ulw_heads = {
	["ja"] = { "{{ja}}", "{{ja-r}}" },
}
 
function export.show(frame)
	local wiki, lang, original, roman = frame.args[1], frame.args[2], frame.args[3], frame.args[4] or ''
	local text = {}
 
	if wiki == 'vw' then
		table.insert(text, '{| style="width:100%"')
		table.insert(text, '! align=left |' .. vw_heads[lang][1])
		table.insert(text, '! align=left |' .. vw_heads[lang][2])
	elseif wiki == 'ulw' then
		table.insert(text, '{| class="lyrics"')
		table.insert(text, '! ' .. ulw_heads[lang][1])
		table.insert(text, '! ' .. ulw_heads[lang][2])
	end
 
	original = split(original, '\n')
	roman = split(roman, '\n') or {}
 
	for i = 1, #original, 1 do
		local original, roman = original[i], roman[i] or ''
 
		original = trim(original)
		roman = trim(roman)
 
		if original == '' and roman == '' then
			original = '<br>'
			roman = false
		elseif match(original, '^[^ぁ-ー㐀-鿕]+$') and (roman == '' or roman == original) then
			original = '{{shared}}|' .. original
			roman = false
		end
 
		original = '\n' .. '|' .. original
		roman = (roman and ('\n' .. '|' .. roman) or '')
 
		table.insert(text, '|-' .. original .. roman)
	end
 
	table.insert(text, '|}')
 
	return table.concat(text, '\n')
end
 
return export

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.