[2.1.20] The “on_string_translated” event does not return the localized name for all in-game vanilla items

Bugs that are actually features.
User avatar
picklock
Filter Inserter
Filter Inserter
Posts: 268
Joined: Sat Nov 09, 2019 6:49 am
Contact:

[2.1.20] The “on_string_translated” event does not return the localized name for all in-game vanilla items

Post by picklock »

What did you do?
In my mod, “Picklocks Rocket Silo Stats,” I'm trying to generate a list of the localized names of items that were launched into space as payloads. To do this, I’m trying to obtain the localized names of the items via calls to “request_translation” through the “on_string_translated” event.

What happened?
However, for some in-game vanilla items, the “on_string_translated” event triggered by “request_translation” returns “false” as the translation status, and therefore no localized name for the item is returned as a result.
See the following excerpt from a log file as an example.

Code: Select all

  32.831 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = true - player index = 1 - unique id = 1 - localised_string = item-name.space-platform-starter-pack item name = space-platform-starter-pack result = Grundgerüst für Raumplattform
  32.831 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = true - player index = 1 - unique id = 2 - localised_string = item-name.space-platform-starter-pack item name = space-platform-starter-pack result = Grundgerüst für Raumplattform
  32.831 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = false - player index = 1 - unique id = 3 - localised_string = item-name.space-platform-hub item name = space-platform-hub result = 
  32.831 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = false - player index = 1 - unique id = 4 - localised_string = item-name.space-platform-hub item name = space-platform-hub result = 
  32.831 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = false - player index = 1 - unique id = 5 - localised_string = item-name.pipe item name = pipe result = 
  32.832 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = false - player index = 1 - unique id = 6 - localised_string = item-name.pipe item name = pipe result = 
  32.832 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = false - player index = 1 - unique id = 7 - localised_string = item-name.pipe-to-ground item name = pipe-to-ground result = 
  32.832 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = false - player index = 1 - unique id = 8 - localised_string = item-name.pipe-to-ground item name = pipe-to-ground result = 
  32.832 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = false - player index = 1 - unique id = 9 - localised_string = item-name.construction-robot item name = construction-robot result = 
  32.832 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = false - player index = 1 - unique id = 10 - localised_string = item-name.construction-robot item name = construction-robot result = 
  32.832 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = true - player index = 1 - unique id = 11 - localised_string = item-name.iron-plate item name = iron-plate result = Eisenplatte
  32.832 Script @__PicksRocketStats__/control.lua:59: [Picklocks rocket silo stats V2.1.0]: pi_rss_on_string_translated: translated = true - player index = 1 - unique id = 12 - localised_string = item-name.iron-plate item name = iron-plate result = Eisenplatte
What did you expect to happen instead? It might be obvious to you, but do it anyway!
I expected the localized name to be returned by the “on_string_translated” event for all in-game vanilla items.

Does it happen always, once, or sometimes?
This happens every time for the same items whenever the “on_string_translated” event is triggered for these items by a call to “request_translation.”

Attached are the latest log file, a test save file, and the current developer version of my mod, “Picklocks Rocket Silo Stats.”
Attachments
RoketStats_Translation_Test_04.zip
(3.49 MiB) Downloaded 7 times
PicksRocketStats_2.1.0.zip
(101.06 KiB) Downloaded 8 times
factorio-current.log
(25.05 KiB) Downloaded 10 times
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters | Picklocks QuickBar Import/Export | Picklocks Nauvis Cliff-Explosives
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4921
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.1.20] The “on_string_translated” event does not return the localized name for all in-game vanilla items

Post by boskid »

Thanks for the report. Locale system is not aware of game logic (item name getting name from the entity it places) which means that the observed behavior is correct: your report points that `item-name.pipe` returns an error. Can you show me where this locale is provided? If you run '/c game.print(serpent.line( prototypes.item["pipe"].localised_name ))' you will observe that this name references an entity-name.pipe which is the correct name for this item.
User avatar
picklock
Filter Inserter
Filter Inserter
Posts: 268
Joined: Sat Nov 09, 2019 6:49 am
Contact:

Re: [2.1.20] The “on_string_translated” event does not return the localized name for all in-game vanilla items

Post by picklock »

Hi boskid!

Thanks for the explanation. I wasn't aware of that. I assumed that all item names were localized. But now that I think about it, the way you've implemented the system makes perfect sense—it avoids duplicate translations and reduces the effort required for localization.

Your explanations are also helping me implement the sorting function in my mod after all. Thanks for that, too.
My Mods: Picklocks Fusion Power | Picklocks Inserter | Picklocks Lithium Polymer Accumulator | Picklocks rocket silo stats | Picklocks Set Inventory Filters | Picklocks QuickBar Import/Export | Picklocks Nauvis Cliff-Explosives
Post Reply

Return to “Not a bug”