Moduli:GeoInfobox
local p = {};
require('strict');
function p.renderId(frame) local idArray = { ['p590'] = 'GNIS', ['p884'] = 'ГВР', ['p1397'] = 'ГКГН', -- ['p1566'] = 'GeoNames', ['p1886'] = 'GVP', ['p4708'] = '<span class="ts-comment-commentedText" title="Komentosarjavirhe: Moduulia ”String” ei ole.">VOGRIPA' } local text =
for i, j in pairs(idArray) do local tmp = frame:expandTemplate { title = 'Wikidata', args = { i } } if tmp and tmp ~= then
text = text .. '
' end end if text ~= then return '
- ' .. text .. '
'
end end
function p.renderLine(frame) local args = frame:getParent().args; frame.args = frame:getParent().args; local cat = local prefix = { ['~'] = 'около', ['>'] = 'более', ['<'] = 'менее' } local before = local ref =
local text = args[1] or ; local label = args[2] or ; -- одиночная метка local label2 = args[3] or ; -- множественная метка local wikify = args[4] or ; local after = args[5] or ;
if text == '-' then return ; end
if text ~= then if label2 ~= then if mw.ustring.match(text, "[^/]+/[^/]+") then label = label2 end if wikify == '1' then frame.args['o'] = '%' frame.args['nodis'] = '1' end local split = require('Module:String/split').split frame.args[1] = text text = split(frame) else if after ~= then if mw.ustring.match(text, '\127') and not mw.ustring.match(text, 'templatestyles') then text, ref = mw.ustring.match(text, '[^\127]+'), mw.ustring.match(text, '\127.+') end if not mw.ustring.match(text, '[-—×]') then local tmp_text = mw.ustring.gsub(text, '[≈−, ]', { ['≈'] = '~',['−'] = '-',[','] = '.',[' '] = }) if mw.ustring.match(text, '^[≈~<>]%s*%d') and prefix[tmp_text:sub(1, 1)] then before = prefix[tmp_text:sub(1, 1)] .. ' ' text = mw.ustring.gsub(text, '^[≈~<>]%s*', ) elseif mw.ustring.match(text, '^[бдмо][еко][лно]?[ел]?[ео]?') then -- до|около|более|менее before = mw.ustring.match(text, '^[бдмо][еко][лно]?[ел]?[ео]?') .. ' ' text = mw.ustring.gsub(text, '^[бдмо][еко][лно]?[ел]?[ео]?%s*', ) end tmp_text = mw.ustring.gsub(tmp_text, '^[≈~<>бдмо][еко]?[лно]?[ел]?[ео]?%s*', ) if tonumber(tmp_text) then local lang = mw.language.getContentLanguage() text = lang:formatNum(tonumber(tmp_text)) elseif mw.title.getCurrentTitle():inNamespace(0) then cat = end end end if wikify == '1' then text = '' .. mw.ustring.gsub(text, '%s?%(.*%)$', ) .. '' end text = before .. text .. ref .. ' ' .. after end end
if args['d'] and args['d'] ~= then text = frame:expandTemplate { title = 'Wikidata', args = { args['d'], text, separator = args['r'] or } }; end
if text ~= then
return '' .. label .. '' .. text .. '' .. cat;
end
return ; end
function p.findImage(frame) local page = mw.title.getCurrentTitle() local txt, args = page:getContent(), frame.args if args and args[1] and args[1] ~= then if txt:match(':' .. args[1]) and mw.title.getCurrentTitle():inNamespace(0) then return end end end
return p;