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

وحدة:استشهاد مختصر

Перевод выполнен человеком

يمكن إنشاء صفحة توثيق الوحدة في وحدة:استشهاد مختصر/شرح

local mCitation = {}

function mCitation.main(frame)
    -- الحصول على المتغيرات تلقائيًا
    local lang = frame.args["لغة"] or "ar"  -- جعل اللغة العربية هي الافتراضية
    local volume = frame.args["ج"] or frame.args["مجلد"] or frame.args["المجلد"] or ""
    local page = frame.args["ص"] or frame.args["صفحة"] or frame.args["الصفحة"] or ""
    local plate = frame.args["لوحة"] or ""
    local chapter = frame.args["فصل"] or ""
    local section = frame.args["قسم"] or ""
    local text = frame.args["نص"] or ""
    local author1 = frame.args[1] or ""
    local author2 = frame.args[2] or ""

    -- التحقق من وجود مؤلفين
    if author1 == "" then
        return "خطأ: يجب تحديد المؤلف الأول."
    end

    -- بناء النص باستخدام قالب تقليم وCITEREF
    local result = "[[#" .. "CITEREF" .. frame:expandTemplate{ title = "تقليم", args = { author1 } }
    if author2 ~= "" then
        result = result .. frame:expandTemplate{ title = "تقليم", args = { author2 } }
    end
    result = result .. "|" .. frame:expandTemplate{ title = "تقليم", args = { author1 } }
    if author2 ~= "" then
        result = result .. " (" .. frame:expandTemplate{ title = "تقليم", args = { author2 } } .. ")"
    end
    result = result .. "]]"

    -- تعيين التسميات حسب اللغة
    local volume_label, page_label, chapter_label, section_label, plate_label, separator

    if lang == "en" then        -- الإنجليزية
        volume_label = "vol."
        page_label = "p."
        chapter_label = "chapt."
        section_label = "sect."
        plate_label = "pla."
        separator = ", "
    elseif lang == "es" then    -- الإسبانية
        volume_label = "vol."
        page_label = "pág."
        chapter_label = "cap."
        section_label = "secc."
        plate_label = "lám."
        separator = ", "
    elseif lang == "ru" then    -- الروسية
        volume_label = "т."
        page_label = "с."
        chapter_label = "гл."
        section_label = "разд."
        plate_label = "табл."
        separator = ", "
    elseif lang == "fr" then    -- الفرنسية
        volume_label = "vol."
        page_label = "p."
        chapter_label = "chap."
        section_label = "sect."
        plate_label = "pla."
        separator = ", "
    elseif lang == "pt" then   -- البرتغالية
        volume_label = "vol."
        page_label = "p."
        chapter_label = "cap."
        section_label = "seç."
        plate_label = "pra."
        separator = ", "
    elseif lang == "tr" then      -- التركية
        volume_label = "der."
        page_label = "s."
        chapter_label = "böl."
        section_label = "kıs."
        plate_label = "lev."
        separator = ", "
    elseif lang == "hr" then      -- الكرواتية
         volume_label = "sv."
         page_label = "str."
         chapter_label = "pogl."
         section_label = "sek."
         plate_label = "bog"
         separator = ", "
    elseif lang == "la" then      -- اللاتينية
         volume_label = "vol."
         page_label = "p."
         chapter_label = "cap."
         section_label = "sect."
         plate_label = "tab."
         separator = ", "
    elseif lang == "de" then     -- الألمانية
        volume_label = "Bd."
        page_label = "s."
        chapter_label = "Kap."
        section_label = "Abs."
        plate_label = "Taf."
        separator = ", "
    else
        -- اللغة الافتراضية هي العربية
        volume_label = "ج."
        page_label = "ص."
        chapter_label = "الفصل"
        section_label = "القسم"
        plate_label = "لوحة"
        separator = "، "
    end

    -- بناء النص حسب وجود لوحة أو صفحة
    if volume ~= "" then result = result .. separator .. volume_label .. " " .. volume end
    
    -- إذا كان وسيط اللوحة موجودًا، استخدمه وإلا استخدم وسيط الصفحة
    if plate ~= "" then
        result = result .. separator .. plate_label .. " " .. plate
    elseif page ~= "" then
        result = result .. separator .. page_label .. " " .. page
    end

    if chapter ~= "" then
        result = result .. separator .. chapter_label .. " " .. chapter
        if section ~= "" then result = result .. separator .. section_label .. " " .. section end
    end

    if text ~= "" then result = result .. separator .. text end

    result = result .. "."
    return result
end

return mCitation