לדלג לתוכן

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

מתוך צפונות ויקי
יצירת דף חדש
 
מאין תקציר עריכה
שורה 22: שורה 22:




local function render()
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
-- TODO: consider to move to template style

גרסה מ־09:42, 3 ביוני 2023

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

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(frame)
		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
}