Module:TNT: Difference between revisions
Jump to navigation
Jump to search
metawikimedia>DiBabelYurikBot m Copying 4 changes by Yurik: "optimize libraryUtil loading only when needed, fix templatedata doc having just the positional parameters, make i18n/ prefix optional, support for usage from modules, no auto I18n/ prefix, breaks some graphs" from mw:Module:TNT. (docs, translate) |
metawikimedia>DiBabelYurikBot m Copying 5 changes by Yurik: "breaking: ignore lang param in format(), use formatInLanguage() instead, make i18n/ prefix optional, support for usage from modules, no auto I18n/ prefix, breaks some graphs, fix doc translation link, deprecate link function, always use c: for data links to Commons" from mw:Module:TNT. (docs, translate) |
||
Line 59: | Line 59: | ||
-- Identical to p.msg() above, but used from other lua modules | -- Identical to p.msg() above, but used from other lua modules | ||
function p.format(dataset, key, | -- Parameters: name of dataset, message key, optional arguments | ||
-- 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 | local checkType = require('libraryUtil').checkType | ||
checkType('format', 1, dataset, 'string') | checkType('format', 1, dataset, 'string') | ||
checkType('format', 2, key, 'string') | checkType('format', 2, key, 'string') | ||
return formatMessage(dataset, key, {...}) | |||
checkType(' | end | ||
return formatMessage(dataset, key, | |||
-- 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', 1, lang, 'string') | |||
checkType('formatInLanguage', 2, dataset, 'string') | |||
checkType('formatInLanguage', 3, key, 'string') | |||
return formatMessage(dataset, key, {...}, lang) | |||
end | end | ||