מייבאים כמותיים, בדוקי עריכות אוטומטית, ביוראקראטן, אינטערפעיס רעדאקטארן, emailconfirmed, אינטערפעיס אדמיניסטראַטאָרן, מנטרים, סיסאפן, צוות טכני, מייבאים, מעדכנים, אספקלריה רעדאקטארן
102,362
רעדאגירונגען
אין תקציר עריכה |
(זאל שוין זיין אלע) |
||
(6 מיטלסטע ווערסיעס פון 2 באַניצער נישט געוויזן.) | |||
שורה 1: | שורה 1: | ||
function | local p = {} | ||
frame | local c = "" | ||
local numberstable = { | |||
["א"] = 1, ["ב"] = 2, ["ג"] = 3, ["ד"] = 4, ["ה"] = 5, | |||
["ו"] = 6, ["ז"] = 7, ["ח"] = 8, ["ט"] = 9, ["י"] = 10, | |||
["כ"] = 20, ["ל"] = 30, ["מ"] = 40, ["נ"] = 50, ["ס"] = 60, | |||
["ע"] = 70, ["פ"] = 80, ["צ"] = 90, ["ק"] = 100, ["ר"] = 200, | |||
["ש"] = 300, ["ת"] = 400, ["תק"] = 500, ["תר"] = 600, | |||
["תש"] = 700, ["תת"] = 800} | |||
local function len1(s) | |||
if (s == nil) then | |||
return 0 end | |||
return mw.ustring.len(s) | |||
end | |||
local function sub1(str, from, to) | |||
return mw.ustring.sub(str, from, to) | |||
end | |||
local function find1(str, what, where) | |||
return mw.ustring.find(str, what, where, true) or 0 | |||
end | |||
local function aserror(message) | |||
error(c .. message, 0) | |||
end | |||
local function fromheb(num) | |||
local ans = 0 | |||
local str = num | |||
while len1(str) > 0 do | |||
if mw.ustring.byte(sub1(str, 1, 1)) == 226 | |||
then aserror("יש להקליד את כל התבנית מחדש") end | |||
if numberstable[sub1(str, 1, 1)] == nil | |||
then if sub1(str, 1, 1) == " " | |||
then aserror("רווח מיותר בתוך פרמטר " .. sub1(str, 1, 1)) | |||
else aserror("אות עברית לא ידועה " .. sub1(str, 1, 1)) end end | |||
--mw.ustring.byte(sub1(str, 1, 1)).." ".. mw.ustring.byte("ב")) | |||
ans = ans + numberstable[sub1(str, 1, 1)] | |||
str = sub1(str, 2, len1(str)) | |||
end | |||
return ans | |||
end | |||
local function tohebdigit(digit) | |||
if digit == 0 | |||
then return "" end | |||
for d, dd in pairs(numberstable) do | |||
if digit == dd | |||
then return d end | |||
end | |||
aserror("ספרה" .. digit .. "לא נמצאה") | |||
end | |||
local function toheb(num) | |||
if num > 899 | |||
then aserror("המספר " .. num .. " גדול מדי") end | |||
local third = num % 10 | |||
local second = (((num - third) / 10) % 10) * 10 | |||
local first = num - third - second | |||
local firstdigit = tohebdigit(first) | |||
local seconddigit = tohebdigit(second) | |||
local thirddigit = tohebdigit(third) | |||
if second == 10 and third == 5 | |||
then seconddigit = "ט" | |||
thirddigit = "ו" end | |||
if second == 10 and third == 6 | |||
then seconddigit = "ט" | |||
thirddigit = "ז" end | |||
return firstdigit .. seconddigit .. thirddigit | |||
end | |||
local function inArray(array, x) | |||
for _, v in ipairs(array) do | |||
if v == x then | |||
return true | |||
end | |||
end | |||
return false | |||
end | |||
local unordered = {"ער", "ערב", "ערד", "ערה", "רחצ", "דש", "שדמ", "עתר", "תערב", "תערד", "תרחצ", "תשדמ"} | |||
local function checknum(hnum) | |||
if toheb(fromheb(hnum)) == hnum or inArray(unordered, hnum) | |||
then return fromheb(hnum) end | |||
aserror("מספר עברי " .. hnum .. " לא מוכר") | |||
end | |||
local function checkbook(book) | |||
bookname = book | |||
local ans = 0 | |||
local str = book | |||
while len1(str) > 0 do | |||
if mw.ustring.byte(sub1(str, 1, 1)) == 226 | |||
then aserror("יש להקליד את כל התבנית מחדש") end | |||
str = sub1(str, 2, len1(str)) | |||
end | |||
for r, rr in pairs(renames) do | |||
if r == book | |||
then book = rr end | |||
end | |||
for n, nn in pairs(names) do | |||
if nn == book | |||
then return n end | |||
end | |||
if 1 == find1(book, syntax["book"] .. " ") | |||
then aserror('יש להשמיט את מילה "' .. syntax["book"] .. '" מתוך הפרמטר') end | |||
if suggestions[book] ~= nil | |||
then aserror("נישטא קיין " .. syntax["book"] .. " " .. bookname .. | |||
", האם הכוונה היא ל" .. suggestions[book] .. "?") end | |||
aserror("נישטא קיין " .. syntax["book"] .. " " .. book) | |||
end | |||
function p.main(frame) | |||
if mw.title.getCurrentTitle()["namespace"] == 3 -- no user conversation namespace | if mw.title.getCurrentTitle()["namespace"] == 3 -- no user conversation namespace | ||
then return end | then return end | ||
שורה 19: | שורה 134: | ||
c = c .. " (ביים רופן [[מוסטער:" .. frame.args["type"] .. "]]) " | c = c .. " (ביים רופן [[מוסטער:" .. frame.args["type"] .. "]]) " | ||
fpar = frame.args["par"] or "" | fpar = frame.args["par"] or "" | ||
fpar = string.gsub(fpar, "['\"]", "") | |||
fpar1 = frame.args["par1"] or "" | fpar1 = frame.args["par1"] or "" | ||
fpar1 = string.gsub(fpar1, "['\"]", "") | |||
if frame.args["book"] == nil or frame.args["book"] == "" | if frame.args["book"] == nil or frame.args["book"] == "" | ||
then aserror("פעלט נאמען פון " .. syntax["book"]) end | then aserror("פעלט נאמען פון " .. syntax["book"]) end | ||
שורה 26: | שורה 143: | ||
local book = checkbook(frame.args["book"]) | local book = checkbook(frame.args["book"]) | ||
local bookdata = data[book] | local bookdata = data[book] | ||
--[[ | |||
if find1(frame.args["chapter"] .. fpar .. fpar1, '"') > 0 | if find1(frame.args["chapter"] .. fpar .. fpar1, '"') > 0 | ||
or find1(frame.args["chapter"] .. fpar .. fpar1, "'") > 0 | or find1(frame.args["chapter"] .. fpar .. fpar1, "'") > 0 | ||
then aserror("יש להוריד את כל סימני ' " .. 'או " מתוך הפרמטרים') end | then aserror("יש להוריד את כל סימני ' " .. 'או " מתוך הפרמטרים') end | ||
]] | |||
if find1(frame.args["chapter"], '-') > 0 | if find1(frame.args["chapter"], '-') > 0 | ||
then aserror("יש לציין מספר " .. syntax["chapter"] .. " אחד בלבד, ניתן להפריד באמצעות |") end | then aserror("יש לציין מספר " .. syntax["chapter"] .. " אחד בלבד, ניתן להפריד באמצעות |") end | ||
if find1(fpar .. fpar1, '-') > 0 | if find1(fpar .. fpar1, '-') > 0 | ||
then aserror("יש לציין מספר ".. syntax["par"] .. " אחד בלבד בכל פרמטר, ניתן להפריד באמצעות |") end | then aserror("יש לציין מספר ".. syntax["par"] .. " אחד בלבד בכל פרמטר, ניתן להפריד באמצעות |") end | ||
frame.args["chapter"] = string.gsub(frame.args["chapter"], "['\"]", "") | |||
local chapter = checknum(frame.args["chapter"]) | local chapter = checknum(frame.args["chapter"]) | ||
local par, par1 | local par, par1 | ||
שורה 50: | שורה 170: | ||
end | end | ||
if chapter > #bookdata | if chapter > #bookdata | ||
then aserror(" | then aserror("נישטא קיין " .. syntax["chapter"] .. " " .. frame.args["chapter"] | ||
.. " | .. " אין " .. syntax["book"] .. " " .. bookname) end | ||
if par > bookdata[chapter] and fpar ~= "" and frame.args["par"] ~= nil | if par > bookdata[chapter] and fpar ~= "" and frame.args["par"] ~= nil | ||
then aserror(" | then aserror("נישטא קיין " .. syntax["par"] .. " " .. fpar .. " אין " .. syntax["chapter"] .. " " .. | ||
frame.args["chapter"] .. " | frame.args["chapter"] .. " אין " .. syntax["book"] .. " " .. bookname) end | ||
if par1 > bookdata[chapter] and fpar1 ~= "" | if par1 > bookdata[chapter] and fpar1 ~= "" | ||
then aserror(" | then aserror("נישטא קיין " .. syntax["par"] .. " " .. fpar1 .. " אין " .. syntax["chapter"] .. " " .. | ||
frame.args["chapter"] .. " | frame.args["chapter"] .. " אין " .. syntax["book"] .. " " .. bookname) end | ||
if par1 == par and fpar1 ~= "" | if par1 == par and fpar1 ~= "" | ||
then aserror("שני הפרמטרים המציינים אותו מספר " .. syntax["par"]) end | then aserror("שני הפרמטרים המציינים אותו מספר " .. syntax["par"]) end | ||
שורה 77: | שורה 197: | ||
end | end | ||
return p | |||
רעדאגירונגען