Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
est31 committed Oct 18, 2015
1 parent c4d1862 commit f3d8256
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions builtin/mainmenu/tab_settings.lua
Expand Up @@ -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

Expand Down Expand Up @@ -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) .. ",,"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f3d8256

Please sign in to comment.