Skip to content

Commit f3d8256

Browse files
committedOct 18, 2015
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.
1 parent c4d1862 commit f3d8256

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed
 

‎builtin/mainmenu/tab_settings.lua

+11-3
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,15 @@ local function create_change_setting_formspec(dialogdata)
234234

235235
formspec = formspec .. ",,"
236236

237-
for _, comment_line in ipairs(fgettext_ne(setting.comment):split("\n")) do
237+
local comment_text = ""
238+
239+
-- fgettext_ne("") doesn't have to return "", according to specification of gettext(3)
240+
if setting.comment == "" then
241+
comment_text = fgettext_ne("(No description of setting given)")
242+
else
243+
comment_text = fgettext_ne(setting.comment)
244+
end
245+
for _, comment_line in ipairs(comment_text:split("\n")) do
238246
formspec = formspec .. "," .. core.formspec_escape(comment_line) .. ","
239247
end
240248

@@ -334,7 +342,7 @@ local function create_settings_formspec(tabview, name, tabdata)
334342
else
335343
name = entry.name
336344
end
337-
345+
338346
if entry.type == "category" then
339347
current_level = entry.level
340348
formspec = formspec .. "#FFFF00," .. current_level .. "," .. core.formspec_escape(name) .. ",,"
@@ -385,7 +393,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
385393
return true
386394
end
387395
end
388-
396+
389397
if fields["btn_edit"] or list_enter then
390398
local setting = settings[selected_setting]
391399
if setting.type ~= "category" then

0 commit comments

Comments
 (0)
Please sign in to comment.