ماژول:Wikidata2/monolingualtext

ویکی‌پدیا، آزادِ دانشنومه، جه

توضیحات این پودمان می‌تواند در ماژول:Wikidata2/monolingualtext/توضیحات قرار گیرد.

local p = {}

function p._main(datavalue, datatype, options)
	fetchName = require('ماژول:زوونون').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, 'mzn')
	local fa = fetchName(lang_code, '', 0, 'i')
	if not fa or fa == '' then
		language2 = language
	else
		language2 = fa
	end
	--mw.log('language2: ' .. language2)
	--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' or language2 == 'مازرونی' then
					--mw.log(' formatting:' .. options.formatting .. ',text:' .. text .. '.' )
					return text
				elseif options.showlang and options.showlang ~= '' then
					return mw.getCurrentFrame():preprocess('{{Lang|' ..
						lang_code .. '|' .. language2 .. '|' .. text .. '|na=' .. laa .. '}}'
					) -- valu  ..' '..lange
				else
					return mw.getCurrentFrame():preprocess('{{زوون کد|' .. lang_code .. '|' .. text .. '}}') --valu
				end
			end
		end
	else
		lange = '(' .. language .. ')'
		valu = mw.text.tag('span', {title = language}, text)
		if language2 == 'مازرونی' then
			return text
		elseif options.showlang and options.showlang ~= '' then
			return mw.getCurrentFrame():preprocess('{{Lang|' .. 
				lang_code .. '|' .. language2 .. '|' .. text .. '|na=' .. laa .. '}}'
			) -- valu  ..' '..lange
		else
			return mw.getCurrentFrame():preprocess('{{زوون کد|' .. 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