Module:TNT: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
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)
Line 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:
Line 5 ⟶ 12:
-- 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
--
-- DESCRIPTION:
-- This module allows templates to use translations from the shared Datasets on Commons
--
-- DESCRIPTION:
-- The "msg" function uses a Commons dataset to translate a message
-- with a given key (e.g. source-table), plus optional arguments
-- to the wiki markup in the current content language.
-- Use lang=xx to set language. Example:
--
-- {{#invoke:TNT | msg | Original/Template:Graphs.tab | source-table | param1 }}
-- | I18n/Template:Graphs.tab uses<!-- https://commons.wikimedia.org/wiki/Data:OriginalI18n/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.
-- 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.
--
-- {{#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
--
 
Line 35 ⟶ 43:
for k, v in pairs(frame.args) do
if k == 1 then
dataset = mw.text.trim(v)
elseif k == 2 then
id = mw.text.trim(v)
elseif type(k) == 'number' then
table.insert(params, v)
elseif k == 'lang' and v ~= '_' then
lang = mw.text.trim(v)
end
end
Line 55 ⟶ 63:
-- Given a dataset name, convert it to a title with the 'commons:data:' prefix
function link(dataset)
dataset = 'Data:' .. mw.text.trim(dataset or '')
if mw.site.siteName == 'Wikimedia Commons' then
return dataset
0

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu