此模块的文档可以在模块:Lang/doc创建

local p = {}
local tLang = mw.loadData('Module:Lang/data'); -- Get table of languages
local u = require('Module:Utility')
 
function p.getLang(sCode)
    if sCode then
      sCode = mw.text.trim(string.lower(sCode or ""))
      if (tLang[sCode]) then 
         sCode = tLang[sCode]
         return sCode
      end
    end
 
end
 
function p.lang(frame)
    local tArgs = u.getArgs(frame)
    if(tArgs and tArgs[1]) then
        local sCode = string.lower(tArgs[1])
        return p.getLang(sCode)
    end
end
 
function p.getLangCode(sArgLang)
    if not sArgLang then
        return
    end
 
    sArgLang = sArgLang:gsub("_"," ") 
    for sCode, sLang in  pairs( tLang ) do
        if sArgLang  and string.lower(sArgLang) == string.lower(sLang) then 
            return sCode
        end
    end
 
    --return 'unknown'
end
 
function p.getcode(frame) 
    local sArgLang = (u.getArgs(frame,true))
    if(sArgLang) then
        sArgLang = mw.text.trim(string.lower(sArgLang[1] or ""))
        return p.getLangCode(sArgLang)
    end
end
 
 
return p
除了特别提示,社区内容遵循CC-BY-SA授权协议。