Page 1 of 1

Custom item/entity translations

Posted: Sat May 28, 2016 2:53 pm
by bNarFProfCrazy
It would be nice if I could define in the prototype how an Entity/Item should be called in game without specifying a translation for the data.name key.

Example:

Code: Select all

tree_type = data.raw["tree"]["tree-02"]
tree_item = {
		type = "item",
		name = tree_type.name .. "-sapling",
		icon = tree_type.icon,
...
It would be nice if I could configure a function that resolves the name.

Code: Select all

localized_string("mytree.naming-template", localized_string("mytree.sapling"), localized_string("tree-02"))
So I only have to provide two translations "mytree.naming-template" (__2__ __1__) and "mytree.sapling" (Sapling) for the result "Tree 2 Sapling").
(This is also intended as a help for MK2-MK100 translations that only differ in the number and are a pain to maintain for different languages.)

Why I want this?
Well because I don't want to maintain translations for other (mod added) trees as well that would be all build in the same way. "Tree 9 Sapling", "Rubber Tree Sapling", "Dessert tree Sapling"....

------------------------------------------------

Or that I can provide a reference to a translation to be used.

Code: Select all

		type = "entity",
		name = tree_type.name .. "-small",
		localiced_name = tree_type.name,
		icon = tree_type.icon,
...
Maing "tree-02-small" using the same translations as "tree-02".

Why I want this:
Because in some cases, I have quite a lot different versions of the same thing and I don't want to maintain a translation for each of them.
(It does not matter if the tree is small or big, the only important thing is the name and maybe that the tree is not mature yet/is still growing)

Re: Custom item/entity translations

Posted: Sat May 28, 2016 5:50 pm
by DaveMcW
naming-template=Tree __1__ __2__
sapling=Sapling
tree-02=2

Code: Select all

function localized_string(template, size, number)
  return {template, number, size}
end

game.player.print(localized_string("naming-template", "sapling", "tree-02"))

Re: Custom item/entity translations

Posted: Sun Apr 02, 2017 9:32 pm
by Rseding91
You can already do this. You just define the "localised_name" key for a prototype and it uses that.

Re: Custom item/entity translations

Posted: Sun Apr 02, 2017 10:16 pm
by bNarFProfCrazy
Well that question is almost a year old and IIRC at that time that feature was not present.
I already found it in the mean time. Thanks for the answer anyway.

For everybody that might stumble about this thread in the future.
Here is the link to the docs: http://lua-api.factorio.com/latest/Conc ... isedString