Localizing allowed_values without duplicating entries in the *.cfg file

Place to get help with not working mods / modding interface.
Post Reply
User avatar
<NO_NAME>
Filter Inserter
Filter Inserter
Posts: 291
Joined: Tue Aug 02, 2016 9:52 am
Contact:

Localizing allowed_values without duplicating entries in the *.cfg file

Post by <NO_NAME> »

There is a series of drop-down lists in my mod settings, each containing the same allowed_values.
I know I can do localize them like this:

Code: Select all

[string-mod-setting]
my-mod-setting1-value1=Locale 1
my-mod-setting1-value2=Locale 2
# more values... (imagine 4 more lines here)
my-mod-setting1-value7=Locale 7
my-mod-setting2-value1=Locale 1
my-mod-setting2-value2=Locale 2
# more values... (imagine 4 more lines here)
my-mod-setting2-value7=Locale 7
# more settings (imagine 21 more lines here)
my-mod-setting6-value1=Locale 1
my-mod-setting6-value2=Locale 2
# more values... (imagine 4 more lines here)
my-mod-setting6-value7=Locale 7
but this way the file is almost entirely duplicates.
In this example I have 42 lines in the *.cfg file but really there is only 7 unique strings.

How can I assign arbitrary localized strings to drop-down entries, in similar way to how I can do that for setting name using the localised_name?
I am a translator. And what did you do for Factorio?
Check out my mod "Realistic Ores" and my other mods!

User avatar
<NO_NAME>
Filter Inserter
Filter Inserter
Posts: 291
Joined: Tue Aug 02, 2016 9:52 am
Contact:

Re: Localizing allowed_values without duplicating entries in the *.cfg file

Post by <NO_NAME> »

OK, a real example from my latest mod.
Rohlinheatagtmuf Hdhaotaotfnllsape'atnsasri.cfg
(30.42 KiB) Downloaded 75 times
There is 165 entries in this file but it could be only 53 (> 3x less!) if duplicates were removed.

I'm using a template of the locale file and then create duplicate files by a script but this is a problematic approach if someone decides to look into sources and they doesn't use Linux. Is there a way to do it natively in the game?
I am a translator. And what did you do for Factorio?
Check out my mod "Realistic Ores" and my other mods!

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

Re: Localizing allowed_values without duplicating entries in the *.cfg file

Post by eradicator »

<NO_NAME> wrote:
Tue Mar 09, 2021 7:59 am
create duplicate files by a script but this is a problematic approach if someone decides to look into sources and they doesn't use Linux.
Just write the locale-generation-script in lua and include it in the mod ;).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
kirazy
Filter Inserter
Filter Inserter
Posts: 416
Joined: Tue Mar 06, 2018 12:18 am
Contact:

Re: Localizing allowed_values without duplicating entries in the *.cfg file

Post by kirazy »

If you could define a LocalisedName in lua during the settings stage for allowed_values, you could resolve this easily, but it is not exposed to the API to be able to do this. Interface request time?

User avatar
<NO_NAME>
Filter Inserter
Filter Inserter
Posts: 291
Joined: Tue Aug 02, 2016 9:52 am
Contact:

Re: Localizing allowed_values without duplicating entries in the *.cfg file

Post by <NO_NAME> »

kirazy wrote:
Tue Mar 09, 2021 9:45 am
If you could define a LocalisedName in lua during the settings stage for allowed_values, you could resolve this easily, but it is not exposed to the API to be able to do this. Interface request time?
If there is really no way to do it right now then interface request time, sure as heck. (Both for names and descriptions of allowed_values.)
I am a translator. And what did you do for Factorio?
Check out my mod "Realistic Ores" and my other mods!

User avatar
<NO_NAME>
Filter Inserter
Filter Inserter
Posts: 291
Joined: Tue Aug 02, 2016 9:52 am
Contact:

Re: Localizing allowed_values without duplicating entries in the *.cfg file

Post by <NO_NAME> »

Could some mod move this topic to Modding interface requests board, please?
I am a translator. And what did you do for Factorio?
Check out my mod "Realistic Ores" and my other mods!

Post Reply

Return to “Modding help”