956
次編輯
Economy666(留言 | 貢獻) 小 (Economy666移动页面Module:沙盒/Economy666/ConvertLink至Module:ConvertLink,不留重定向:done) |
Economy666(留言 | 貢獻) (优化) |
||
行 10: | 行 10: | ||
end | end | ||
end | end | ||
local NotJaArtist = {['旅人E']=''} | |||
function p.artistLink(artistName) | function p.artistLink(artistName) | ||
行 35: | 行 36: | ||
local cal = mw.loadJsonData 'Template:ComplexArtistsList.json' | local cal = mw.loadJsonData 'Template:ComplexArtistsList.json' | ||
local function formatJapaneseText(text) | local function formatJapaneseText(text) | ||
if NotJaArtist[text] then return text end | |||
return mw.ustring.gsub( | |||
text, '[一-龠ぁ-ゔァ-ヴー々〆〤ヶ]+', | |||
function(v) return ('<span lang="ja">-{%s}-</span>'):format(v) end | |||
) | |||
end | end | ||
local artist = '' | local artist = '' | ||
local artist_list = cal[string.gsub(artistName, ' ' , '')] | local artist_list = cal[artistName] or cal[string.gsub(artistName, ' ' , '')] | ||
if artist_list then | if artist_list then | ||
for _, data in ipairs(artist_list) do | for _, data in ipairs(artist_list) do | ||
local display_ja = formatJapaneseText(data.display) | local display_ja = formatJapaneseText(data.display) or nil | ||
if data.link then | if data.link then | ||
artist = artist .. link('曲师列表#' .. data.link, display_ja) | artist = artist .. (display_ja and link('曲师列表#' .. data.link, display_ja) or '') | ||
else | else | ||
artist = artist .. display_ja | artist = artist .. (display_ja or '') | ||
end | end | ||
end | end |
次編輯