util: Filter out message context of untranslated strings

Commit 5a47ad837b changed the definition of NC_() to include the
message context, so that gettext can correctly disambiguate strings
like "S". However this does only work when gettext actually returns
a translation from the catalogue; if the string is not found, we
need to strip the context again to not have it show up in the UI.

https://bugzilla.gnome.org/show_bug.cgi?id=745521
This commit is contained in:
Florian Müllner 2015-03-03 15:03:35 +01:00
parent 6c5861ab3d
commit f85d68aa70

View File

@ -223,11 +223,13 @@ shell_util_translate_time_string (const char *str)
{ {
const char *locale = g_getenv ("LC_TIME"); const char *locale = g_getenv ("LC_TIME");
const char *res; const char *res;
char *sep;
if (locale) if (locale)
setlocale (LC_MESSAGES, locale); setlocale (LC_MESSAGES, locale);
res = gettext (str); sep = strchr (str, '\004');
res = g_dpgettext (NULL, str, sep ? str - sep : 0);
setlocale (LC_MESSAGES, ""); setlocale (LC_MESSAGES, "");