Atenție!

Deși îndeplinește în mare parte același rol ca modulul din alte limbi, acest modul nu este o copie a modulului de la en.wp sau din altă parte. El este scris special pentru necesitățile Wikipediei în limba română și nu trebuie înlocuit cu implementarea din altă parte.

Modulul generează un element HTML span care are completat atributul semantic lang care identifică un text scris într-o altă limbă. El este folosit atât direct, prin formatul {{Lang}}, cât și din alte module.


local p = {}
local getArgs = require('Modul:Arguments').getArgs
local wikidata = require('Modul:Wikidata')

p.fromArgs = function(langISOcode, languageDir, langText, italic)
	local span = mw.html.create('span')
	span:attr('lang', langISOcode)
	span:attr('translate', 'no')
	if languageDir then span:attr('dir', languageDir) end
	if italic then span:css('font-style', 'italic') end
	span:wikitext(langText)
	return tostring(span)
end

p.fromFrame = function(frame)
	local args = getArgs(frame)
	local langId = args[1]
	local langISOCode = langId
	local languageRTL = args['rtl']
	local italic = true
	if mw.ustring.match(langId, 'Q?%d+') then
		langISOCode = wikidata.findOneValue('P218', langId) or wikidata.findOneValue('P219', langId) or wikidata.findOneValue('P305', langId)
		if languageAlphabets and languageAlphabets[1] then
			languageDirectionalities = wikidata.getBestEntityIdsList(languageAlphabets[1], 'P1406')
			if languageDirectionalities and languageDirectionalities[1] then
				languageRTL = (languageDirectionalities[1] == 7333457)
			end
		end
	end
	if args['italic'] == 'no' or args['italic'] == 'false' or args['italic'] == 'nu' then
		italic = false
	end
	
	return p.fromArgs(langISOCode, languageRTL and 'rtl', args[2], italic)
end

return p