بۆ ناوەڕۆک بازبدە

مۆدیوول:Wikidata2/monolingualtext

لە ئینسایکڵۆپیدیای ئازادی ویکیپیدیاوە
بەڵگەدارکردنی مۆدیوول[دروست بکە]
local p = {}

function p._main( datavalue, datatype, options )
	fetchName = require('مۆدیوول:Lang').getname
	local lang_code = datavalue.value.language
	--mw.log("lang_code: " .. lang_code)
	local text = datavalue.value.text
	local language = mw.language.fetchLanguageName(lang_code, 'ckb')
	local fa = fetchName(lang_code,'',0,'i')
	if not fa or fa =='' 
		then language2 =language
		else language2 =fa
	end
	--if(options.langpref and options.property ) then
	--mw.log(" langpref:" .. options.langpref .. ",prop:" .. options.property .. ",lang_code:" .. lang_code .. "." )
	--end

	if lang_code == "mis" then -- Unsupported language
		return text
	end
	if not fa or fa =='' then laa= language2 else laa='' end
	if options.langpref and options.langpref ~= '' then
		if options.langpref =='justlang' then return language
		elseif options.langpref =='langcode' then return lang_code
		else
			if lang_code == options.langpref then
				--mw.log(" langpref:" .. options.langpref .. ",prop:" .. options.property .. ",lang_code:" .. lang_code .. "." )
				valu  = mw.text.tag('span', {title = language}, text)
				lange = '('.. language..')'
				if options.formatting and options.formatting == "text" then
					--mw.log(" formatting:" .. options.formatting .. ",text:" .. text .. "." )
					return text
				elseif options.showlang and options.showlang ~= '' then 
					return mw.getCurrentFrame():preprocess('{{زمان لەگەڵ ناو|'..
		 										lang_code ..'|'.. language2 .. '|'.. text ..'|na='.. laa .. '}}') -- valu  ..' '..lange
				else 
					return mw.getCurrentFrame():preprocess('{{Lang|'..lang_code ..'|'.. text ..'}}') --valu
				end
			end
		end
		
	else 
		lange = '('.. language..')'
		valu = mw.text.tag('span', {title = language},  text)
		if options.showlang and options.showlang ~= '' then
			return mw.getCurrentFrame():preprocess('{{زمان لەگەڵ ناو|'..
			 										lang_code ..'|'.. language2 .. '|'.. text ..'|na='.. laa .. '}}') -- valu  ..' '..lange
		else
			return mw.getCurrentFrame():preprocess('{{Lang|'..lang_code ..'|'.. text ..'}}') --valu
		end
	end
end
function p.main( Frame )
	return p._main( {language=frame.args['language'], text=frame.args['text'], }, frame.args['datatype'], frame.args )
end
return p