Localised string "if key is unknown use something else" (or equivalent)

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3740
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Localised string "if key is unknown use something else" (or equivalent)

Post by eradicator » Tue Jun 04, 2019 5:10 pm

What?

I want to specify a localised string so that if one component of it produces an "Unknown key:" it uses something else instead.

Speculative example:

Code: Select all

tooltip = {'my.tooltip-preset',{item-description.wooden-chest,my.no-description-placeholder,mode='use-first'}}
Why?

(Disclaimer: I don't really care *how* this is technically solved. So above is only a wild idea. I'm totally fine with anything better. Like making it possible for mods to know if a localised string is valid or not :p)

The problem is that certain localised strings can not be used in good looking mod guis because they produce garbage 90% of the time (i.e. "Unknown key:"). A prime cause of this are item descriptions, because there's only very few that have them. And from the mod side it's impossible to know if any given loc_string is valid or not.

Code: Select all

/c
game.player.gui.center.clear() 
game.player.gui.center.add{
 type="label",
 caption=game.item_prototypes['wooden-chest'].localised_description
 }
This is not limited to base keys though, for example i have a use-case for localised surface names, but i want to fall back to the internal name if me (or the surface-creating mod's author) haven't localised a name yet.

This is mostly annoying on tooltips, but it'd be awesome if a generic solution for all localised texts existed.

A good example is also the mod on the portal (which i can't find right now...) that extends the tooltip of mod settings to include the default value. But because most settings don't have a description it looks like this most of the time:
From Arumbas Stream @17:33
unknownkey.png
unknownkey.png (51.91 KiB) Viewed 115 times
Author of: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3740
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Localised string "if key is unknown use something else" (or equivalent)

Post by eradicator » Tue Jun 04, 2019 6:18 pm

Maybe a locale.cfg specification would be simple enough to be realistic?

Code: Select all

[my]
tooltip-preset=Lorem ipsum __1_or_2_or_3__ dolor sit amet.
Author of: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding interface requests”

Who is online

Users browsing this forum: No registered users