Is it possible to do localisation dynamical?
Is it possible to do localisation dynamical?
I am working on a mod that has a few Items with a configurable number of tiers. Is it possible to do the localisation dynamical or set the screen name is Code?
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Is it possible to do localisation dynamical?
You can specify the localised name for each prototype in the prototype definition.
The base game does this for example for barreling:
The localization file would then look something like this (from memory):
Code: Select all
localised_name = {"some_group.some_localisation_identifier", some_variable}
Code: Select all
-- Generates a barrel item with the provided name and fluid definition using the provided empty barrel stack size
local function create_barrel_item(name, fluid, empty_barrel_item)
local result =
{
type = "item",
name = name,
localised_name = {"item-name.filled-barrel", {"fluid-name." .. fluid.name}},
icons = generate_barrel_item_icons(fluid, empty_barrel_item),
icon_size = 32,
flags = {"goes-to-main-inventory"},
subgroup = "fill-barrel",
order = "b[" .. name .. "]",
stack_size = empty_barrel_item.stack_size
}
data:extend({result})
return result
end
Code: Select all
[some_group]
some_localisation_identifier=SomeItemName Tier __1__
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Is it possible to do localisation dynamical?
Alternatively, this works too
Say your items are named... thing-1, thing-2 etc.
the __ITEM__thing__ part will assign the locale entry from "thing". then add the " 1" to the end of it. etc.
I use that in my mod, for example, on the artillery wagon to add MK2 and MK3 to the end of it, the name then reads as "Artillery wagon MK2", and the best part is that if you switch to another language, it automatically works with the other languages Artillery wagon entry.
Say your items are named... thing-1, thing-2 etc.
Code: Select all
[item-name]
thing=Thing
thing-1=__ITEM__thing__ 1
thing-2=__ITEM__thing__ 2
I use that in my mod, for example, on the artillery wagon to add MK2 and MK3 to the end of it, the name then reads as "Artillery wagon MK2", and the best part is that if you switch to another language, it automatically works with the other languages Artillery wagon entry.