الفرق بين الصفحتين: «وحدة:لغات» و«وحدة:لغات/ملعب»

(الفرق بين الصفحتين)
اذهب إلى التنقل اذهب إلى البحث
صفحة 1
صفحة 2
لا ملخص تعديل
 
لا ملخص تعديل
 
سطر 1: سطر 1:
local p = {}
local p = {}
local data = require("Module:لغات/بيانات")
local data = require('Module:لغات/بيانات/ملعب')
local scripts = {
local scripts = {
["-latn"] = " لاتينية",
['-latn'] = ' لاتينية' ,
["-cyrl"] = " سيريلية",
['-cyrl'] = ' سيريلية' ,
["-arab"] = " عربية"
['-arab'] = ' عربية' ,
}
}
local function isvalid(x)
if x and x ~= "" then
return x
end
return nil
end


local function gsubname(temp, the, code)
local function gsubname(temp , the , code)
local al = data.lang_name_with_al[code] or data.lang_name_with_al[code:lower()]
if data.lang_name_with_al[code] then
if al then
return data.lang_name_with_al[code]
return al
elseif data.lang_name_with_al[code:lower()] then
return data.lang_name_with_al[code:lower()]
end
end
if isvalid(the) then
local fi
return "ال" .. string.gsub(temp, " ", " ال")
if the and the ~= ''
then
local s = string.gsub(temp, " ", " ال")
s = "ال".. s
fi = s
else
fi = temp
end
end
return temp
return fi
end
end


local function LatnCyrl(code, al, number, returnnil)
local function LatnCyrl(code,al,number, returnnil)
local ar_name = ""
local ar_name = ""
code = code:lower()
code = code:lower()
number = (number or 0) + 1
number = (number or 0) +1
local e = string.sub(code, -5) -- 5 from the end until the end
local e = string.sub(code, -5)     -- 5 from the end until the end
local s = string.gsub(code, e, "")
local s = string.gsub(code, e, '')
local d = p.getname(s, "", number)
local d = p.getname(s , '' , number)
local co = "" and isvalid(returnnil) or code
if d and d ~='' then
 
if scripts[e] then
if isvalid(d) and scripts[e] then
ar_name = d .. scripts[e]
ar_name = d .. scripts[e]
end
end
local co
if returnnil and returnnil ~= '' then
co = ''
else
co = code
end
end
 
if ar_name == "" then  
if ar_name == "" then
return co
return co
else
return gsubname(ar_name , al , code)
end
end
return gsubname(ar_name, al, code)
end
end


function p.getcode(code)
function p.getcode(code)
local s = code
local s = code
s = string.gsub(code, " ", "")
s = string.gsub(code, ' ', '')
return data.lang_name[s] or data.lang_name[s:lower()] or data.lang_name_with_al[s:lower()]
return data.lang_name[s] or data.lang_name[s] or data.lang_name_with_al[s:lower()]
end
end


سطر 55: سطر 62:
function p.getname(code, al, number, returnnil)
function p.getname(code, al, number, returnnil)
number = (number or 0) + 1
number = (number or 0) + 1
if number and number > 3 then
if number and number > 3 then return nil end
return nil
if not code or code =='' then return '' end
end
if string.find(code,"[)|(]") then return code end
if not isvalid(code) then
code = string.gsub(code , ' ', '')--:lower()
return ""
end
if string.find(code, "[)|(]") then
return code
end
code = string.gsub(code, " ", "")
local fi
local fi
local name = p.get_name_from_code(code)
if code and code~= '' then
if isvalid(name) then
local name = p.get_name_from_code(code)  
fi = gsubname(name, al, code)
if name and name ~= ''
else
then  
fi = LatnCyrl(code, al, number, returnnil)
fi = gsubname(name , al , code)
else
fi = LatnCyrl(code,al,number, returnnil)
end
end
end
return fi
return fi
سطر 80: سطر 84:
end
end
for ss, v in pairs(data.lang_table) do
for ss, v in pairs(data.lang_table) do
if (name == p.getname(ss, "t") or name == p.getname(ss, "")) then
if (name == p.getname(ss, 't') or name == p.getname(ss , ''))
return ss
then  
return ss--frame:preprocess(ss)
else
else
for q, codee in pairs(v.codes) do
for q, codee in pairs( v.codes ) do
if (name == p.getname(codee, "t") or name == p.getname(codee, "")) then
if (name == p.getname(codee, 't') or name == p.getname(codee, ''))
return codee
then return codee
elseif (name == p.getname(ss .. "-cyrl", "t") or name == p.getname(ss .. "-cyrl", "")) then
elseif (name == p.getname(ss .. '-cyrl', 't') or name == p.getname(ss .. '-cyrl', ''))
return ss .. "-cyrl"
then return ss .. '-cyrl'
elseif (name == p.getname(ss .. "-latn", "t") or name == p.getname(ss .. "-latn", "")) then
elseif (name == p.getname(ss.. '-latn', 't') or name == p.getname(ss.. '-latn', ''))
return ss .. "-latn"
then return ss.. '-latn'
elseif (name == p.getname(ss .. "-arab", "t") or name == p.getname(ss .. "-arab", "")) then
elseif (name == p.getname(ss.. '-arab', 't') or name == p.getname(ss.. '-arab', ''))
return ss .. "-arab"
then return ss.. '-arab'
end
end
end
end
end
end
end
end
end
end


local function make_cat(lange)
p['اسم لغة'] = function ( frame )
if lange == "ar" or lange == "ara" then
return ""
end
local c = p.getname(lange, "t")
 
return "[[تصنيف:مقالات تحوي نصا ب" .. (c or lange) .. "]]"
end
 
p["اسم لغة"] = function(frame)
local na = frame.args[1]
local na = frame.args[1]
if not isvalid(na) then
if not na or na =='' then return '' end
return ""
local code = p.getname(frame.args[1], frame.args[2], 0, frame.args['nil'])
end
local code = p.getname(frame.args[1], frame.args[2], 0, frame.args["nil"])
return frame:preprocess(code)
return frame:preprocess(code)
end
end


p["قالب رمز لغة"] = function(frame)
p['قالب رمز لغة'] = function ( frame )
local lange = frame.args[1]
local lange= frame.args[1]
local text = frame.args[2]
local text = frame.args[2]
if not isvalid(lange) then
local c = p.getname(frame.args[1], 't')
return ""
if lange and lange ~= '' then
lange = string.gsub(lange, ' ', '')
lange = lange:lower()
local textout =  mw.text.tag('span', {lang= lange}, text)
local p = 'تصنيف:مقالات تحوي نصا ب'
local cate
if lange =='ar' or lange =='ara' then
cate = ''
else
cate = '[['.. p .. (c or lange) .. ']]'
end
return  textout .. cate
else
return ''
end
end
lange = string.gsub(lange, " ", "")
lange = lange:lower()
local textout = mw.text.tag("span", {lang = lange}, text)
local cate = make_cat(lange)
return textout .. cate
end
end


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


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


return p
return p