לדלג לתוכן

יחידה:שפת קישור

מתוך צפונות ויקי
גרסה מ־09:41, 3 ביוני 2023 מאת wikipedia:he>ערן (יצירת דף חדש)
(הבדל) → הגרסה הקודמת | הגרסה האחרונה (הבדל) | הגרסה הבאה ← (הבדל)

ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:שפת קישור/תיעוד

local Arguments = require( "Module:Arguments" )

local function getLocalLangNameWithPrefix(langCodeOrLocalName)
	local localName = langCodeOrLocalName
	
	if not mw.ustring.match(langCodeOrLocalName, '[א-ת]+') then
		-- tanslate
		if langCodeOrLocalName == 'iw' then -- legacy code for modern hebrew
			localName = 'עברית'
		else
			localName = mw.language.fetchLanguageName(langCode, 'he')
		end
	end
	
	-- add prefix
	if  mw.ustring.match(localName, '[א-ת]+') then
		return 'ב' .. localName
	else
		return 'ב־' .. localName
	end
end


local function render()
		local args = Arguments.getArgs(frame, { ['trim'] = true, ['removeBlanks'] = true })
		-- TODO: consider to move to template style
		local templatestyles = frame:extensionTag{
			name = 'templatestyles', args = { src = 'שפת קישור/styles.css' }
		}

		local res = '<span dir="rtl" class="languageicon">'
		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
end

return 	{
	['שפת קישור']=render
}