יחידה:שפת קישור: הבדלים בין גרסאות בדף

מאין תקציר עריכה
מ 7 גרסאות של הדף wikipedia:he:יחידה:שפת_קישור יובאו
 
(4 גרסאות ביניים של 2 משתמשים אינן מוצגות)
שורה 3: שורה 3:
local function getLocalLangNameWithPrefix(langCodeOrLocalName)
local function getLocalLangNameWithPrefix(langCodeOrLocalName)
local localName = langCodeOrLocalName
local localName = langCodeOrLocalName
 
if not mw.ustring.match(langCodeOrLocalName, '[א-ת]+') then
if not mw.ustring.match(langCodeOrLocalName, '[א-ת]+') then
-- tanslate
-- tanslate
שורה 9: שורה 9:
localName = 'עברית'
localName = 'עברית'
else
else
localName = mw.language.fetchLanguageName(langCode, 'he')
localName = mw.language.fetchLanguageName(langCodeOrLocalName, 'he')
end
end
end
end
שורה 24: שורה 24:
local function render(frame)
local function render(frame)
local args = Arguments.getArgs(frame, { ['trim'] = true, ['removeBlanks'] = true })
local args = Arguments.getArgs(frame, { ['trim'] = true, ['removeBlanks'] = true })
-- TODO: consider to move to template style
local langs = {}
for _, v in pairs(args) do
table.insert(langs, getLocalLangNameWithPrefix(v))
end
if #langs == 0 then
table.insert(langs, 'ב{{{שפה}}}')
end
local templatestyles = frame:extensionTag{
local templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = 'יחידה:שפת קישור/styles.css' }
name = 'templatestyles', args = { src = 'יחידה:שפת קישור/styles.css' }
}
}
 
local res = '<span dir="rtl" class="languageicon">'
local res = '<span dir="rtl" class="languageicon">('.. mw.text.listToText( langs, ', ', ' ו' ) .. ')</span>' .. templatestyles
if #args == 0 then
args[1] = '{{{שפה}}}'
end
if #args == 1 then
res=res .. getLocalLangNameWithPrefix(code[1])
else
local translatedLangs = {}
for _, v in pairs(args) do
table.insert(translatedLangs, getLocalLangNameWithPrefix(v))
end
res = mw.text.listToText( translatedLangs, ', ', 'ו' )  
end
res = res .. '</span>' .. templatestyles
return res
return res
end
end