Module:Citation/lang
ښکارېدونکې بڼه
لاسوند لپاره ددې موډيول کېدای سی په Module:Citation/lang/لاسوند کي وي
local p = {}
local types = {
["book_en"] = 'book',
["book_ps"] = 'کتاب',
["web_en"] = 'web',
["web_ps"] = 'وېب',
["cite_en"] = 'Citation',
["cite_ps"] = 'سرچينه/پوښ چلندوال',
["journal_en"] = 'journal',
["journal_ps"] = 'ژورنال',
["encyclopedia_en"] = 'encyclopedia',
["encyclopedia_ps"] = 'پوهنغونډ',
["podcast_en"] = 'podcast',
["podcast_ps"] = 'پودکاسټ',
["news_en"] = 'news',
["news_ps"] = 'خبرونه',
["magazine_en"] = 'magazine',
["magazine_ps"] = 'مجله',
["interview_en"] = 'interview',
["interview_ps"] = 'مرکه',
["arxiv_en"] = 'arXiv',
["arxiv_ps"] = 'خونديځ',
["av_en"] = 'AV media',
["av_ps"] = 'وېډيو',
["conference_en"] = 'conference',
["conference_ps"] = 'کنفرانس',
["map_en"] = 'map',
["map_ps"] = 'نخچه',
};
function getlangcode(lang) -- get the code of the language if full language name is given
if 3 < lang:len() then
local languages = mw.loadData('Module:Language/data/ISO 639-1')
local langCode = languages[lang]
if langCode ~= nil then return langCode[1] end
else
return lang
end
end
--[[
function p.testlang(frame)
return getlangcode(frame.args['lang'])
end
]]
--[[
returns the citation template name based on the {{{ژبه}}} parameter
--]]
function p.is_rtl(frame)
cite_type = frame.args['type']; -- type of the citation template (book, web, etc.)
lang = mw.ustring.lower(frame.args['lang']) -- language code
lang_code = getlangcode(lang)
local rtl_langs = { ['ps'] =true, ['ps-IR'] =true, ['ar'] =true, ['ur'] =true, ['he'] =true, }
if lang_code == "" or lang_code == nil or rtl_langs[lang_code] then
if cite_type == "cite" then
return types["cite_ps"]
else
return "سرچينه "..types[cite_type.."_ps"].."/پوښ"
end
else
if cite_type == "cite" then
return types["cite_en"]
else
return "Cite "..types[cite_type.."_en"]
end
end
end
--[[
returns the citation template name based on the characters in title
--
function p.is_rtl2(frame)
cite_type = frame.args['type']; -- type of the citation template (book, web, etc.)
Title = frame.args['title']
if Title:match("[ابپتټثجچحخڅځدډذرزژږړسشښصضطظعغفقکگګلمنوهېئۍيی۱۲۳۴۵۶۷۸۹۰]+") then --که پښتو کرکترونه يې لرل
if cite_type == "cite" then
return types["cite_ps"]
else
return "سرچينه "..types[cite_type.."_ps"].."/پوښ"
end
else
if cite_type == "cite" then
return types["cite_en"]
else
return "Cite "..types[cite_type.."_en"]
end
end
end
]]
return p