Implemented russian translation and added translated name support

This commit is contained in:
Wofsauge committed 2020-10-25 01:23:46 +02:00
1 parent 070efdf17e
commit 695bf11478
3 files changed
+870 -844

No files matched your search

+825 -812
View File
File diff suppressed because it is too large. Load diff
+27 -8
View File
@@ -109,12 +109,17 @@ function EID:getDescriptionTable(objTable)
end end
-- returns the description object of the specified object table translated with the current language -- returns the description object of the specified object table translated with the current language
-- falls back to english if the key isnt available -- falls back to english if the objID isnt available
function EID:getDescriptionObj(objTable, key) function EID:getDescriptionObj(objTable, objID)
return EID.descriptions[EIDConfig["Language"]][objTable][key] or EID.descriptions["en_us"][objTable][key] local tableEntry = EID.descriptions[EIDConfig["Language"]][objTable][tonumber(objID)] or EID.descriptions["en_us"][objTable][tonumber(objID)]
local description = {}
description.ID = tableEntry[1] or objID
description.Name = EID:getObjectName(objID, objTable) or objTable
description.Description = tableEntry[4] or tableEntry[3] or ""
description.Transformation = tableEntry[2] or "0"
return description
end end
--Get the name of the given transformation by its ID --Get the name of the given transformation by its ID
function EID:getTransformationName(id) function EID:getTransformationName(id)
local str = "Custom" local str = "Custom"
@@ -126,13 +131,26 @@ end
-- tries to get the ingame name of an item based on its ID -- tries to get the ingame name of an item based on its ID
function EID:getObjectName(objID, objType) function EID:getObjectName(objID, objType)
if objType == "collectible" then local tableEntry = EID.descriptions[EIDConfig["Language"]][objType][tonumber(objID)] or EID.descriptions["en_us"][objType][tonumber(objID)]
if objType == "collectibles" then
if EIDConfig["Language"]~="en_us" and #tableEntry==4 then
return tableEntry[3]
end
return EID.itemConfig:GetCollectible(objID).Name return EID.itemConfig:GetCollectible(objID).Name
elseif objType == "trinket" then elseif objType == "trinkets" then
if EIDConfig["Language"]~="en_us" and #tableEntry==3 then
return tableEntry[2]
end
return EID.itemConfig:GetTrinket(objID).Name return EID.itemConfig:GetTrinket(objID).Name
elseif objType == "card" then elseif objType == "cards" then
if EIDConfig["Language"]~="en_us" and #tableEntry==3 then
return tableEntry[2]
end
return EID.itemConfig:GetCard(objID).Name return EID.itemConfig:GetCard(objID).Name
elseif objType == "pill" then elseif objType == "pills" then
if EIDConfig["Language"]~="en_us" and #tableEntry==3 then
return tableEntry[2]
end
return EID.itemConfig:GetPillEffect(objID).Name return EID.itemConfig:GetPillEffect(objID).Name
elseif objType == "sacrifice" then elseif objType == "sacrifice" then
return EID:getDescriptionTable("sacrificeHeader") return EID:getDescriptionTable("sacrificeHeader")
@@ -185,6 +203,7 @@ end
-- Returns the inlineIcon object of a given Iconstring -- Returns the inlineIcon object of a given Iconstring
-- can be used to validate an iconstring -- can be used to validate an iconstring
function EID:getIcon(str) function EID:getIcon(str)
if str == nil then return nil end
local strTrimmed = string.gsub(str, "{{(.-)}}", function(a) return a end) local strTrimmed = string.gsub(str, "{{(.-)}}", function(a) return a end)
if #strTrimmed < #str then if #strTrimmed < #str then
return EID.InlineIcons[strTrimmed] or nil return EID.InlineIcons[strTrimmed] or nil
+18 -24
View File
@@ -30,7 +30,7 @@ require("descriptions.ab+.bul")
require("descriptions.ab+.fr") require("descriptions.ab+.fr")
--require("descriptions.ab+.pl") -- WIP --require("descriptions.ab+.pl") -- WIP
require("descriptions.ab+.pt") require("descriptions.ab+.pt")
--require("descriptions.ab+.ru") -- WIP require("descriptions.ab+.ru") -- WIP
require("descriptions.ab+.spa") require("descriptions.ab+.spa")
require("eid_data") require("eid_data")
@@ -83,9 +83,8 @@ local function posY()
end end
function printDescription(desc) function printDescription(desc)
local Description = desc[3]
local padding = posY() local padding = posY()
local itemType = EID.itemConfig:GetCollectible(desc[1]).Type local itemType = EID.itemConfig:GetCollectible(desc.ID).Type
--Display ItemType / Charge --Display ItemType / Charge
if EIDConfig["ShowItemType"] and (itemType == 3 or itemType == 4) then if EIDConfig["ShowItemType"] and (itemType == 3 or itemType == 4) then
@@ -102,7 +101,7 @@ function printDescription(desc)
Vector(0, 0) Vector(0, 0)
) )
if itemType == 3 then -- Display Charge if itemType == 3 then -- Display Charge
IconSprite:Play(EID.itemConfig:GetCollectible(desc[1]).MaxCharges) IconSprite:Play(EID.itemConfig:GetCollectible(desc.ID).MaxCharges)
IconSprite:Update() IconSprite:Update()
IconSprite:Render( IconSprite:Render(
Vector(EIDConfig["XPosition"], padding + offsetY), Vector(EIDConfig["XPosition"], padding + offsetY),
@@ -125,7 +124,7 @@ function printDescription(desc)
end end
end end
EID:renderString( EID:renderString(
EID:getObjectName(desc[1], "collectible"), desc.Name,
Vector(EIDConfig["XPosition"] + offset * EIDConfig["Scale"], padding - 4), Vector(EIDConfig["XPosition"] + offset * EIDConfig["Scale"], padding - 4),
Vector(EIDConfig["Scale"], EIDConfig["Scale"]), Vector(EIDConfig["Scale"], EIDConfig["Scale"]),
EID:getNameColor(), EID:getNameColor(),
@@ -136,8 +135,8 @@ function printDescription(desc)
end end
--Display Transformation --Display Transformation
if not (desc[2] == "0" or desc[2] == "" or desc[2] == nil) then if not (desc.Transformation == "0" or desc.Transformation == "" or desc.Transformation == nil) then
local transformationName = EID:getTransformationName(desc[2]) local transformationName = EID:getTransformationName(desc.Transformation)
local transformSprite = EID.TransformationIcons[transformationName] local transformSprite = EID.TransformationIcons[transformationName]
if transformSprite == nil then if transformSprite == nil then
transformSprite = EID.TransformationIcons["Custom"] transformSprite = EID.TransformationIcons["Custom"]
@@ -167,21 +166,16 @@ function printDescription(desc)
padding = padding + lineHeight * EIDConfig["Scale"] padding = padding + lineHeight * EIDConfig["Scale"]
end end
end end
printBulletPoints(Description, padding) printBulletPoints(desc.Description, padding)
end end
function printTrinketDescription(desc, objType) function printTrinketDescription(desc, objType)
local Description = desc[2]
local padding = posY() local padding = posY()
--Display Itemname --Display Itemname
if EIDConfig["ShowItemName"] then if EIDConfig["ShowItemName"] then
local name = EID:getObjectName(desc[1], objType)
if objType == "custom" then
name = desc[2][1]
Description = desc[2][2]
end
EID:renderString( EID:renderString(
name, desc.Name,
Vector(EIDConfig["XPosition"], padding - 4), Vector(EIDConfig["XPosition"], padding - 4),
Vector(EIDConfig["Scale"], EIDConfig["Scale"]), Vector(EIDConfig["Scale"], EIDConfig["Scale"]),
EID:getNameColor(), EID:getNameColor(),
@@ -190,7 +184,7 @@ function printTrinketDescription(desc, objType)
padding = padding + lineHeight * EIDConfig["Scale"] padding = padding + lineHeight * EIDConfig["Scale"]
end end
printBulletPoints(Description, padding) printBulletPoints(desc.Description, padding)
end end
function printBulletPoints(description, padding) function printBulletPoints(description, padding)
@@ -205,7 +199,7 @@ function printBulletPoints(description, padding)
if EID:getIcon(word) ~= nil then if EID:getIcon(word) ~= nil then
wordLength = EID:getIcon(word)[3] wordLength = EID:getIcon(word)[3]
end end
if curLength + wordLength <= textboxWidth then if curLength + wordLength <= textboxWidth or curLength < 25 then
text = text .. word .. " " text = text .. word .. " "
curLength = curLength + wordLength curLength = curLength + wordLength
else else
@@ -368,10 +362,10 @@ local function onRender(t)
if EID:getModDescription(__eidTrinketDescriptions, closest.SubType) then if EID:getModDescription(__eidTrinketDescriptions, closest.SubType) then
printTrinketDescription( printTrinketDescription(
{closest.SubType, EID:getModDescription(__eidTrinketDescriptions, closest.SubType)}, {closest.SubType, EID:getModDescription(__eidTrinketDescriptions, closest.SubType)},
"trinket" "trinkets"
) )
elseif closest.SubType <= 128 then elseif closest.SubType <= 128 then
printTrinketDescription(EID:getDescriptionObj("trinkets",closest.SubType), "trinket") printTrinketDescription(EID:getDescriptionObj("trinkets",closest.SubType), "trinkets")
else else
printTrinketDescription({closest.SubType, EID.itemConfig:GetTrinket(closest.SubType).Description}) printTrinketDescription({closest.SubType, EID.itemConfig:GetTrinket(closest.SubType).Description})
end end
@@ -409,9 +403,9 @@ local function onRender(t)
return return
end end
if EID:getModDescription(__eidCardDescriptions, closest.SubType) then if EID:getModDescription(__eidCardDescriptions, closest.SubType) then
printTrinketDescription({closest.SubType, EID:getModDescription(__eidCardDescriptions, closest.SubType)}, "card") printTrinketDescription({closest.SubType, EID:getModDescription(__eidCardDescriptions, closest.SubType)}, "cards")
elseif closest.SubType <= 54 then elseif closest.SubType <= 54 then
printTrinketDescription(EID:getDescriptionObj("cards", closest.SubType), "card") printTrinketDescription(EID:getDescriptionObj("cards", closest.SubType), "cards")
CardSprite:Play(tostring(closest.SubType)) CardSprite:Play(tostring(closest.SubType))
CardSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"]) CardSprite.Scale = Vector(EIDConfig["Scale"], EIDConfig["Scale"])
CardSprite:Update() CardSprite:Update()
@@ -439,9 +433,9 @@ local function onRender(t)
local identified = pool:IsPillIdentified(pillColor) local identified = pool:IsPillIdentified(pillColor)
if (identified or EIDConfig["ShowUnidentifiedPillDescriptions"]) then if (identified or EIDConfig["ShowUnidentifiedPillDescriptions"]) then
if EID:getModDescription(__eidPillDescriptions, pillEffect) then if EID:getModDescription(__eidPillDescriptions, pillEffect) then
printTrinketDescription({pillEffect, EID:getModDescription(__eidPillDescriptions, pillEffect)}, "pill") printTrinketDescription({pillEffect, EID:getModDescription(__eidPillDescriptions, pillEffect)}, "pills")
elseif pillEffect < 47 then elseif pillEffect < 47 then
printTrinketDescription(EID:getDescriptionObj("pills", pillEffect + 1), "pill") printTrinketDescription(EID:getDescriptionObj("pills", pillEffect + 1), "pills")
else else
EID:renderString( EID:renderString(
EIDConfig["ErrorMessage"], EIDConfig["ErrorMessage"],
@@ -509,4 +503,4 @@ if ModConfigMenu then
EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame) EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame)
end end
--require("eid_debugging") require("eid_debugging")