وحدة:Wikidata2/monolingualtext
المظهر
توثيق الوحدة [أنشئ] [محو الاختزان][استخدامات] [قوالب]
local p = {}
function p._main( datavalue, datatype, options )
fetchName = require('وحدة:لغات').getname
local lang_code = datavalue.value.language
local text = datavalue.value.text
local language = mw.language.fetchLanguageName(datavalue.value.language, 'ar')
local fa = fetchName(datavalue.value.language,'',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 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 datavalue.value.language == 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('{{رمز لغة واسمها|'..
datavalue.value.language ..'|'.. language2 .. '|'.. text ..'|na='.. laa .. '}}') -- valu ..' '..lange
else
return mw.getCurrentFrame():preprocess('{{رمز لغة|'..datavalue.value.language ..'|'.. 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('{{رمز لغة واسمها|'..
datavalue.value.language ..'|'.. language2 .. '|'.. text ..'|na='.. laa .. '}}') -- valu ..' '..lange
else
return mw.getCurrentFrame():preprocess('{{رمز لغة|'..datavalue.value.language ..'|'.. 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