Merge branch 'wip/djz/factor-out-untranslatable-err-msgs' into 'main'

gdbus: factor out untranslatable parts of error messages

Closes #3363

See merge request GNOME/glib!4103
This commit is contained in:
Philip Withnall 2024-06-13 18:30:58 +00:00
commit 9b5f41c71b
3 changed files with 29 additions and 12 deletions

View File

@ -619,8 +619,12 @@ g_dbus_address_connect (const gchar *address_entry,
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT, G_IO_ERROR_INVALID_ARGUMENT,
_("Error in address “%s” — the host attribute is missing or malformed"), /* Translators: The first placeholder is a D-Bus connection address,
address_entry); * the second is the literal name of an attribute in the address.
*/
_("Error in address “%s” — the %s attribute is missing or malformed"),
address_entry,
"host");
goto out; goto out;
} }
@ -633,8 +637,9 @@ g_dbus_address_connect (const gchar *address_entry,
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT, G_IO_ERROR_INVALID_ARGUMENT,
_("Error in address “%s” — the port attribute is missing or malformed"), _("Error in address “%s” — the %s attribute is missing or malformed"),
address_entry); address_entry,
"port");
goto out; goto out;
} }
@ -647,8 +652,9 @@ g_dbus_address_connect (const gchar *address_entry,
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT, G_IO_ERROR_INVALID_ARGUMENT,
_("Error in address “%s” — the noncefile attribute is missing or malformed"), _("Error in address “%s” — the %s attribute is missing or malformed"),
address_entry); address_entry,
"noncefile");
goto out; goto out;
} }
} }

View File

@ -4716,7 +4716,10 @@ invoke_get_property_in_idle_cb (gpointer _data)
{ {
reply = g_dbus_message_new_method_error (data->message, reply = g_dbus_message_new_method_error (data->message,
DBUS_ERROR_UNKNOWN_METHOD, DBUS_ERROR_UNKNOWN_METHOD,
_("No such interface “org.freedesktop.DBus.Properties” on object at path %s"), /* Translators: The first placeholder is a D-Bus interface,
* the second is the path of an object. */
_("No such interface “%s” on object at path %s"),
DBUS_INTERFACE_PROPERTIES,
g_dbus_message_get_path (data->message)); g_dbus_message_get_path (data->message));
g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
g_object_unref (reply); g_object_unref (reply);
@ -5070,7 +5073,8 @@ invoke_get_all_properties_in_idle_cb (gpointer _data)
{ {
reply = g_dbus_message_new_method_error (data->message, reply = g_dbus_message_new_method_error (data->message,
DBUS_ERROR_UNKNOWN_METHOD, DBUS_ERROR_UNKNOWN_METHOD,
_("No such interface “org.freedesktop.DBus.Properties” on object at path %s"), _("No such interface “%s” on object at path %s"),
DBUS_INTERFACE_PROPERTIES,
g_dbus_message_get_path (data->message)); g_dbus_message_get_path (data->message));
g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); g_dbus_connection_send_message (data->connection, reply, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
g_object_unref (reply); g_object_unref (reply);

View File

@ -1421,8 +1421,13 @@ validate_headers (GDBusMessage *message,
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT, G_IO_ERROR_INVALID_ARGUMENT,
_("%s message: PATH header field is using the reserved value /org/freedesktop/DBus/Local"), /* Translators: The first placeholder is a D-Bus message type,
message_type_to_string (message->type)); * the second is the name of a header field and the third is
* a value that is reserved for the given field. */
_("%s message: %s header field is using the reserved value %s"),
message_type_to_string (message->type),
"PATH",
DBUS_PATH_LOCAL);
goto out; goto out;
} }
break; break;
@ -1443,8 +1448,10 @@ validate_headers (GDBusMessage *message,
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_INVALID_ARGUMENT, G_IO_ERROR_INVALID_ARGUMENT,
_("%s message: INTERFACE header field is using the reserved value org.freedesktop.DBus.Local"), _("%s message: %s header field is using the reserved value %s"),
message_type_to_string (message->type)); message_type_to_string (message->type),
"INTERFACE",
DBUS_INTERFACE_LOCAL);
goto out; goto out;
} }
break; break;