モジュール:Lan

2024 ppm 3 2024-03-05T15:03:09+00:00up 5 312024 (Ape.) 15:03時点におけるMkpoli (Ukoytak | isankep)によるwerson (1版 をインポートしました)
(差分) ← 古いwerson | 最新werson (差分) | Asir werson → (差分)

このモジュールについての説明文ページを モジュール:Lan/doc に作成できます

local l={}
local getArgs

local args
l.fallbackList={
	 ['zh']={'zh','zh-hans','zh-hant','zh-cn','zh-tw','zh-hk','zh-mo','zh-sg','zh-my'}
	,['zh-hans']={'zh-hans','zh-cn','zh-sg','zh-my','zh'}
	,['zh-hant']={'zh-hant','zh-tw','zh-hk','zh-mo','zh'}
	,['zh-cn']={'zh-cn','zh-hans','zh-sg','zh-my','zh'}
	,['zh-sg']={'zh-sg','zh-hans','zh-cn','zh-my','zh'}
	,['zh-my']={'zh-my','zh-hans','zh-cn','zh-sg','zh'}
	,['zh-tw']={'zh-tw','zh-hant','zh-hk','zh-mo','zh'}
	,['zh-hk']={'zh-hk','zh-hant','zh-mo','zh-tw','zh'}
	,['zh-mo']={'zh-mo','zh-hant','zh-hk','zh-tw','zh'}
}

function l._main(args, frame)
	local userlanguage=frame:callParserFunction{ name = 'int', args = {'Conversionname'} }
	--mw.message.new('Conversionname'):plain()
	local fallback=l.fallbackList[userlanguage]
	if fallback == nil then
		fallback=l.fallbackList['zh']
	end
	for _,langArgName in ipairs(fallback)  do
		if 	args[langArgName] ~= nil then
			return args[langArgName]
		end
	end
	return ''
end

function l.main(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	args = getArgs(frame, {parentFirst=true})
        return l._main(args, frame)
end

return l