Skip to content

Commit

Permalink
Fix for translating empty strings
Browse files Browse the repository at this point in the history
Fix for incorrect translation of empty strings

In the key change menu, when a button key not have name an empty string is passed to gettext.
The empty string is reserved for gettext to return de header of the .po file an this is shoved in the button
  • Loading branch information
minduser00 authored and sfan5 committed Apr 9, 2018
1 parent d58801a commit 9a06d6a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/gettext.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ extern wchar_t *utf8_to_wide_c(const char *str);
// The returned string is allocated using new
inline const wchar_t *wgettext(const char *str)
{
return utf8_to_wide_c(gettext(str));
// We must check here that is not an empty string to avoid trying to translate it
return str[0] ? utf8_to_wide_c(gettext(str)) : L"";
}

inline std::string strgettext(const std::string &text)
{
return gettext(text.c_str());
return text.empty() ? "" : gettext(text.c_str());
}

0 comments on commit 9a06d6a

Please sign in to comment.