gstrfuncs: Fix translation issues

The tool that extracts the translatable strings to .po files does not
cope with the G_GUINTX_FORMAT macros, so we preformat the numbers to
strings and use the strings in the translatable error messages.
This commit is contained in:
Krzesimir Nowak 2017-05-10 16:03:20 +02:00
parent 6b19907a4f
commit e8222c3343

View File

@ -3263,11 +3263,15 @@ g_ascii_string_to_signed (const gchar *str,
} }
if (saved_errno == ERANGE || number < min || number > max) if (saved_errno == ERANGE || number < min || number > max)
{ {
gchar *min_str = g_strdup_printf ("%" G_GINT64_FORMAT, min);
gchar *max_str = g_strdup_printf ("%" G_GINT64_FORMAT, max);
g_set_error (error, g_set_error (error,
G_NUMBER_PARSER_ERROR, G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS, G_NUMBER_PARSER_ERROR, G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS,
_("Number “%" G_GINT64_FORMAT "” is out of bounds" _("Number “%s” is out of bounds [%s, %s]"),
" [%" G_GINT64_FORMAT ", %" G_GINT64_FORMAT "]"), str, min_str, max_str);
number, min, max); g_free (min_str);
g_free (max_str);
return FALSE; return FALSE;
} }
if (out_num != NULL) if (out_num != NULL)
@ -3362,11 +3366,15 @@ g_ascii_string_to_unsigned (const gchar *str,
} }
if (saved_errno == ERANGE || number < min || number > max) if (saved_errno == ERANGE || number < min || number > max)
{ {
gchar *min_str = g_strdup_printf ("%" G_GUINT64_FORMAT, min);
gchar *max_str = g_strdup_printf ("%" G_GUINT64_FORMAT, max);
g_set_error (error, g_set_error (error,
G_NUMBER_PARSER_ERROR, G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS, G_NUMBER_PARSER_ERROR, G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS,
_("Number “%" G_GUINT64_FORMAT "” is out of bounds" _("Number “%s” is out of bounds [%s, %s]"),
" [%" G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT "]"), str, min_str, max_str);
number, min, max); g_free (min_str);
g_free (max_str);
return FALSE; return FALSE;
} }
if (out_num != NULL) if (out_num != NULL)