وحدة:Other uses
{{{1}}}
الغرض
تُستعمل هذه الوحدة لإظهار ملاحظة في أعلى المقالة تُحيل القارئ إلى صفحات أخرى تحمل الاسم نفسه أو قريبة منه. تعادل القالب قالب:قالب في ويكيبيديا الإنجليزية ({{Other uses}})، لكن النص فيها عربي بالكامل:
- «للاستخدامات الأخرى، انظر صفحة التوضيح.»**
طريقة الاستخدام
يمكن استدعاء الوحدة في القالب مباشرة، أو استعمالها يدويًا عبر:
{{#invoke:Other uses|otheruses}}
يُفضَّل عادة أن تُضمَّن في قالب باسم قالب:قالب ليسهُل على المحررين استعمالها.
---
الوسائط
الاستعمال الأساسي
{{#invoke:Other uses|otheruses}}
يعرض: > للاستخدامات الأخرى، انظر Other uses (توضيح).
---
تحديد صفحة توضيح مختلفة
{{#invoke:Other uses|otheruses|default=اسم الصفحة (توضيح)}}
الناتج: > للاستخدامات الأخرى، انظر اسم الصفحة (توضيح).
---
تحديد عدة صفحات
{{#invoke:Other uses|otheruses
| صفحة 1
| صفحة 2
| صفحة 3
}}
الناتج: > للاستخدامات الأخرى، انظر صفحة 1، صفحة 2 وصفحة 3.
---
صيغة "استخدامات أخرى لــ..."
يُستعمل النمط الثاني **otherX** لإضافة كلمة مخصَّصة بعد العبارة:
{{#invoke:Other uses|otherX|الأماكن
| مكان أ
| مكان ب
}}
الناتج: > لاستخدامات أخرى **الأماكن**، انظر مكان أ ومكان ب.
---
وسائط إضافية
|default=
— يحدّد صفحة التوضيح الافتراضية عند غياب وسائط رقمية.|disambiguator=
— يحدّد النص داخل القوسين في الصفحة الافتراضية (الافتراضي:توضيح
).|selfref=yes
— يستعمل التنسيق الخاص بالصفحات الذاتية (في النطاقات المساعدة أو التوثيقية).
---
ملاحظات تقنية
- الوحدة تمنع الروابط إلى الصفحة نفسها (self-link).
- تستعمل فواصل عربية «،» وحرف العطف «و».
- لا تعتمد على النصوص الإنجليزية من وحدة
Hatnote list
، بل تولّد العبارة كاملة بالعربية. - تعيد المخرَج عبر
mHatnote._hatnote
للحفاظ على تنسيق ملاحظات الرأس القياسي.
---
أمثلة
{{#invoke:Other uses|otheruses}}
{{#invoke:Other uses|otheruses|صفحة توضيح أخرى}}
{{#invoke:Other uses|otheruses|صفحة 1|صفحة 2|صفحة 3}}
{{#invoke:Other uses|otherX|الموسيقى|أغنية|ألبوم}}
يعطي:
- للاستخدامات الأخرى، انظر Other uses (توضيح).
- للاستخدامات الأخرى، انظر صفحة توضيح أخرى.
- للاستخدامات الأخرى، انظر صفحة 1، [[ص]()]()*
-- Module:Other uses (Arabic)
-- Produces Arabic hatnotes like:
-- "للاستخدامات الأخرى، انظر [[Example (توضيح)]]."
-- and: "لاستخدامات أخرى الأماكن، انظر [[A]]، [[B]] و [[C]]."
local mHatnote = require('Module:Hatnote')
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local mArguments -- lazy
local mTableTools -- lazy
local p = {}
----------------------------------------------------------------
-- Helpers
----------------------------------------------------------------
-- Wrap a page/title string in [[...]] unless it's already linked
local function makeLink(s)
if type(s) ~= 'string' or s == '' then
return nil
end
if s:find('%[%[') then
return s
end
return string.format('[[%s]]', s)
end
-- Arabic joiner: "A"، "B و C" / "A، B و C"
local function joinArabic(list)
local n = #list
if n == 0 then
return ''
elseif n == 1 then
return list[1]
elseif n == 2 then
return list[1] .. ' و ' .. list[2]
else
-- A، B، C و D
local parts = {}
for i = 1, n - 1 do
table.insert(parts, list[i])
end
return table.concat(parts, '، ') .. ' و ' .. list[n]
end
end
-- Build default disambiguation title: "Title (توضيح)" or with custom disambiguator
local function makeDefaultTarget(titleText, disambiguator)
disambiguator = (disambiguator and disambiguator ~= '') and disambiguator or 'توضيح'
return string.format('%s (%s)', titleText, disambiguator)
end
-- Filter out self-links and normalize to wikilinks
local function normalizeTargets(rawTargets, hereTitleObj)
local out = {}
for i = 1, #rawTargets do
local t = rawTargets[i]
if type(t) == 'string' and t ~= '' then
local tt = mw.title.new(t)
-- If it's a valid title and equals current page, skip (self-link guard)
if not (tt and tt.prefixedText == hereTitleObj.prefixedText) then
local link = makeLink(t)
if link then
table.insert(out, link)
end
end
end
end
return out
end
----------------------------------------------------------------
-- Public entry points
----------------------------------------------------------------
-- {{#invoke:Other uses|otheruses| [targets...] |default=... |disambiguator=... |selfref=yes }}
function p.otheruses(frame)
mArguments = mArguments or require('Module:Arguments')
mTableTools = mTableTools or require('Module:TableTools')
local raw = mArguments.getArgs(frame)
local args = mTableTools.compressSparseArray(raw)
local options = {
title = mw.title.getCurrentTitle().prefixedText,
disambiguator = raw.disambiguator,
defaultPage = raw.default,
selfref = (raw.selfref == 'yes' or raw.selfref == 'true')
}
return p._otheruses(args, options)
end
-- {{#invoke:Other uses|otherX|نص| [targets...] |default=... |disambiguator=... |selfref=yes }}
-- Produces: "لاستخدامات أخرى <نص>، انظر ..."
function p.otherX(frame)
mArguments = mArguments or require('Module:Arguments')
mTableTools = mTableTools or require('Module:TableTools')
local x = frame.args[1]
local raw = mArguments.getArgs(frame, { parentOnly = true })
local args = mTableTools.compressSparseArray(raw)
local options = {
title = mw.title.getCurrentTitle().prefixedText,
otherText = x,
disambiguator = raw.disambiguator,
defaultPage = raw.default,
selfref = (raw.selfref == 'yes' or raw.selfref == 'true')
}
return p._otheruses(args, options)
end
----------------------------------------------------------------
-- Core
----------------------------------------------------------------
function p._otheruses(args, options)
checkType('_otheruses', 1, args, 'table', true)
args = args or {}
checkType('_otheruses', 2, options, 'table')
-- Determine if any numeric args (targets) were passed
local hasNumeric = false
for k in pairs(args) do
if type(k) == 'number' then
hasNumeric = true
break
end
end
local here = mw.title.getCurrentTitle()
-- If none, fall back to a single default disambiguation page
if not hasNumeric then
local fallback = options.defaultPage or makeDefaultTarget(
options.title or here.prefixedText,
options.disambiguator
)
args = { fallback }
end
-- Normalize and filter self-links
local targets = normalizeTargets(args, here)
-- If nothing remains, produce no hatnote
if #targets == 0 then
return ''
end
-- Build Arabic heading phrase
-- Base: "للاستخدامات الأخرى"
-- If otherText is present: "لاستخدامات أخرى <otherText>"
local lead
if options.otherText and options.otherText ~= '' then
lead = 'لاستخدامات أخرى ' .. options.otherText
else
lead = 'للاستخدامات الأخرى'
end
-- Join target links with Arabic punctuation/conjunctions
local pagesText = joinArabic(targets)
-- Final Arabic sentence (no trailing period per common AR hatnote style)
local text = string.format('%s، انظر %s', lead, pagesText)
return mHatnote._hatnote(text, { selfref = options.selfref == true })
end
return p