Änderungen

Wechseln zu: Navigation, Suche

Modul:Recipes

6.449 Bytes hinzugefügt, vor 1 Jahr
Aktualisiert. // Updated.
-- Note: for "Any xxx" group (e.g. "Any Birds"), they should be added to {{tr}} database.
local l10n_info = {
['en'] = {
-- for {{recipes}}--
['cate_unexcepted_rows_count'] = 'Recipes table with unexcepted total number of rows',
['cate_no_row'] = 'Recipes table with no row',
['header_result'] = 'Result',
['header_ingredients'] = 'Ingredients',
['header_station'] = '[[Crafting station]]',
 
['cate_craftable'] = 'Craftable items',
 
['station_by_hand'] = '[[By Hand]]',
['station_sep_or'] = "<br/>'''''or'''''<br/>",
['station_sep_and'] = " '''and''' ",
 
['ingredients_sep'] = " ''or'' ",
['snow_biome'] = '[[Snow biome]]',
 
['station_cate'] = {
['Lead Anvil'] = 'Iron or Lead Anvil',
['Iron Anvil'] = 'Iron or Lead Anvil',
['Orichalcum Anvil'] = 'Mythril or Orichalcum Anvil',
['Mythril Anvil'] = 'Mythril or Orichalcum Anvil',
['Demon Altar'] = 'Demon or Crimson Altar',
['Crimson Altar'] = 'Demon or Crimson Altar',
['Altar'] = 'Demon or Crimson Altar',
['Titanium Forge'] = 'Adamantite or Titanium Forge',
['Adamantite Forge'] = 'Adamantite or Titanium Forge',
['Cauldron'] = 'Cooking Pot or Cauldron',
['Cooking Pot'] = 'Cooking Pot or Cauldron',
['Bottle only'] = 'Placed Bottle',
['Placed Bottle only'] = 'Placed Bottle',
['Bottle'] = 'Placed Bottle or Alchemy Table',
['Placed Bottle'] = 'Placed Bottle or Alchemy Table',
['Alchemy Table'] = 'Placed Bottle or Alchemy Table',
['Water'] = 'Water or Sink',
['Sink'] = 'Water or Sink',
['Crystal Ball and Water'] = 'Crystal Ball and Water or Sink',
['Sky Mill and Water'] = 'Sky Mill and Water or Sink',
['Crystal Ball and Honey'] = 'Crystal Ball and Honey',
['Crystal Ball and Lava'] = 'Crystal Ball and Lava',
},
-- for {{recipes/extract}}--
['default_sep_compact'] = "<br/>'''or'''<br/>",
['default_sep_ingredients'] = "'''or'''",
['compact_snow_biome'] = '[[Snow biome|Snow]]',
},
['de'] = {
-- for {{recipes}}--
['cate_unexcepted_rows_count'] = 'Rezepte-Tabelle mit unerwarteter Gesamtzahl an Zeilen',
['cate_no_row'] = 'Rezepte-Tabelle ohne Zeilen',
['header_result'] = 'Resultat',
['header_ingredients'] = 'Zutaten',
['header_station'] = '[[Herstellungsobjekt]]',
 
['cate_craftable'] = 'Herstellbare Gegenstände',
 
['station_by_hand'] = '[[kein Objekt]]',
['station_sep_or'] = "<br/>'''''oder'''''<br/>",
['station_sep_and'] = " '''und''' ",
 
['ingredients_sep'] = " ''oder'' ",
['snow_biome'] = '[[Tundra]]',
 
['station_cate'] = {
['Lead Anvil'] = 'Eisen- oder Bleiamboss',
['Iron Anvil'] = 'Eisen- oder Bleiamboss',
['Orichalcum Anvil'] = 'Mithril- oder Oreichalkosamboss',
['Mythril Anvil'] = 'Mithril- oder Oreichalkosamboss',
['Demon Altar'] = 'Dämonen- oder Purpur-Altar',
['Crimson Altar'] = 'Dämonen- oder Purpur-Altar',
['Altar'] = 'Dämonen- oder Purpur-Altar',
['Titanium Forge'] = 'Adamantit- oder Titanschmiede',
['Adamantite Forge'] = 'Adamantit- oder Titanschmiede',
['Cauldron'] = 'Kochtopf oder Kessel',
['Cooking Pot'] = 'Kochtopf oder Kessel',
['Bottle only'] = 'Platzierte Flasche',
['Placed Bottle only'] = 'Platzierte Flasche',
['Bottle'] = 'Platzierte Flasche oder Alchemietisch',
['Placed Bottle'] = 'Platzierte Flasche oder Alchemietisch',
['Alchemy Table'] = 'Platzierte Flasche oder Alchemietisch',
['Water'] = 'Wasser oder Waschbecken',
['Sink'] = 'Wasser oder Waschbecken',
['Crystal Ball and Water'] = 'Kristallkugel und Wasser oder Waschbecken',
['Sky Mill and Snow Biome'] = 'Himmelsmühle und Tundra',
['Sky Mill and Water'] = 'Himmelsmühle und Wasser oder Waschbecken',
['Crystal Ball and Lava'] = 'Kristallkugel und Lava',
['Crystal Ball and Honey'] = 'Kristallkugel und Honig',
},
-- for {{recipes/extract}}--
['default_sep_compact'] = "<br/>'''oder'''<br/>",
['default_sep_ingredients'] = "'''oder'''",
['compact_snow_biome'] = '[[Tundra]]',
},
['zh'] = {
-- for {{recipes}}--
['cate_unexcepted_rows_count'] = 'Recipes table with unexcepted total number of rows',
['cate_no_row'] = 'Recipes table with no row',
['header_result'] = '产物',
['header_ingredients'] = '材料',
['header_station'] = '[[制作站]]',
 
['cate_craftable'] = '可制作物品',
 
['station_by_hand'] = '[[徒手]]',
['station_sep_or'] = "<br/>'''''或'''''<br/>",
['station_sep_and'] = " '''和''' ",
 
['ingredients_sep'] = " ''或'' ",
['snow_biome'] = '[[雪原生物群落]]',
 
['station_cate'] = {
['Lead Anvil'] = '铁砧或铅砧',
['Iron Anvil'] = '铁砧或铅砧',
['Orichalcum Anvil'] = '秘银砧或山铜砧',
['Mythril Anvil'] = '秘银砧或山铜砧',
['Demon Altar'] = '恶魔祭坛或猩红祭坛',
['Crimson Altar'] = '恶魔祭坛或猩红祭坛',
['Altar'] = '恶魔祭坛或猩红祭坛',
['Titanium Forge'] = '精金熔炉或钛金熔炉',
['Adamantite Forge'] = '精金熔炉或钛金熔炉',
['Cauldron'] = '烹饪锅或大锅',
['Cooking Pot'] = '烹饪锅或大锅',
['Bottle only'] = '放置的瓶子',
['Placed Bottle only'] = '放置的瓶子',
['Bottle'] = '放置的瓶子或炼药桌',
['Placed Bottle'] = '放置的瓶子或炼药桌',
['Alchemy Table'] = '放置的瓶子或炼药桌',
['Water'] = '水或水槽',
['Sink'] = '水或水槽',
['Crystal Ball and Water'] = '水晶球和水或水槽',
['Sky Mill and Water'] = '天磨和水或水槽',
['Crystal Ball and Honey'] = '水晶球和蜂蜜',
['Crystal Ball and Lava'] = '水晶球和熔岩',
},
-- for {{recipes/extract}}--
['default_sep_compact'] = "<br/>'''或'''<br/>",
['default_sep_ingredients'] = "'''或'''",
['compact_snow_biome'] = '[[雪原生物群落|雪原]]',
},
}
 
 
local l10n_auto_translate_eicons_pagename = {
['zh'] = true,
}
 
 
------- The following is not related to l10n. --------------
 
 
local inputArgs -- global args cache.
local lang -- cache current lang.
local l10n_table
 
