Modul:TNT: Unterschied zwischen den Versionen
resetting to the main mediawiki.org version, allows auto-syncing
(Module has been nominated for deletion) |
(resetting to the main mediawiki.org version, allows auto-syncing) |
||
| Zeile 1: | Zeile 1: | ||
-- | |||
-- INTRO: (!!! DO NOT RENAME THIS PAGE !!!) | |||
-- This module allows any template or module to be copy/pasted between | |||
-- wikis without any translation changes. All translation text is stored | |||
-- in the global Data:*.tab pages on Commons, and used everywhere. | |||
-- | |||
-- SEE: https://www.mediawiki.org/wiki/Multilingual_Templates_and_Modules | |||
-- | -- | ||
-- ATTENTION: | -- ATTENTION: | ||
| Zeile 5: | Zeile 12: | ||
-- Please do not modify it anywhere else, as it may get copied and override your changes. | -- Please do not modify it anywhere else, as it may get copied and override your changes. | ||
-- Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT | -- Suggestions can be made at https://www.mediawiki.org/wiki/Module_talk:TNT | ||
-- | -- | ||
-- DESCRIPTION: | -- DESCRIPTION: | ||
-- The "msg" function uses a Commons dataset to translate a message | -- The "msg" function uses a Commons dataset to translate a message | ||
-- with a given key (e.g. source-table), plus optional arguments | -- with a given key (e.g. source-table), plus optional arguments | ||
-- to the wiki markup in the current content language. | -- to the wiki markup in the current content language. | ||
-- Use lang=xx to set language. | -- Use lang=xx to set language. Example: | ||
-- | -- | ||
-- | -- {{#invoke:TNT | msg | ||
- | -- | I18n/Template:Graphs.tab <!-- https://commons.wikimedia.org/wiki/Data:I18n/Template:Graphs.tab --> | ||
-- | source-table <!-- uses a translation message with id = "source-table" --> | |||
-- | param1 }} <!-- optional parameter --> | |||
-- | -- | ||
-- | |||
-- The "doc" function will generate the <templatedata> parameter documentation for templates. | -- The "doc" function will generate the <templatedata> parameter documentation for templates. | ||
-- This way all template parameters can be stored and localized in a single Commons dataset. | -- This way all template parameters can be stored and localized in a single Commons dataset. | ||
-- NOTE: "doc" assumes that all documentation is located in Data:Templatedata/* on Commons. | -- NOTE: "doc" assumes that all documentation is located in Data:Templatedata/* on Commons. | ||
-- | -- | ||
-- | -- {{#invoke:TNT | doc | Graph:Lines }} | ||
-- | -- uses https://commons.wikimedia.org/wiki/Data:Templatedata/Graph:Lines.tab | ||
-- | -- if the current page is Template:Graph:Lines/doc | ||
-- | -- | ||
| Zeile 35: | Zeile 43: | ||
for k, v in pairs(frame.args) do | for k, v in pairs(frame.args) do | ||
if k == 1 then | if k == 1 then | ||
dataset = v | dataset = mw.text.trim(v) | ||
elseif k == 2 then | elseif k == 2 then | ||
id = v | id = mw.text.trim(v) | ||
elseif type(k) == 'number' then | elseif type(k) == 'number' then | ||
table.insert(params, v) | table.insert(params, v) | ||
elseif k == 'lang' and v ~= '_' then | elseif k == 'lang' and v ~= '_' then | ||
lang = v | lang = mw.text.trim(v) | ||
end | end | ||
end | end | ||
| Zeile 55: | Zeile 63: | ||
-- Given a dataset name, convert it to a title with the 'commons:data:' prefix | -- Given a dataset name, convert it to a title with the 'commons:data:' prefix | ||
function link(dataset) | function link(dataset) | ||
dataset = 'Data:' .. (dataset or '') | dataset = 'Data:' .. mw.text.trim(dataset or '') | ||
if mw.site.siteName == 'Wikimedia Commons' then | if mw.site.siteName == 'Wikimedia Commons' then | ||
return dataset | return dataset | ||