跳转到内容

模組:IPA symbol

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由Great Brightstar留言 | 贡献2013年11月21日 (四) 16:59 (移植 en:Module:IPA symbol编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)

local p, __output, args, data = {}, {}, {}, mw.loadData("Module:IPA symbol/data")
local id, output
 
__output.name = function() return data.correspondences[id]["name"] end
__output.wikipage = function() return data.correspondences[id]["wikipage"] end
__output.soundfile = function() return data.correspondences[id]["soundfile"] end
__output.type = function() return data.correspondences[id]["type"] end
 
local function html_error(message)
  if args.custom_error then
    return args.custom_error
  else
    return mw.ustring.format(
      '<strong class="error">错误使用{{[[Template:IPA symbol|IPA symbol]]}}:%s%s</strong>'
      ,message
      ,mw.title.getCurrentTitle().isContentPage and ("[[Category:需要注意的含有国际音标的页面|" .. (args[1] or "") .. "]]") or ""
     )
  end
end
 
function p.main(frame)
  -- all input is trimmed; accepted parameters are:
  --   name              description
  --   ====              ===========
  --   (1)               the input
  --   output            the output, one of: input; name; wikipage; soundfile; type
  --   custom_output     overwrite the output when input is empty
  --   custom_error      overwrite the error message
  for k, v in pairs(frame.args) do
    args[k] = v and mw.text.trim(v)
  end
 
  if not args[1] or args[1] == "" then return args.custom_output or "" end
 
  id = data.symbols[args[1]]
  if not id then return html_error('"' .. args[1] .. '" not found in list') end
 
  return  __output[args.output] and __output[args.output]() or html_error("No such output option")
end
 
return p