Localization with description references

Place to get help with not working mods / modding interface.
Post Reply
kerboom
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 05, 2019 8:43 pm
Contact:

Localization with description references

Post by kerboom »

I am working on my first mod, and part of what it does is create alternate versions of existing entities. For the entity-name and entity-description localization of the new entities, I would like to append a string to the localized name and description of the original entities.

I can do this in locale.cfg for the name by writing

Code: Select all

locomotive-mu=MU __ENTITY__locomotive__
And get the result
MU Locomotive
But there does not seem to be a keyword to reference localized entity-descriptions the same way. Do I need to put it in the prototype with a script in data.lua? Is it worth asking for a new keyword, for example __ENTITY-DESCRIPTION__, to concatenate localization strings the easy way?

kerboom
Burner Inserter
Burner Inserter
Posts: 7
Joined: Tue Mar 05, 2019 8:43 pm
Contact:

Re: Localization with description references

Post by kerboom »

I solved my problem using data.lua scripting. While you cannot access data.raw["category"]["original-item"].localised_description correctly, you can use locale tags from any item in the game to assign localised_description to your new item. You can use Lua string concatenation to retrieve them dynamically:

Code: Select all

newItem.localised_description = { 'description.new-item-template', 
          {'item-description.' .. originalItem.name} }
The old item name goes inside its own curly braces so it is also pulled from the locale files.

In locale.cfg, you add your template like this (the "description" category is arbitrary):

Code: Select all

[description]
new-item-template=__1__ This comes after the original description.

Post Reply

Return to “Modding help”