置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:Nihongo title

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
  1. local p = {}
  2. local getArgs = require('Module:Arguments').getArgs
  3. local yesno = require('Module:Yesno')
  4. local function varCase(t)
  5. local case = 'CHT'
  6. if t.cn == '' or t.tw == '' then
  7. case = ''
  8. elseif t.hk == '' or t.hk == 'tw' or t.hk == t.tw then
  9. case = 'CTT'
  10. elseif t.hk == 'cn' or t.hk == t.cn then
  11. case = 'CCT'
  12. elseif t.tw == 'cn' or t.tw == t.cn then
  13. case = 'CHC'
  14. elseif t.cn == 'tw' or t.cn == t.tw then
  15. case = 'THT'
  16. end
  17. return case
  18. end
  19. local function chi(t)
  20. local ret = ''
  21. local lang = ''
  22. local case = varCase(t)
  23. local list = {
  24. {'C', "中国大陆", t.cn},
  25. {'H', "香港", t.hk},
  26. {'T', "台湾", t.tw},
  27. {'CH', "中国大陆和香港", t.cn},
  28. {'HT', "香港和台湾", t.tw},
  29. {'CT', "中国大陆和台湾", t.cn},
  30. {'CT2', "中国大陆和台湾", t.tw},
  31. }
  32. local varTag = {}
  33. for i, v in ipairs(list) do
  34. if v[3] == "en" then
  35. varTag[v[1]] = v[2] .. "使用英文"
  36. else
  37. varTag[v[1]] = v[2] .. "译作“'''" .. v[3] .. "'''”"
  38. end
  39. end
  40. if case == '' then
  41. return ''
  42. elseif case == 'CHT' then
  43. lang = varTag.C .. ',' .. varTag.H .. ',' .. varTag.T
  44. elseif case == 'CTT' then
  45. lang = varTag.C .. ',' .. varTag.HT
  46. elseif case == 'CCT' then
  47. lang = varTag.CH .. ',' .. varTag.T
  48. elseif case == 'CHC' then
  49. lang = varTag.CT .. ',' .. varTag.H
  50. elseif case == 'THT' then
  51. lang = varTag.CT2 .. ',' .. varTag.H
  52. end
  53. return lang
  54. end
  55. local function link(cont)
  56. if yesno(_link, true) then
  57. if yesno(_lead) then
  58. cont = '[[' .. cont .. ']]'
  59. end
  60. cont = cont .. ':'
  61. else
  62. cont = ''
  63. end
  64. return cont
  65. end
  66. function p.nihongo_title(frame)
  67. local ret
  68. local _ret
  69. local args = getArgs(frame, {
  70. frameOnly= true;
  71. valueFunc = function (key, value)
  72. if value == nil and value ~= 'no' then
  73. return ''
  74. else
  75. return value
  76. end
  77. end;
  78. })
  79. _link = args.link
  80. _lead = args.lead
  81. if args[1] ~= '' and args[2] ~= '' then
  82. ret = "《'''" .. args[1] .. "'''》" .. '(' .. link('日语') .. "{{lj|'''" .. args[2] .. "'''}}"
  83. if args[3] ~= '' then
  84. ret = ret .. ',' .. link('英语') .. "{{lang|en|'''''" .. args[3] .. "'''''}}"
  85. end
  86. if args.cn ~= '' and args.tw ~= '' then
  87. ret = ret .. ',' .. chi(args)
  88. end
  89. if args[4] ~= '' then
  90. ret = ret .. ',' .. args[4]
  91. end
  92. ret = ret .. ')'
  93. if args[5] ~= '' then
  94. ret = ret .. args[5]
  95. end
  96. end
  97. return ret
  98. end
  99. return p