local l10n = function(key)
return l10n_table[key] or l10n_info['en'][key]
end
 
local extCols_stationBefore = nil
args[1] = name
args[2] = currentFrame:expandTemplate{ title = 'tr', args = {name, lang=lang} }
args['eicons'] = l10n_auto_translate_eicons_pagename[lang]
args['small'] = 'y'
args['lang'] = lang or 'en'
end
 
local resultCell = function(row, showResultId, needLink, noVersion, template)
local result, resultid, resultimage, resulttext, amount, version = row['result'], row['resultid'], row['resultimage'], row['resulttext'], row['amount'], row['version']
local str = ''
local args = {anchor = 'y', nolink = not needLink, class='multi-line'}
if showResultId then
args['id'] = resultid
str = str .. ' (' ..currentFrame:expandTemplate{ title = 'version icons', args = {version} }..')'
end
end
if template then
local template_str = currentFrame:expandTemplate{ title = template, args = {
link = needLink, showid = showResultId, noversion = noVersion,
resultid=resultid, resultimage=resultimage, resulttext=resulttext,
result=result, amount=amount, versions=version,
} }
str = template_str:gsub('@@@@', str)
end
return str
for _, itemname in ipairs(split(item)) do
if s then
s = s .. " l10n('ingredients_sep'oder'' ") .. itemLink(itemname)
else
s = itemLink(itemname)
options = options or {wrap = 'y'}
if station == 'By Hand' then
return l10n('[[kein Objekt]]station_by_hand')
elseif station == 'Furnace' or station == 'Work Bench' or station == 'Sawmill' or station == "Tinkerer's Workshop" or station == 'Dye Vat'
or station == 'Loom' or station == 'Keg' or station == 'Hellforge' or station == 'Bookcase' or station == 'Imbuing Station' or station == 'Lava'
return itemLink(station, options)
elseif station == 'Iron Anvil' then
return itemLink('Iron Anvil', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Lead Anvil', options)
elseif station == 'Adamantite Forge' then
return itemLink('Adamantite Forge', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Titanium Forge', options)
elseif station == 'Mythril Anvil' then
return itemLink('Mythril Anvil', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Orichalcum Anvil', options)
elseif station == 'Demon Altar' then
return itemLink('Demon Altar', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Crimson Altar', options)
elseif station == 'Cooking Pot' then
return itemLink('Cooking Pot', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Cauldron', options)
elseif station == 'Placed Bottle' then
return itemLink('Placed Bottle', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Alchemy Table', options)
elseif station == 'Water' then
return itemLink('Water', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Sink', options)
elseif station == 'Table and Chair' then
return itemLink('Table', options) .. " l10n('station_sep_and''und''' ") .. itemLink('Chair', options)
elseif station == 'Work Bench and Chair' then
return itemLink('Work Bench', options) .. " l10n('station_sep_and''und''' ") .. itemLink('Chair', options)
elseif station == 'Crystal Ball and Lava' then
return itemLink('Crystal Ball', options) .. " l10n('station_sep_and''und''' ") .. itemLink('Lava', options)
elseif station == 'Crystal Ball and Honey' then
return itemLink('Crystal Ball', options) .. " l10n('station_sep_and''und''' ") .. itemLink('Honey', options)
elseif station == 'Crystal Ball and Water' then
return itemLink('Crystal Ball', options) .. " l10n('station_sep_and''und''' ").. '<span class="water">' .. itemLink('Water', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Sink', options) .. '</span>'
elseif station == 'Sky Mill and Water' then
return itemLink('Sky Mill', options) .. " l10n('station_sep_and''und''' ").. '<span class="water">' .. itemLink('Water', options) .. "<br/>l10n('station_sep_or''''oder'''''<br/>") .. itemLink('Sink', options) .. '</span>'
elseif station == 'Sky Mill and Snow Biome' then
return itemLink('Sky Mill', options) .. " l10n('station_sep_and''und''' ").. l10n('[[Tundra]]snow_biome')
elseif station == 'Placed Bottle only' then
return itemLink('Placed Bottle', options)
return ' @&thinsp;' .. itemLink('Sky Mill', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;".. '(&thinsp;' .. itemLink('Water', {mode = 'image'}) .. "&thinsp;/&thinsp;" .. itemLink('Sink', {mode = 'image'}) .. '&thinsp;)'
elseif station == 'Sky Mill and Snow Biome' then
return ' @&thinsp;' .. itemLink('Sky Mill', {mode = 'image'}) .. "&thinsp;&amp;&thinsp;".. l10n('[[Tundra]]compact_snow_biome')
elseif station == 'Placed Bottle only' then
return ' @&thinsp;' .. itemLink('Placed Bottle', {mode = 'image'})
end
 
local addCate, cateStr -- for table body. init in p.query
 
local addCate, cateStr = (function()
local cate = {
['Lead Anvil'] = 'Eisen- oder Bleiamboss',
['Iron Anvil'] = 'Eisen- oder Bleiamboss',
['Orichalcum Anvil'] = 'Mithril- oder Oreichalkosamboss',
['Mythril Anvil'] = 'Mithril- oder Oreichalkosamboss',
['Demon Altar'] = 'Dämonen- oder Purpur-Altar',
['Crimson Altar'] = 'Dämonen- oder Purpur-Altar',
['Altar'] = 'Dämonen- oder Purpur-Altar',
['Titanium Forge'] = 'Adamantit- oder Titanschmiede',
['Adamantite Forge'] = 'Adamantit- oder Titanschmiede',
['Cauldron'] = 'Kochtopf oder Kessel',
['Cooking Pot'] = 'Kochtopf oder Kessel',
['Bottle only'] = 'Platzierte Flasche',
['Placed Bottle only'] = 'Platzierte Flasche',
['Bottle'] = 'Platzierte Flasche oder Alchemietisch',
['Placed Bottle'] = 'Platzierte Flasche oder Alchemietisch',
['Alchemy Table'] = 'Platzierte Flasche oder Alchemietisch',
['Water'] = 'Wasser oder Waschbecken',
['Sink'] = 'Wasser oder Waschbecken',
['Crystal Ball and Water'] = 'Kristallkugel und Wasser oder Waschbecken',
['Sky Mill and Snow Biome'] = 'Himmelsmühle und Tundra',
['Sky Mill and Water'] = 'Himmelsmühle und Wasser oder Waschbecken',
['Crystal Ball and Lava'] = 'Kristallkugel und Lava',
['Crystal Ball and Honey'] = 'Kristallkugel und Honig',
}
local cateCache = {}
local addCate = function(station)
cateCache[station] = true
end
local cateStr = function()
local str = ''
for station, _ in pairs(cateCache) do
str = str .. '[[Category:'..currentFrame:preprocess(cate[station] or '{{tr|'..station..'|de}}')..']]'
end
if str ~= '' then
str = '[[Category:Herstellbare Gegenstände]]' .. str
end
return str
end
return addCate, cateStr
end)()
 
local tableStart = function(title, withStation)
_field = 'col-A-' .. _i
end
str = str .. '<th class="result">' .. (getArg('header-result') or l10n('Resultatheader_result')) .. '</th>'
_i = 1
_field = 'col-B-1'
_field = 'col-B-' .. _i
end
str = str .. '<th class="ingredients">' .. (getArg('header-ingredients') or l10n('Zutatenheader_ingredients')) .. '</th>'
_i = 1
_field = 'col-C-1'
_field = 'station-col-before-' .. _i
end
str = str .. '<th class="station">' .. (getArg('header-station') or l10n('[[Herstellungsobjekt]]header_station')) .. '</th>'
_i = 1
_field = 'station-col-after-1'
 
local tableEnd = function(rows_count, expectedrows)
local str = '</table><div style="display: none">total: '..rows_count..' Zeilerow(ns)</div></div></div>'
if expectedrows and rows_count ~= expectedrows then
str = str .. '[[Category:Rezepte-Tabelle'.. mitl10n('cate_unexcepted_rows_count') unerwarteter.. Gesamtzahl an Zeilen']]'
end
if not expectedrows and rows_count == 0 then
str = str .. '[[Category:Rezepte-Tabelle'.. ohnel10n('cate_no_row') Zeilen.. ']]'
end
return str
end
 
local tableRow = function(str, row, current_station, station_count, rows_count, showResultId, withStation, needCate, needLink, needGroup, current_result, result_count, current_result_ext, result_ext_count, template)
local str_w = '' -- before result col
local str_x = '' -- between result and ingredients cols
current_result = result
result_count = 1
str_resultCell = '<td class="result" rowspan="yyyrowspanyyy">'.. resultCell(row, showResultId, needLink, false, template).. '</td>'
end
-- grouping ext cols
for _, v in ipairs(extCols_A) do
if result_index then
str_w = str_w .. '<td class="'..v..'" rowspan="zzzrowspanzzz">' .. (getArg(result_index .. '-row-' .. v) or '') .. '</td>'
else
str_w = str_w .. '<td class="'..v..'" rowspan="zzzrowspanzzz"></td>'
end
end
for _, v in ipairs(extCols_B) do
if result_index then
str_x = str_x .. '<td class="'..v..'" rowspan="zzzrowspanzzz">' .. (getArg(result_index .. '-row-' .. v) or '') .. '</td>'
else
str_x = str_x .. '<td class="'..v..'" rowspan="zzzrowspanzzz"></td>'
end
end
for _, v in ipairs(extCols_C) do
if result_index then
str_y = str_y .. '<td class="'..v..'" rowspan="zzzrowspanzzz">' .. (getArg(result_index .. '-row-' .. v) or '') .. '</td>'
else
str_y = str_y .. '<td class="'..v..'" rowspan="zzzrowspanzzz"></td>'
end
end
for _, v in ipairs(extCols_D) do
if result_index then
str_z = str_z .. '<td class="'..v..'" rowspan="zzzrowspanzzz">' .. (getArg(result_index .. '-row-' .. v) or '') .. '</td>'
else
str_z = str_z .. '<td class="'..v..'" rowspan="zzzrowspanzzz"></td>'
end
end
for _, v in ipairs(extCols_A) do
if result_index then
str_w = str_w .. '<td class="'..v..'">' .. (getArg(result_index .. '-row-' .. v) or '') .. '</td>'
else
str_w = str_w .. '<td class="'..v..'"></td>'
end
end
for _, v in ipairs(extCols_B) do
if result_index then
str_x = str_x .. '<td class="'..v..'">' .. (getArg(result_index .. '-row-' .. v) or '') .. '</td>'
else
str_x = str_x .. '<td class="'..v..'"></td>'
end
end
for _, v in ipairs(extCols_C) do
if result_index then
str_y = str_y .. '<td class="'..v..'">' .. (getArg(result_index .. '-row-' .. v) or '') .. '</td>'
else
str_y = str_y .. '<td class="'..v..'"></td>'
end
end
for _, v in ipairs(extCols_D) do
if result_index then
str_z = str_z .. '<td class="'..v..'">' .. (getArg(result_index .. '-row-' .. v) or '') .. '</td>'
else
str_z = str_z .. '<td class="'..v..'"></td>'
end
end
end
str_resultCell = '<td class="result">'.. resultCell(row, showResultId, needLink, false, template).. '</td>'
end
 
for _, v in ipairs(extCols_stationBefore) do
if station_index then
str = str .. '<td class="station '..v..'" rowspan="xxxrowspanxxx">' .. (getArg(station_index .. '-row-' .. v) or '') .. '</td>'
else
str = str .. '<td class="station '..v..'" rowspan="xxxrowspanxxx"></td>'
end
end
for _, v in ipairs(extCols_stationAfter) do
if station_index then
str = str .. '<td class="station '..v..'" rowspan="xxxrowspanxxx">' .. (getArg(station_index .. '-row-' .. v) or '') .. '</td>'
else
str = str .. '<td class="station '..v..'" rowspan="xxxrowspanxxx"></td>'
end
end
if temp then
valid = true
str = str .. '<td class="'..v..'">' .. temp .. '</td>'
else
str = str .. '<td class="'..v..'"></td>'
end
end
if temp then
valid = true
str = str .. '<td class="'..v..'">' .. temp .. '</td>'
else
str = str .. '<td class="'..v..'"></td>'
end
end
if temp then
valid = true
str = str .. '<td class="'..v..'">' .. temp .. '</td>'
else
str = str .. '<td class="'..v..'"></td>'
end
end
if temp then
valid = true
str = str .. '<td class="station '..v..'">' .. temp .. '</td>'
else
str = str .. '<td class="station '..v..'"></td>'
end
end
if temp then
valid = true
str = str .. '<td class="station '..v..'">' .. temp .. '</td>'
else
str = str .. '<td class="station '..v..'"></td>'
end
end
if temp then
valid = true
str = str .. '<td class="'..v..'">' .. temp .. '</td>'
else
str = str .. '<td class="'..v..'"></td>'
end
end
 
 
local tableBody = function(result, showResultId, withStation, needGroup, needCate, needLink, rootpagename, title, expectedrows, template)
local str = tableStart(title, withStation)
-- top ext rows:
rows_count = rows_count + 1
-- table row:
str, current_station, station_count, current_result, result_count, current_result_ext, result_ext_count = tableRow(str, row, current_station, station_count, rows_count, showResultId, withStation, needCate, needLink, needGroup, current_result, result_count, current_result_ext, result_ext_count, template)
-- cate:
if needCate then
if needCate == 2 or rootpagename == currentFrame:expandTemplate{ title = 'tr', args = {row['result'], 'de'} } then
addCate(row['station'])
end
inputArgs = args
 
lang = getArg('lang') or frame:expandTemplate{ title = .args['lang' }] or 'en'
l10n_table = l10n_info[lang] or l10n_info['en']
 
addCate, cateStr = (function()
local cate = l10n('station_cate')
local cateCache = {}
local addCate = function(station)
cateCache[station] = true
end
local cateStr = function()
local str = ''
for station, _ in pairs(cateCache) do
str = str .. '[[Category:'..(cate[station] or frame:expandTemplate{ title = 'tr', args = {station, lang=lang}})..']]'
end
if str ~= '' then
str = '[[Category:'.. l10n('cate_craftable').. ']]' .. str
end
return str
end
return addCate, cateStr
end)()
 
local where = trim(args['where'] or '')
limit = 2000,
})
return tableBody(result, showResultId, false, needGroup, needCate, needLink, rootpagename, _title, _expectedrows, getArg('resulttemplate'))
else
-- with station
limit = 2000,
})
return tableBody(result, showResultId, true, needGroup, needCate, needLink, rootpagename, _title, _expectedrows, getArg('resulttemplate'))
end
end -- p.query
inputArgs = args
 
