Anonymous user
Module:TNT: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
m
Changed protection level for "Module:TNT": High-risk Lua module: per request at WP:RFPP to match Module:Excerpt ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))
(sync from wmw) |
m (Changed protection level for "Module:TNT": High-risk Lua module: per request at WP:RFPP to match Module:Excerpt ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite))) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 36:
local p = {}
local i18nDataset = 'I18n/Module:TNT.tab'
local checkType = require('libraryUtil').checkType▼
-- Forward declaration of the local functions
Line 60 ⟶ 59:
-- Identical to p.msg() above, but used from other lua modules
-- Example with 2 params: format('I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset')
function p.format(dataset, key, ...)
▲ local checkType = require('libraryUtil').checkType
checkType('format', 1, dataset, 'string')
checkType('format', 2, key, 'string')
checkType('format', 3, params, 'table', true)▼
end
checkType('format', 4, lang, 'string', true)▼
▲ return formatMessage(dataset, key, params, lang)
-- Identical to p.msg() above, but used from other lua modules with the language param
-- Parameters: language code, name of dataset, message key, optional arguments
-- Example with 2 params: formatInLanguage('es', I18n/Module:TNT', 'error_bad_msgkey', 'my-key', 'my-dataset')
function p.formatInLanguage(lang, dataset, key, ...)
local checkType = require('libraryUtil').checkType
checkType('formatInLanguage', 2, dataset, 'string')
return formatMessage(dataset, key, {...}, lang)
end
Line 141 ⟶ 153:
if not dataset then
error(formatMessage(i18nDataset, 'error_no_dataset', {}))
end
-- Give helpful error to thirdparties who try and copy this module.
if not mw.ext or not mw.ext.data or not mw.ext.data.get then
error('Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:' .. dataset)
end
|