Page 1 of 1

Localisation in log files

Posted: Thu Jan 03, 2019 2:39 pm
by ActionJackson
Hello!

I'm working on a fun pet project that allows for traversing items and recipes via a web interface, with the ultimate goal being you can load in whatever mods you are using and create a dump of the information I need from items and recipes to a log file from within factorio. I take that data and upload it to my site, parse it, and make a snazzy GUI that can show you how to make whatever item, what assembling machine it takes, recipe info, etc. For a days work, it works pretty well but I'm not near ready enough to post it anywhere. But I did come across one problem...

The LuaEntityPrototype class "localisation_name" (and similarly in LuaRecipePrototype) does not contain any useful information. I'd love to be able to pull the localisation out so I don't have to copy and paste from a ton of .cfg files and build my localisations that way. It seems... unreliable doing it that way.

Recommendation:

Add localisation_names to Lua*Prototype objects to contain a key/value pair of "language" to "definition"...
CODE: SELECT ALL

Code: Select all

game.entity_prototypes[x].localisation_names = { "en" : "Foo", "de" : "Bar", "ga-IE" : "Bash" } etc
(pardon me if this incorrect syntax but it's late and I'm very tired :D )

with that I'd be able to pull the language(s) that I want to include for a given item, recipe, tile, etc

Similarly, if I'm missing something please feel free to let me know if this possible and I've missed it.

Re: Localisation in log files

Posted: Thu Jan 03, 2019 7:30 pm
by Rseding91
As talked about on Discord you can write directly to the file using the localised_name and it will output the translation. The actual translation is not available for mods due to determinism.

Re: Localisation in log files

Posted: Thu Jan 03, 2019 7:33 pm
by ActionJackson
Well you can log() the name, but not write it to a file with game.write_file

that's why i was suggesting a table of all loaded localisations and i can pick the one i want after that with a simple comparison. I have what I need for now, it's just not ideal.

Re: Localisation in log files

Posted: Thu Jan 03, 2019 8:13 pm
by Rseding91
ActionJackson wrote: Thu Jan 03, 2019 7:33 pm Well you can log() the name, but not write it to a file with game.write_file

that's why i was suggesting a table of all loaded localisations and i can pick the one i want after that with a simple comparison. I have what I need for now, it's just not ideal.
viewtopic.php?f=3&t=60548
0.16.44 Changelog wrote:* Added support for localised strings in LuaGameScript::write_file.

Re: Localisation in log files

Posted: Thu Jan 03, 2019 8:14 pm
by ActionJackson
Thanks!