Heya, not sure if this is a duplicate of the earlier .cfg post or not (different locales, spellings), so here goes ...
I'd like a startup-option to allow the string to be toggled between "Aluminum" (North American) and "Aluminium" (Everyone else?) strings.
Utility function in a .lua script to perform a ternary operation:
local function ternary_op( cond, true_case, false_case )
if cond then return true_case else return false_case end
end
A line in your settings.lua:
data:extend({{ type = 'bool-setting', name = "bz_aluminum-modus", setting_type = 'startup',
localised_name={"bz_aluminum-modus.name"},
localised_description={"bz_aluminum-modus.desc"}, default_value = false }});
When referencing "Aluminum"/"aluminum" (in a data.lua), perform a locale query, much like so:
local capitalized = {
"bz_aluminum-modus" .. ternary_op( settings.startup["bz_aluminum-modus"], ".gn_cap", ".na_cap" ) }
local lowercase = {
"bz_aluminum-modus" .. ternary_op( settings.startup["bz_aluminum-modus"], ".gn_low", ".na_low" ) }
The above keys can then be used as parameters to parametric locale queries, or stand-alone.
With a locale file containing the following content:
[bz_aluminum-modus]
gn_cap=Aluminium
gn_low=aluminium
na_cap=Aluminum
na_low=aluminum
name=Use global naming ("Aluminium") or North American ("Aluminum")
desc=Toggle ON to use global naming, OFF (Default) to use North American naming.
Now, although the above code works, in my mind... heh...
The above code is untested, but that should more-or-less allow alternating between the two accepted names for Aluminium/Aluminum.
Now you've got keys for both the capitalized and the lowercase versions.
(Any questions?)
Best Regards,