Page 1 of 1

localized_name -> plain string [seems very simple]

Posted: Thu Jan 25, 2018 7:04 am
by thelordodin
Please if possible expose function for converting localized_name to plain string.
I found no way to do it. (I was looking at API - http://lua-api.factorio.com/latest/Conc ... isedString - there is no way to do it described stated there).
The problem obvously isn't limited to non-english users because even in english display name often differs from internal name.

Use case:
filtering technologies by it's displayed name.

for name, tech in pairs(player.force.technologies) do
...
if not matches(tech.research_unit_ingredients, "name", t) and
(
not global.text_filter
or global.text_filter == ""
or tech.name and string.find(string.lower(tech.name), string.lower(global.text_filter), 1, true)
or name and string.find(string.lower(name), string.lower(global.text_filter), 1, true)
-- or tech.localized_name and string.find(string.lower(tech.localized_name), string.lower(global.text_filter), 1, true)
)

Mods wishing to have this are:
- Auto research
- Reseach queue

Re: localized_name -> plain string [seems very simple]

Posted: Thu Jan 25, 2018 8:12 am
by Rseding91
This isn't possible because the translations aren't deterministic across platforms. One person can have "copper-ore" translate to "An ore that's made of copper" and another could have it translate to "Purple fish" and it would still be valid.

Additionally the translation depends on the players current locale which isn't part of the game state data and isn't known by anyone except the local player.

Re: localized_name -> plain string [seems very simple]

Posted: Thu Jan 25, 2018 8:28 am
by thelordodin
Well, I just want to get that string which is displayed to user, that's it. I don't need all of them.
My use case is quick search field in research queue mod.
I just want to filter technologies by part of it's current localized name.

Re: localized_name -> plain string [seems very simple]

Posted: Thu Jan 25, 2018 4:03 pm
by eradicator
The only way to currently achieve this is to include all localized strings in your mods lua state and have the player chose a search language within your mod. :/ (i.e. reimplement localization)

@Rseding: How feasible would it be to dump (to file) the localized string of a different locale than the current one? I.e. to get a list of strings for this purpose without restarting the game for every locale required.