مۆدیوول:Lang

لە ئینسایکڵۆپیدیای ئازادی ویکیپیدیاوە
Jump to navigation Jump to search
Module documentation[view] [edit] [history] [purge]

This module exists primarily to provide correct html markup for non-English language text where that text is used in the English Wikipedia. It has a secondary purpose of providing correct visual rendering for this non-English text. The module was developed to consolidate processing for {{lang}}, the {{lang-??}} (most), and {{transl}} templates into a single source and to use a clearly defined data set extracted from international standards.

The module does not require the myriad {{ISO 639 name ??}} templates, {{Language with name}}, {{Language with name and transliteration}}, and {{transl}}. It provides error checking and reporting to ensure that the html rendered is correct for browsers and screen readers.

Other templates that get language name support from this module are:

{{native name}}
{{link language}}

Data set[دەستکاری]

The data set is specified in Module:Language/name/data and its included data modules:

language tag-and-name data
Module:Language/data/iana languages – from IANA language-subtag-registry file
Module:Language/data/ISO 639-3 – from sil.org UTF-8 Complete Code Tables Set
Module:Language/data/wp languages – sourcing for the data in this module is unknown
language script data
Module:Language/data/iana scripts – from IANA language-subtag-registry file
language region data
Module:Language/data/iana regions – from IANA language-subtag-registry file
language variant data
Module:Language/data/iana variants – from IANA language-subtag-registry file
suppressed-script data
Module:Language/data/iana suppressed scripts – from IANA language-subtag-registry file

The data set also includes supplementary data modules:

override and other non-standard data
Module:Lang/data – For example, when IANA disagrees with ISO 639-3 or when the standard language name is cumbersome or contains information not suitable for use in article space, the override table can hold that language information
Module:Lang/ISO 639 synonyms – maps three character ISO 639-2, -2T, -3 codes to two character ISO 639-1 codes – from Codes for the Representation of Names of Languages
Module:Lang/name to tag – reversed language tag-and-name data so that the language name is the key and the language tag is the value

Error messages and categorization[دەستکاری]

Mainspace articles that have errors are placed in appropriate error categories:

Category:lang and lang-xx template errors
Category:transl template errors

Maintenance categories:

Category:Lang and lang-xx code promoted to ISO 639-1

See also[دەستکاری]

MOS on foreign words:

داڕێژە:Slink

local p = 	{}
local lang= require('مۆدیوول:Lang/data')

function gsubname(temp,the)
	if the and the ~= ''
		then
			s = string.gsub(temp, " ", " ")
			s = "".. s
			fi = s 
		else
			fi = temp 
	end
	return fi
end

function LatnCyrl(code,al,number, returnnil)
	code = code:lower()
	number = (number or 0) +1
	e = string.sub(code, -5)     -- 5 from the end until the end
	s = string.gsub(code, e, '')
	d = p.getname(s, '',number)
	if d and d ~='' then
		if (e == '-latn' or e == '-cyrl' or e == '-arab')
			then
				if e == '-latn' then f = ' لاتینی'
				elseif e == '-cyrl' then f = ' کریلی'
				elseif e == '-arab' then f = ' عەرەبی'
				end
				  er = d ..  f
				  
			else
		end
	end
	if returnnil and returnnil ~= '' then co = '' else co = code end
	if not er then return co else return gsubname(er,al) end
end

function p.getcode(code)
	s = code
	s = string.gsub(code, ' ', '')
--	s = s:lower()
	for k, v in pairs(lang) do
		for i, r in pairs(v) do
			if (s == r or s == k)
				then 
					return v.name
			end
		end
	end
end

function p.getname(co, al, number, returnnil)
	number = (number or 0) + 1
	if number and number > 3 then return nil end
	if not co or co =='' then return '' end
	code = co  --:lower()
	code = string.gsub(co , ' ', '')--:lower()
	if code and code~= '' then
		val = p.getcode(code) 
		if val and val~= '' 
			then 
				fi = gsubname(val,al)
			else
				fi = LatnCyrl(code,al,number, returnnil)
		end
		end
	return fi
end

function goo(name)
	for ss, v in pairs(lang) do
		if (name == p.getname(ss, 't') or name == p.getname(ss , ''))
		then 
			return ss--frame:preprocess(ss)
		else
			for q, codee in pairs(v) do
				if (name == p.getname(codee, 't') or name == p.getname(codee, ''))
					then return codee
				elseif (name == p.getname(ss .. '-cyrl', 't') or name == p.getname(ss .. '-cyrl', ''))
					then return ss .. '-cyrl'
				elseif (name == p.getname(ss.. '-latn', 't') or  name == p.getname(ss.. '-latn', ''))
					then return ss.. '-latn'
				elseif (name == p.getname(ss.. '-arab', 't') or  name == p.getname(ss.. '-arab', ''))
					then return ss.. '-arab'
				end
			end
		end
	end
	
end

p['اسم لغة'] = function ( frame )
	local na = frame.args[1]
	if not na or na =='' then return '' end
	local code = p.getname(frame.args[1], frame.args[2], 0, frame.args['nil'])
	return frame:preprocess(code)
end

p['قالب رمز لغة'] = function ( frame )
	lange= frame.args[1]
	text = frame.args[2]
	local c = p.getname(frame.args[1], 't')
	if lange and lange ~= '' 
	then
	lange = string.gsub(lange, ' ', '')
	lange = lange:lower()
	textout =  mw.text.tag('span', {lang= lange}, text)
		local p = 'پۆل: ئەو پۆلانەی دەقی زمانی'
		if lange =='ar' or lange =='ara'
			then cate = '' 
			else
				cate = '[['.. p .. (c or lange) .. ']]'
		end
		return  textout .. cate
	else
		return ''
	end
end

p['رمز لغة'] = function ( frame )
	local na = frame.args[1]
		if na and na~= '' 
		then
			return goo(na) or goo(gsubname(na, 't'))
		else
			return ''
	end
end


p['قائمة'] = function ( frame )
	lang= require('مۆدیوول:Lang/data')
	for k, nam in pairs(lang) do
		for i, v in pairs(nam) do
			name= v.na 
		end
	end
	local list = mw.html.create("table")
	list:addClass("wikitable sortable collapsible")
	local head = list:tag("tr")
	head:tag("th"):wikitext("رمز")
	head:tag("th"):wikitext("تضمين قالب")
	head:tag("th"):wikitext("وصلة")
	head:tag("th"):wikitext("اسم")
	head:tag("th"):wikitext("التحويلات")
	for o, nam in pairs(lang) do
		local temp = nam.name-- or k
		local row = list:tag("tr")
		local oo = row:tag("td")
		local r = row:tag("td")
		local th = row:tag("td")
		local ss = row:tag("td")
		local rr = row:tag("td")
		local rsr = '{{اسم آيزو 639 ' .. o ..'}}'
		local er = '[[قالب:اسم آيزو 639 ' .. o ..']]'
		local dd = "\n[[زمان ".. temp .."]]"
		local ooo = 'زمانی ' .. gsubname(temp, 'r')
		oo:tag("span"):wikitext(er)
		r:tag("span"):wikitext(frame:preprocess(rsr))
		th:tag("span"):wikitext(dd)
		ss:tag("span"):wikitext(ooo)
			for k,v in pairs(nam) do
				local cc =  {}
						if v and v ~= '' then 
					  		u = v
					  	end
				rr:tag("code"):wikitext(u)
				rr:tag("span"):wikitext(' - ') 
			end
			end
	return list
end

return p