lang = getArg('lang') or frame:expandTemplate{ title = .args['lang' }] or 'en'
l10n_table = l10n_info[lang] or l10n_info['en']
 
local where = trim(args['where'] or '')
local sep = getArg('sep') or getArg('seperator')
if not mode or mode =='compact' or mode == '' then
--default mode = ingredientscompact
local sep = sep or "<br/>l10n('default_sep_compact''or'''<br/>")
local withResult = getArg('withresult')
local withStation = not getArg('nostation')
return str
elseif mode == 'ingredients' then
local sep = sep or "l10n('default_sep_ingredients''or'''")
local str = nil
for _, row in ipairs(result) do
local needCate, needLink = getFlags(args)
for _, row in ipairs(result) do
return resultCell(row, getArg('showresultid'), needLink, true, getArg('resulttemplate'))
end
else
end
end -- p.extract
 
 
-- return "yes" or ""
p.exist = function(frame)
local args = frame.args
local where = trim(args['where'] or '')
if where == '' then
where = criStr(args)
end
-- no constraint no result.
if where == '' then
return
end
-- query:
local result = mw.ext.cargo.query('Recipes', 'result', {
where = where,
limit = 1, -- enough.
})
-- output
for _, row in ipairs(result) do
return 'yes'
end
end -- p.exist
 
return p
3.577

Bearbeitungen