Module:TranslationData: Difference between revisions
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
Created page with "local p = {} p.messages = { en = { header = "Machine Translation", body = "This page began as a machine translation from English. Please help us make it more natural!", project = "Translation Project" }, de = { header = "Maschinelle Übersetzung", body = "Diese Seite wurde ursprünglich maschinell aus dem Englischen übersetzt. Bitte hilf uns, sie natürlicher zu gestalten!", project = "Übersetzungsprojekt"..." |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
p.messages = { | p.messages = { | ||
en = { | en = { header = "Machine Translation", body = "This page began as a machine translation from English. Please help us make it more natural!", edit = "Edit this translation", source = "Original English version" }, | ||
de = { header = "Maschinelle Übersetzung", body = "Diese Seite wurde ursprünglich maschinell aus dem Englischen übersetzt. Bitte hilf uns, sie natürlicher zu gestalten!", edit = "Übersetzung bearbeiten", source = "Englische Originalversion" }, | |||
fr = { header = "Traduction Automatique", body = "Cette page est issue d'une traduction automatique de l'anglais. Merci de nous aider à la rendre plus naturelle !", edit = "Modifier la traduction", source = "Version anglaise originale" }, | |||
zh = { header = "机器翻译", body = "本页面最初由英文机器翻译而成。请帮助我们完善语言,使其更加自然!", edit = "编辑翻译", source = "英文原文" }, | |||
es = { header = "Traducción Automática", body = "Esta página comenzó como una traducción automática del inglés. ¡Ayúdenos a hacerla más natural!", edit = "Editar traducción", source = "Versión original en inglés" } | |||
de = { | |||
fr = { | |||
zh = { | |||
} | |||
} | } | ||
function p. | function p.renderNotice(frame) | ||
local lang = | local title = mw.title.getCurrentTitle() | ||
local | |||
-- | -- If it's a subpage (e.g., Namespace:Page/de), basePageTitle keeps the Namespace:Page part | ||
local | local basePage = title.basePageTitle.fullText | ||
return | local lang = title.subpageText | ||
-- Fallback for non-subpages | |||
if not title.isSubpage then lang = "en" end | |||
local msg = p.messages[lang] or p.messages["en"] | |||
-- Generate the Direct Edit URL | |||
local editUrl = title:fullUrl('action=edit') | |||
-- Construct the HTML string | |||
local output = msg.body .. "<br />" | |||
output = output .. "'''[" .. editUrl .. " " .. msg.edit .. "]''' • " | |||
output = output .. "'''[[" .. basePage .. "|" .. msg.source .. "]]'''" | |||
return output | |||
end | |||
function p.getHeader(frame) | |||
local title = mw.title.getCurrentTitle() | |||
local lang = title.isSubpage and title.subpageText or "en" | |||
local msg = p.messages[lang] or p.messages["en"] | |||
return msg.header | |||
end | end | ||
return p | return p | ||
Latest revision as of 15:15, 6 March 2026
Documentation for this module may be created at Module:TranslationData/doc
local p = {}
p.messages = {
en = { header = "Machine Translation", body = "This page began as a machine translation from English. Please help us make it more natural!", edit = "Edit this translation", source = "Original English version" },
de = { header = "Maschinelle Übersetzung", body = "Diese Seite wurde ursprünglich maschinell aus dem Englischen übersetzt. Bitte hilf uns, sie natürlicher zu gestalten!", edit = "Übersetzung bearbeiten", source = "Englische Originalversion" },
fr = { header = "Traduction Automatique", body = "Cette page est issue d'une traduction automatique de l'anglais. Merci de nous aider à la rendre plus naturelle !", edit = "Modifier la traduction", source = "Version anglaise originale" },
zh = { header = "机器翻译", body = "本页面最初由英文机器翻译而成。请帮助我们完善语言,使其更加自然!", edit = "编辑翻译", source = "英文原文" },
es = { header = "Traducción Automática", body = "Esta página comenzó como una traducción automática del inglés. ¡Ayúdenos a hacerla más natural!", edit = "Editar traducción", source = "Versión original en inglés" }
}
function p.renderNotice(frame)
local title = mw.title.getCurrentTitle()
-- If it's a subpage (e.g., Namespace:Page/de), basePageTitle keeps the Namespace:Page part
local basePage = title.basePageTitle.fullText
local lang = title.subpageText
-- Fallback for non-subpages
if not title.isSubpage then lang = "en" end
local msg = p.messages[lang] or p.messages["en"]
-- Generate the Direct Edit URL
local editUrl = title:fullUrl('action=edit')
-- Construct the HTML string
local output = msg.body .. "<br />"
output = output .. "'''[" .. editUrl .. " " .. msg.edit .. "]''' • "
output = output .. "'''[[" .. basePage .. "|" .. msg.source .. "]]'''"
return output
end
function p.getHeader(frame)
local title = mw.title.getCurrentTitle()
local lang = title.isSubpage and title.subpageText or "en"
local msg = p.messages[lang] or p.messages["en"]
return msg.header
end
return p