Page 1 of 1

Automatically generating localized names

Posted: Thu Jul 13, 2017 9:57 pm
by Reika
I have a research that adds turret range upgrades, but to do this it has to effectively clone turrets once per turret type, once per level.

This all works fine, but the problem is that the upgraded turrets (internally named [original name]-rangeboost-[level]") have no corresponding localization. As I cannot foresee all the possible turret types, nor am I willing to hardcode 800 entries for the ones I do know (Bob, 5Dim, DyTech, my Concussion, Plasma, and Cannon...), is there a way to either forcibly set a localized name (English only is fine, as it is still better than "unknown key:blah") or automatically populate the locale files? Ideally I would want the derivative turrets to appear exactly as their base counterparts.

Re: Automatically generating localized names

Posted: Thu Jul 13, 2017 10:36 pm
by Nexela
In locale.cfg

Code: Select all

[turrets]
upgrade=__1__ range_boost __2__
in data*.lua

Code: Select all

myturret.localised_name = {"turrets.upgrade", {"entity-name."..turret_name_from_loop}, level}

Re: Automatically generating localized names

Posted: Fri Jul 14, 2017 2:11 am
by Reika
Nexela wrote:In locale.cfg

Code: Select all

[turrets]
upgrade=__1__ range_boost __2__
in data*.lua

Code: Select all

myturret.localised_name = {"turrets.upgrade", {"entity-name."..turret_name_from_loop}, level}
What will that parse into?

Re: Automatically generating localized names

Posted: Fri Jul 14, 2017 2:49 am
by nucleargen
%turret_name% range_boost %level%
%turret_name% = {"entity-name."..turret_name_from_loop} - entity name from your data loop.
__1__ and __2__ are placeholders.

Re: Automatically generating localized names

Posted: Fri Jul 14, 2017 12:09 pm
by Nexela

Code: Select all

myturret.localised_name =  -- Set the localized name for this prototype  
{ --in most places if something takes a string you can use {} brackets to tell it to look for an entry in the locale table
"turrets.upgrade", --use the localization "turrets.upgradge"
 {"entity-name."..turret_name_from_loop}, --use the localization for "entity-name.turrent-name"  as the first placeholder value
 level -- use the variable level for the third argument.
}