Module:Esperanto Translation/Nomoj
Jump to navigation
Jump to search
-- En Nomoj/eo_uy.json enmetu el la lingva dosiero ĉiujn liniojn, kiuj komenciĝas je «block.minecraft.», «color.minecraft.», «filled_map.» aŭ «item.minecraft.»
local this = "Module:Esperanto_Translation/Nomoj/"
local eo_uy_full = mw.loadJsonData( this .. "eo_uy.json" )
local en_us_full = mw.loadJsonData( this .. "en_us.json" )
local necesaj_prefiksoj = {'block%.minecraft%.', 'color%.minecraft%.', 'filled_map%.', 'item%.minecraft%.', 'trim_pattern%.minecraft%.'}
local eo_uy = {}
local en_us = {}
for k, _ in pairs( eo_uy_full ) do
for _, p in ipairs( necesaj_prefiksoj ) do
if k:find( '^' .. p ) and not k:find( 'pottery_shard' ) then
eo_uy[k] = eo_uy_full[k]
en_us[k] = en_us_full[k]
end
end
end
local special_json_names = {'be', 'specialaj', 'funkciaj'}
local specialaj = {}
for _, filename in ipairs( special_json_names ) do
local json_table = mw.loadJsonData( this .. filename .. '.json' )
for eo, en in pairs( json_table ) do
specialaj[eo] = en
end
end
local langTools = mw.language.new("eo")
local blokitaj_maplinioj = {
['id'] = 1,
['level'] = 1,
['locked'] = 1,
['scale'] = 1,
['unknown'] = 1,
}
local kolorajxoj = {
['artfajraĵa stelo'] = 'Firework Star',
['baloneto'] = 'Balloon',
['brilbastono'] = 'Glow Stick',
}
-- Generado de specialaj_generitaj
for key, value in pairs ( eo_uy ) do
if key:find( '^color%.minecraft%.' ) then
koloro = value:sub( 1, value:len() - 1 )
color = en_us[key]
for eo, en in pairs ( kolorajxoj ) do
specialaj[ koloro .. 'a ' .. eo ] = color .. ' ' .. en
end
elseif key:find( '^filled_map%.' ) and not blokitaj_maplinioj[ key:sub( string.len('filled_map.') + 1 ) ] then
mapnomo = value
map_name = en_us[key]
specialaj[ mapnomo ] = map_name
elseif key:find( '^trim_pattern%.minecraft%.' ) then
inkrustajxo = value
trim_pattern = en_us[key]
specialaj[ inkrustajxo ] = trim_pattern
end
end
local p = {}
local suffixes = {'BE', 'LCE'}
local prefixes = {
['Damaĝita'] = 'Damaged'
}
local function item_in_array(item, array)
local new = true
for _, v in ipairs( array ) do
if v == item then new = false end
end
return (not new)
end
local function id_el_nomo(nomo) -- la identigilo de bloko aŭ objekto laŭ ĝia nomo
local possibilities = {}
local alternatives = {}
for code, name in pairs( eo_uy ) do
if string.lower(name) == string.lower(nomo) then
local _, dot_pos = code:find("^block%.minecraft%.")
if not dot_pos then _, dot_pos = code:find("^item%.minecraft%.") end
if dot_pos then
local identifier = code:sub(dot_pos + 1)
if identifier:find('%.') then
if not item_in_array( identifiers, alternatives ) then table.insert( alternatives, identifier ) end
else
if not item_in_array( identifiers, possibilities ) then table.insert( possibilities, identifier ) end
end
end
end
end
-- assert (#possibilities > 0 or #alternatives > 0, "Objekto kun la nomo «" .. nomo .. "» ne troviĝis")
if #possibilities == 0 and #alternatives == 0 then return nil end
-- assert (#possibilities <= 1 and (#possibilities == 1 or #alternatives == 1), "Pluraj objektoj nomiĝas «" .. nomo .. "». La identigilo ne determineblas")
if #possibilities > 1 or (#possibilities == 0 and #alternatives > 1) then return nil end
if #possibilities == 1 then
return possibilities[1]
else
return alternatives[1]
end
end
local function dosiernomo_el_id(id) -- la angla nomo de bloko aŭ objekto, uzata en teksturaj dosieroj
if not id then return id end
-- local filename = string.gsub( " " .. id:gsub("_", " "), "[ .]%l", string.upper ):sub(2) -- uppercase first letter of every first word
if en_us['block.minecraft.' .. id] then
return en_us['block.minecraft.' .. id]
elseif en_us['item.minecraft.' .. id] then
return en_us['item.minecraft.' .. id]
end
-- Eliksiraĵoj
--[[
filename = filename:gsub("%.Effect%.", " of ")
filename = filename:gsub("%.", " ")
]]--
-- Koloraj ŝildoj
--[[
_, space_pos = filename:find("^Shield ")
if space_pos then
filename = filename:sub(space_pos + 1) .. " Shield"
end
]]--
-- return filename
return nil
end
local function dosiernomo_el_nomo(nomo) -- la angla nomo de objekto, uzata en bildaj dosieroj
local suffix = ''
local prefix = ''
local name = nomo
for _, s in ipairs( suffixes ) do
if name:find(' ' .. s .. '$') then
suffix = ' ' .. s .. suffix
name = name:gsub( ' ' .. s .. '$', '' )
end
end
for p, tr in pairs( prefixes ) do
if name:find('^' .. p .. 'j? ') then
prefix = prefix .. tr .. ' '
name = name:gsub( '^' .. p .. 'j? ', '' )
end
end
if prefix ~= '' then name = langTools:ucfirst(name) end
local filename = dosiernomo_el_id(id_el_nomo(name))
if not filename and specialaj[name] then
-- assert (key_in_dict(nomo, funkciaj), "Objekto kun la nomo «" .. nomo .. "» ne troviĝis")
filename = specialaj[name]
end
if filename then filename = prefix .. filename .. suffix end
return filename
end
function p.id_el_nomo( f )
local args = f.args or {["nomo"] = f}
return id_el_nomo( args.nomo )
end
function p.dosiernomo_el_id( f )
local args = f.args or {["id"] = f}
return dosiernomo_el_id( args.id )
end
function p.dosiernomo_el_nomo( f )
local args = f.args or {["nomo"] = f}
return dosiernomo_el_nomo( args.nomo )
end
return p