aboutsummaryrefslogtreecommitdiff
path: root/builtin/mainmenu/tab_settings.lua
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-10-18 02:18:10 +0200
committerest31 <MTest31@outlook.com>2015-10-18 02:18:10 +0200
commitf3d82567c9dc98d5b1fa8724055727956ed351eb (patch)
treef035dc4496678e0f1cad06af6577493dc788720c /builtin/mainmenu/tab_settings.lua
parentc4d18623440b58b9f90629c798687608bc32c6da (diff)
downloadminetest-f3d82567c9dc98d5b1fa8724055727956ed351eb.tar.gz
minetest-f3d82567c9dc98d5b1fa8724055727956ed351eb.tar.bz2
minetest-f3d82567c9dc98d5b1fa8724055727956ed351eb.zip
Display sane output for empty descriptions
According to its man page, the function gettext(3) "may return a nonempty string" when msgid is "". This commit fixes a bug where the comment "" for some settings caused gettext to return a "nonempty string", in this case header info of the po file.
Diffstat (limited to 'builtin/mainmenu/tab_settings.lua')
-rw-r--r--builtin/mainmenu/tab_settings.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua
index 90d245337..f3605fd48 100644
--- a/builtin/mainmenu/tab_settings.lua
+++ b/builtin/mainmenu/tab_settings.lua
@@ -234,7 +234,15 @@ local function create_change_setting_formspec(dialogdata)
formspec = formspec .. ",,"
- for _, comment_line in ipairs(fgettext_ne(setting.comment):split("\n")) do
+ local comment_text = ""
+
+ -- fgettext_ne("") doesn't have to return "", according to specification of gettext(3)
+ if setting.comment == "" then
+ comment_text = fgettext_ne("(No description of setting given)")
+ else
+ comment_text = fgettext_ne(setting.comment)
+ end
+ for _, comment_line in ipairs(comment_text:split("\n")) do
formspec = formspec .. "," .. core.formspec_escape(comment_line) .. ","
end
@@ -334,7 +342,7 @@ local function create_settings_formspec(tabview, name, tabdata)
else
name = entry.name
end
-
+
if entry.type == "category" then
current_level = entry.level
formspec = formspec .. "#FFFF00," .. current_level .. "," .. core.formspec_escape(name) .. ",,"
@@ -385,7 +393,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
return true
end
end
-
+
if fields["btn_edit"] or list_enter then
local setting = settings[selected_setting]
if setting.type ~= "category" then