پودمان:Citation/lang
local p = {}
local types = {
["book_en"] = 'book',
["book_fa"] = 'کتاب',
["web_en"] = 'web',
["web_fa"] = 'وب',
["cite_en"] = 'Citation',
["cite_fa"] = 'یادکرد/هسته پودمان',
["journal_en"] = 'journal',
["journal_fa"] = 'ژورنال',
["encyclopedia_en"] = 'encyclopedia',
["encyclopedia_fa"] = 'دانشنامه',
["podcast_en"] = 'podcast',
["podcast_fa"] = 'پادکست',
["news_en"] = 'news',
["news_fa"] = 'خبر',
["magazine_en"] = 'magazine',
["magazine_fa"] = 'مجله',
["interview_en"] = 'interview',
["interview_fa"] = 'مصاحبه',
["arxiv_en"] = 'arXiv',
["arxiv_fa"] = 'آرکایو',
["av_en"] = 'AV media',
["av_fa"] = 'ویدئو',
["conference_en"] = 'conference',
["conference_fa"] = 'کنفرانس',
["map_en"] = 'map',
["map_fa"] = 'نقشه',
};
function getlangcode(lang) -- get the code of the language if full language name is given
if 3 < lang:len() then
local languages = mw.loadData('پودمان:Citation/lang/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 = { ['fa'] =true, ['fa-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_fa"]
else
return "یادکرد "..types[cite_type.."_fa"].."/هسته"
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_fa"]
else
return "یادکرد "..types[cite_type.."_fa"].."/هسته"
end
else
if cite_type == "cite" then
return types["cite_en"]
else
return "Cite "..types[cite_type.."_en"]
end
end
end
]]
return p