Module:IsTranslation
Jump to navigation
Jump to search
Lua
CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules
Usage
[edit]Implements {{IsTranslation}} and {{GetLangcode}}.
local isTranslation = require('Module:IsTranslation')._isTranslation
{{#invoke:IsTranslation|isTranslation}}
local isTranslation = require('Module:IsTranslation').getLangCode
{{#invoke:IsTranslation|getLangCode}}
Code
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p._isTranslation(args)
local subpageName = string.lower(mw.title.getCurrentTitle().subpageText)
local langNames = mw.language.fetchLanguageNames()
if langNames[subpageName] then
return args[1]
else
return args[2]
end
end
function p.isTranslation(frame)
return p._isTranslation(getArgs(frame))
end
function p._getLangCode(args)
local subpageName = string.lower(mw.title.getCurrentTitle().subpageText)
local langNames = mw.language.fetchLanguageNames()
if langNames[subpageName] then
return subpageName
else
return args[1] or mw.language.getContentLanguage().code
end
end
function p.getLangCode(frame)
return p._getLangCode(getArgs(frame))
end
return p