Module:Translation
From the only original and legitimate Battlestar Wiki: the free-as-in-beer, non-corporate, open-content encyclopedia, analytical reference, and episode guide on all things Battlestar Galactica. Accept neither subpar substitutes nor subpar clones.
More actions
Documentation for this module may be created at Module:Translation/doc
local p = {}
function p.listLanguages(frame)
local parent = frame:getParent()
local title = mw.title.getCurrentTitle()
local basePage = title.fullText
-- Define your language mapping here
local langNames = {
de = "Deutsch",
fr = "Français",
zh = "中文",
es = "Español",
it = "Italiano",
ru = "Русский",
ja = "日本語"
}
local links = {}
-- Loop through the defined languages and check if subpages exist
for code, name in pairs(langNames) do
local subpage = mw.title.new(basePage .. '/' .. code)
if subpage and subpage.exists then
table.insert(links, "[[" .. basePage .. "/" .. code .. "|" .. name .. "]]")
end
end
if #links > 0 then
return table.concat(links, " • ")
else
return "No translations available yet."
end
end
return p