Page 1 of 1

[SOLVED] Localising mod settings

Posted: Fri Apr 12, 2019 10:24 pm
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?

Re: Localising mod settings

Posted: Sat Apr 13, 2019 6:27 am
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.

Re: Localising mod settings

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

Re: Localising mod settings

Posted: Sat Apr 13, 2019 7:17 am
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

Re: Localising mod settings

Posted: Sat Apr 13, 2019 8:37 am
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!

Re: Localising mod settings

Posted: Sat Apr 13, 2019 9:18 am
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.