Модуль:Loc: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| (не показаны 3 промежуточные версии этого же участника) | |||
| Строка 1: | Строка 1: | ||
local data = mw.loadData(" | local JsonPaths = require('Module:JsonPaths') | ||
local getArgs = require('Module:Arguments').getArgs | |||
local data = mw.loadData(JsonPaths.get("loc.json")) | |||
local p = {} | local p = {} | ||
| Строка 56: | Строка 58: | ||
function p.GetString(frame) | function p.GetString(frame) | ||
local key = | local args = getArgs(frame, { removeBlanks = false }) | ||
local subkey = | local key = args[1] | ||
local subkey = args[2] or "_value" | |||
local noFormat = args.noFormat or "" | |||
if not key then | if not key then | ||
| Строка 69: | Строка 73: | ||
end | end | ||
if noFormat == "" then | |||
return frame:preprocess("{{#invoke:Loc/Marking|main|<nowiki>".. result .. "</nowiki>}}") | |||
else | |||
return frame:preprocess("{{#invoke:Loc/Marking|main|noFormat=1|<nowiki>".. result .. "</nowiki>}}") | |||
end | |||
end | end | ||
function p.GetRawString(frame) | function p.GetRawString(frame) | ||
local key = | local args = getArgs(frame, { removeBlanks = false }) | ||
local subkey = | local key = args[1] | ||
local subkey = args[2] or "_value" | |||
local noFormat = args.noFormat or "" | |||
if not key then | if not key then | ||
| Строка 86: | Строка 96: | ||
end | end | ||
if noFormat == "" then | |||
return result | |||
else | |||
return frame:preprocess("<nowiki>".. result .. "</nowiki>") | |||
end | |||
end | end | ||
return p | return p | ||