3 local concat = table.concat
4 local insert = table.insert
5 local sprintf = string.format
8 local minetest_example_header = [[
9 # This file contains a list of all available settings and their default value for minetest.conf
11 # By default, all the settings are commented and not functional.
12 # Uncomment settings by removing the preceding #.
14 # minetest.conf is read by default from:
17 # Any other path can be chosen by passing the path as a parameter
18 # to the program, eg. "minetest.exe --config ../minetest.conf.example".
20 # Further documentation:
21 # http://wiki.minetest.net/
25 local group_format_template = [[
29 # spread = (%s, %s, %s),
39 local function create_minetest_conf_example()
40 local result = { minetest_example_header }
41 for _, entry in ipairs(settings) do
42 if entry.type == "category" then
43 if entry.level == 0 then
44 insert(result, "#\n# " .. entry.name .. "\n#\n\n")
46 insert(result, rep("#", entry.level))
47 insert(result, "# " .. entry.name .. "\n\n")
50 local group_format = false
51 if entry.noise_params and entry.values then
52 if entry.type == "noise_params_2d" or entry.type == "noise_params_3d" then
56 if entry.comment ~= "" then
57 for _, comment_line in ipairs(entry.comment:split("\n", true)) do
58 insert(result, "# " .. comment_line .. "\n")
61 insert(result, "# type: " .. entry.type)
63 insert(result, " min: " .. entry.min)
66 insert(result, " max: " .. entry.max)
68 if entry.values and entry.noise_params == nil then
69 insert(result, " values: " .. concat(entry.values, ", "))
71 if entry.possible then
72 insert(result, " possible values: " .. concat(entry.possible, ", "))
75 if group_format == true then
76 insert(result, sprintf(group_format_template, entry.name, entry.values[1],
77 entry.values[2], entry.values[3], entry.values[4], entry.values[5],
78 entry.values[6], entry.values[7], entry.values[8], entry.values[9],
82 if entry.default ~= "" then
83 append = " " .. entry.default
85 insert(result, sprintf("# %s =%s\n\n", entry.name, append or ""))
92 local translation_file_header = [[
93 // This file is automatically generated
94 // It conatins a bunch of fake gettext calls, to tell xgettext about the strings in config files
95 // To update it, refer to the bottom of builtin/mainmenu/dlg_settings_advanced.lua
99 local function create_translation_file()
100 local result = { translation_file_header }
101 for _, entry in ipairs(settings) do
102 if entry.type == "category" then
103 insert(result, sprintf("\tgettext(%q);", entry.name))
105 if entry.readable_name then
106 insert(result, sprintf("\tgettext(%q);", entry.readable_name))
108 if entry.comment ~= "" then
109 local comment_escaped = entry.comment:gsub("\n", "\\n")
110 comment_escaped = comment_escaped:gsub("\"", "\\\"")
111 insert(result, "\tgettext(\"" .. comment_escaped .. "\");")
115 insert(result, "}\n")
116 return concat(result, "\n")
119 local file = assert(io.open("minetest.conf.example", "w"))
120 file:write(create_minetest_conf_example())
123 file = assert(io.open("src/settings_translation_file.cpp", "w"))
124 -- If 'minetest.conf.example' appears in the 'bin' folder, the line below may have to be
125 -- used instead. The file will also appear in the 'bin' folder.
126 --file = assert(io.open("settings_translation_file.cpp", "w"))
127 file:write(create_translation_file())