Module:Pagelanguage
Jump to navigation
Jump to search
[Create] Documentation
-- Support for {{Translation not complete}} template.
-- Based on Module:Langcode.
-- Could probably be merged with other language inferring code in the future.
local p = {} -- p stands for package
function p.langcode( frame )
local title = mw.title.new(frame.args[1])
local subjectspace = title.subjectNsText
if string.len(subjectspace) == 2 then
return string.lower(subjectspace) -- dedicated language namespace
end
local pos = string.find(title.text,':')
if pos == nil then
return 'en' -- assume English if no colon
end
local pseudonamespace = string.sub(title.text,1,pos-1)
local langcode = frame.args[pseudonamespace] -- language passed as argument
if langcode then
return langcode
else
return string.lower(pseudonamespace) -- pseudonamespace is language
end
end
return p