انتقل إلى المحتوى

وحدة:عدجمل

من ويكي مصدر، المكتبة الحرة
local je={
	["ء"] = 0,
	["أ"] = 1,
	["ا"] = 1,
	["إ"] = 1,
	["آ"] = 1,
	["ب"] = 2,
	["ج"] = 3,
	["د"] = 4,
	["ه"] = 5,
	["ة"] = 5,
	["و"] = 6,
	["ؤ"] = 6,
	["ز"] = 7,
	["ح"] = 8,
	["ط"] = 9,
	["ي"] = 10,
	["ى"] = 10,
	["ئ"] = 10,
	["ك"] = 20,
	["ل"] = 30,
	["م"] = 40,
	["ن"] = 50,
	["س"] = 60,
	["ع"] = 70,
	["ف"] = 80,
	["ص"] = 90,
	["ق"] = 100,
	["ر"] = 200,
	["ش"] = 300,
	["ت"] = 400,
	["ث"] = 500,
	["خ"] = 600,
	["ذ"] = 700,
	["ض"] = 800,
	["ظ"] = 900,
	["غ"] = 1000
}

local jw={
	["ء"] = 0,
    ["أ"] = 1,
    ["ا"] = 1,
    ["إ"] = 1,
    ["آ"] = 1,
    ["ب"] = 2,
    ["ج"] = 3,
    ["د"] = 4,
    ["ه"] = 5,
	["ة"] = 5,
    ["و"] = 6,
    ["ؤ"] = 6,
    ["ز"] = 7,
    ["ح"] = 8,
    ["ط"] = 9,
    ["ي"] = 10,
    ["ى"] = 10,
    ["ئ"] = 10,
    ["ك"] = 20,
    ["ل"] = 30,
    ["م"] = 40,
    ["ن"] = 50,
    ["ص"] = 60,
    ["ع"] = 70,
    ["ف"] = 80,
    ["ض"] = 90,
    ["ق"] = 100,
    ["ر"] = 200,
    ["س"] = 300,
    ["ت"] = 400,
    ["ث"] = 500,
    ["خ"] = 600,
    ["ذ"] = 700,
    ["ظ"] = 800,
    ["غ"] = 900,
    ["ش"] = 1000
}

local function main(frame)
    local txt = frame:getParent().args[1] or frame.args[1] or ''
    local magrib = (frame.args["مغربي"] or frame:getParent().args["مغربي"]) and true
    local j=magrib and jw or je
    local r_number=0
    for i =1,mw.ustring.len( txt ) do
        r_number=r_number + (j[mw.ustring.sub( txt, i, i )] or 0)
    end
    return '<span class="num-jml" title="' .. r_number .. '"' .. (color and (' style="color:' .. color .. ';">') or ">") .. txt .. "</span>"
end

return {
    main=main
}