Module:Nihongo title
跳到导航
跳到搜索
- local p = {}
- local getArgs = require('Module:Arguments').getArgs
- local yesno = require('Module:Yesno')
- local function varCase(t)
- local case = 'CHT'
- if t.cn == '' or t.tw == '' then
- case = ''
- elseif t.hk == '' or t.hk == 'tw' or t.hk == t.tw then
- case = 'CTT'
- elseif t.hk == 'cn' or t.hk == t.cn then
- case = 'CCT'
- elseif t.tw == 'cn' or t.tw == t.cn then
- case = 'CHC'
- elseif t.cn == 'tw' or t.cn == t.tw then
- case = 'THT'
- end
- return case
- end
- local function chi(t)
- local ret = ''
- local lang = ''
- local case = varCase(t)
- local list = {
- {'C', "中国大陆", t.cn},
- {'H', "香港", t.hk},
- {'T', "台湾", t.tw},
- {'CH', "中国大陆和香港", t.cn},
- {'HT', "香港和台湾", t.tw},
- {'CT', "中国大陆和台湾", t.cn},
- {'CT2', "中国大陆和台湾", t.tw},
- }
- local varTag = {}
- for i, v in ipairs(list) do
- if v[3] == "en" then
- varTag[v[1]] = v[2] .. "使用英文"
- else
- varTag[v[1]] = v[2] .. "译作“'''" .. v[3] .. "'''”"
- end
- end
- if case == '' then
- return ''
- elseif case == 'CHT' then
- lang = varTag.C .. ',' .. varTag.H .. ',' .. varTag.T
- elseif case == 'CTT' then
- lang = varTag.C .. ',' .. varTag.HT
- elseif case == 'CCT' then
- lang = varTag.CH .. ',' .. varTag.T
- elseif case == 'CHC' then
- lang = varTag.CT .. ',' .. varTag.H
- elseif case == 'THT' then
- lang = varTag.CT2 .. ',' .. varTag.H
- end
- return lang
- end
- local function link(cont)
- if yesno(_link, true) then
- if yesno(_lead) then
- cont = '[[' .. cont .. ']]'
- end
- cont = cont .. ':'
- else
- cont = ''
- end
- return cont
- end
- function p.nihongo_title(frame)
- local ret
- local _ret
- local args = getArgs(frame, {
- frameOnly= true;
- valueFunc = function (key, value)
- if value == nil and value ~= 'no' then
- return ''
- else
- return value
- end
- end;
- })
- _link = args.link
- _lead = args.lead
- if args[1] ~= '' and args[2] ~= '' then
- ret = "《'''" .. args[1] .. "'''》" .. '(' .. link('日语') .. "{{lj|'''" .. args[2] .. "'''}}"
- if args[3] ~= '' then
- ret = ret .. ',' .. link('英语') .. "{{lang|en|'''''" .. args[3] .. "'''''}}"
- end
- if args.cn ~= '' and args.tw ~= '' then
- ret = ret .. ',' .. chi(args)
- end
- if args[4] ~= '' then
- ret = ret .. ',' .. args[4]
- end
- ret = ret .. ')'
- if args[5] ~= '' then
- ret = ret .. args[5]
- end
- end
- return ret
- end
- return p