Content deleted Content added
m error message is too cryptic if it always says "_default" |
No edit summary |
||
Line 5:
local lang = 'en-GB' -- local default language
-- Below these comments:
-- How to translate this module (for languages without variants):
-- • Characters inside single and double quotation marks are called strings.
Line 67:
end,
['error_unknown'] = function(var)
return 'Unknown
end
},
Line 116:
end,
['error_unknown'] = function(var)
return 'Unknown
end
}
Line 122:
local require = require
local lower = mw.ustring.lower▼
local gsub = mw.ustring.gsub▼
local Type = type
local type = nil
local function getData(system, verify)
Line 132 ⟶ 136:
)
end
▲local lower = mw.ustring.lower
▲local gsub = mw.ustring.gsub
local function getLine(data, _line)
Line 150 ⟶ 151:
end
local function getColor(data, system, line,
if system then
if line then return frame:expandTemplate{ title = system .. ' color', args = {line, ['branch'] =
return frame:expandTemplate{ title = system .. ' color' }
else
Line 158 ⟶ 159:
if line then
local color = line['color'] or line['background color'] or data['color']
local
if
return color
end
Line 168 ⟶ 169:
local match = mw.ustring.match
local concat = table.concat
local _line,
local function getStation(station, _Format)
if
_Format = _Format[_line] or _Format[1]
if
_Format = _Format[
end
end
if
if _line then _Format = gsub(_Format, '%%2', _line) end
return (match(_Format, '%[%[.+%]%]')) and (gsub(_Format, '%%1', station)) or concat({'[[', gsub(_Format, '%%1', station), '|', station, ']]'})
Line 235 ⟶ 236:
local function subst(var1, var2)
-- var1 is the terminus or table of termini; var2 is the key for the table of termini
return
or
or ''
end
Line 242 ⟶ 243:
local function station(var)
if Format then
if
return subst(var)
elseif
local t = {subst(var, 1)}
Line 286 ⟶ 287:
-- If an address has no system, the row uses data from the previous address
or data[index[i - 1]]
or error(i18n[lang]['error_unknown'](args[v]['system']))
data[v]['aliases'] = data[v]['line/type aliases'] or data[v]['aliases']
data[v]['color'] = data[v]['line color'] or data[v]['color']
data[v]['icon'] = data[v]['system icon'] or data[v]['icon']
data[v]['icon format'] = data[v]['system icon format'] or data[v]['icon format']
local lang = data[v]['lang'] or lang
Line 293 ⟶ 300:
insert(wikitable, concat({'\n|-',
'\n!', style['header cell'], i18n[lang]['preceding'](stop_noun),
'\n!', style['header midcell'], (data[v]['system icon'] and data[v]['system icon'] .. ' ' or ''), (data[v]['system title'] or ('[['.. args[v]['system'] ..']]')),
'\n!', style['header cell'], i18n[lang]['following'](stop_noun)
}))
Line 314 ⟶ 321:
_line = args[v]['line'] or '_default'
if data[v]['aliases'] then
_line = data[v]['aliases'][lower(_line)] or _line
if
end
Line 331 ⟶ 338:
concat({'\n|-\n|colspan="5" ',
style['body cell'],
((args[v]['nonstop'] == 'former') and i18n[lang]['nonstop_past'] or i18n[lang]['nonstop_present'])(p._box({data = data[v], line = _line,
})
)
Line 341 ⟶ 348:
local color, background_color
local
if
if
-- line color is used as background if there is no background color in the line type table
background_color =
color =
elseif
background_color =
color = line['color'] or default['color'] or data[v]['color'] or ''
else
Line 355 ⟶ 362:
color = line['color'] or default['color'] or data[v]['color'] or ''
end
type['type title'] = type['title'] or type['type title']
else
background_color = line['background color']
color = line['color'] or default['color'] or data[v]['color'] or ''
end
line['line title'] = line['title'] or line['line title']
-- Alternate termini can be specified based on type
Line 376 ⟶ 386:
-- If the terminus table has more than one numbered key or has the via key then the table shows only the default termini, since _terminus[2] cannot be used and _terminus[via] is reserved
if
if args[v]['to-' .. b] then
terminus = args[v]['to-' .. b]
Line 395 ⟶ 405:
terminus = _terminus
end
elseif
terminus = _terminus[args[v]['to-' .. b]] or _terminus[args[v]['to']] or _terminus[1]
end
Line 416 ⟶ 426:
'\n|', (background_color and 'class="bcA" style="background-color:rgba(' .. concat(rgb(background_color), ',') .. ',.2)"|' or style['body cell']), line['line title'],
--
(
-- Note-mid; table key 'note-mid' in subpages. Overridden by user input
((args[v]['note-mid'] and small(args[v]['note-mid'])) or (
-- Transfer; uses system's station link table
Line 488 ⟶ 498:
local _line = args[2] or args.line
if not (system or _line) then return '' end
local line,
local inline = args[3] or args.inline
local
local data = args.data
if system or data then
Line 497 ⟶ 507:
if data then
line, _line = getLine(data, _line)
if
end
color = getColor(data, nil, _line,
if inline ~= 'box' then
line_data = line or error(i18n[lang]['error_unknown'](_line))
Line 507 ⟶ 517:
end
else
color = getColor(nil, system, _line,
if inline ~= 'box' then
line = frame:expandTemplate{ title = system .. ' lines', args = {_line, ['branch'] =
if mw.text.trim(line) == '' then return error(i18n[lang]['error_unknown'](_line)) end
end
end
local result
if
if line == '' then
line =
else
result = ' – ' ..
end
end
Line 565 ⟶ 575:
local border_color, text_color
if line_data then
if line_data['types'] and line_data['types'][
local
border_color =
text_color =
_line =
else
border_color = line_data['border color'] or color
Line 615 ⟶ 625:
local system = args[1] or args.system
local line = args[2] or args.line
local
local data = args.data
if system or data then
Line 625 ⟶ 635:
if line then
if
Format =
icon =
end
if not (Format or icon) then
Line 642 ⟶ 652:
if Format then
if Format ~= 'image' then return p._box({data = data, [2] = (args[2] or args.line), [3] = Format,
end
Line 695 ⟶ 705:
local line = args[2] or args.line
if not line then return '' end
local
local data = args.data
if system or data then
Line 701 ⟶ 711:
if data then
line = (getLine(data, line)) or error(i18n[lang]['error_unknown'](line))
if
end
line = line['line title'] or error(i18n[lang]['error_missing']('line title'))
else
line = frame:expandTemplate{ title = system .. ' lines', args = {line, ['branch'] =
if mw.text.trim(line) == '' then return error(i18n[lang]['error_unknown'](_line)) end
end
if
if line == '' then
line =
else
line = line .. ' – ' ..
end
end
Line 729 ⟶ 739:
if not station then return '' end
local _line = args[3] or args.line
local
local data = args.data
if system or data then
Line 740 ⟶ 750:
_line = data['aliases'][lower(_line)] or _line
end
if
end
end
Line 749 ⟶ 759:
end
else
station = frame:expandTemplate{ title = system .. ' stations', args = {['station'] = station, ['line'] = _line, ['branch'] =
end
Line 771 ⟶ 781:
if data then
local function getValue(var)
if
var = var[line] or var[1]
if
var = var[station] or var[1]
end
|