[SOLVED] Localising mod settings

Place to get help with not working mods / modding interface.
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

[SOLVED] Localising mod settings

Post by DRY411S »

In my settings.lua, part of it is this:

Code: Select all

  {
      type = "string-setting",
      name = "ZRecycling-difficulty",
      setting_type = "startup",
      default_value = "Expensive",
	  allowed_values = { "Expensive", "Normal" }, 
      order = "ba",
   },
I'd like to get rid of the hard coded strings and localise them with 'technology-difficulty.expensive' for example.

I cannot figure out how to do this. Can anybody help please?
Last edited by DRY411S on Sat Apr 13, 2019 3:55 pm, edited 1 time in total.
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Localising mod settings

Post by DRY411S »

Ok, so I fixed this myself. The code is no different but now there are locale settings in locale.cfg as follows.

Code: Select all

[string-mod-setting]
ZRecycling-difficulty-Expensive=Expensive
ZRecycling-difficulty-Normal=Normal
So now I have to figure out how to test the value returned, when it could be in any language.
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Localising mod settings

Post by eduran »

The value of the setting is still one of the strings defined in allowed_values. Localization only changes displayed strings.
Bilka
Factorio Staff
Factorio Staff
Posts: 3684
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Localising mod settings

Post by Bilka »

For people who find this in the future: The mod settings and their localisation are documented on the wiki: https://wiki.factorio.com/Tutorial:Mod_settings
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Localising mod settings

Post by DRY411S »

eduran wrote: Sat Apr 13, 2019 6:43 am The value of the setting is still one of the strings defined in allowed_values. Localization only changes displayed strings.
Indeed yes.

Code: Select all

difficulty = settings.startup["ZRecycling-difficulty"].value
returns the locale-name, whatever language is being displayed in the drop-down on the mod-settings screen in the game.
Bilka wrote: Sat Apr 13, 2019 7:17 am For people who find this in the future: The mod settings and their localisation are documented on the wiki: https://wiki.factorio.com/Tutorial:Mod_settings
Yes, that's how I solved the question in the first post in this topic. The wiki though is not clear on the 2nd part described by eduran. My confusion wasn't helped by having allowed_values whose lacale names were the same as their English translation!
Bilka
Factorio Staff
Factorio Staff
Posts: 3684
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Localising mod settings

Post by Bilka »

DRY411S wrote: Sat Apr 13, 2019 8:37 am The wiki though is not clear on the 2nd part described by eduran. My confusion wasn't helped by having allowed_values whose locale names were the same as their English translation!
I reworded the wiki, hopefully it is more clear now.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Modding help”