Re: [PATCH spice-gtk v3] Make error messages translatable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

In my comments below, I assume that if we are using a message for debug
purposes, we don't need to translate it. That is, if we GError* will not
be exported to the application.

Let me know if my assumption is wrong.

On Tue, Jul 11, 2017 at 03:43:41PM +0200, Pavel Grunt wrote:
> Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
> Signed-off-by: Pavel Grunt <pgrunt@xxxxxxxxxx>
> ---
>  po/POTFILES.in                         | 13 +++++++++++++
>  src/channel-main.c                     | 15 ++++++++++-----
>  src/channel-port.c                     |  4 +++-
>  src/channel-usbredir.c                 |  8 ++++----
>  src/giopipe.c                          |  7 +++++--
>  src/smartcard-manager.c                |  5 +++--
>  src/spice-channel.c                    |  2 +-
>  src/spice-client-glib-usb-acl-helper.c |  2 +-
>  src/spice-file-transfer-task.c         |  6 ++++--
>  src/spice-pulse.c                      |  8 +++++---
>  src/spice-session.c                    |  2 +-
>  src/spice-uri.c                        | 17 ++++++++++-------
>  src/spice-widget-egl.c                 | 23 ++++++++++++-----------
>  src/usb-acl-helper.c                   |  9 +++++----
>  src/usb-device-manager.c               |  6 +++---
>  src/vmcstream.c                        |  3 ++-
>  src/win-usb-dev.c                      |  8 ++++----
>  src/wocky-http-proxy.c                 | 11 ++++++-----
>  18 files changed, 92 insertions(+), 57 deletions(-)
> 
> diff --git a/po/POTFILES.in b/po/POTFILES.in
> index d1033f9..7a744af 100644
> --- a/po/POTFILES.in
> +++ b/po/POTFILES.in
> @@ -1,9 +1,22 @@
>  src/channel-main.c
> +src/channel-port.c
>  src/channel-usbredir.c
>  src/desktop-integration.c
> +src/giopipe.c
> +src/smartcard-manager.c
>  src/spice-channel.c
> +src/spice-client-glib-usb-acl-helper.c
> +src/spice-file-transfer-task.c
>  src/spice-option.c
> +src/spice-pulse.c
> +src/spice-session.c
> +src/spice-uri.c
> +src/spice-widget-egl.c
> +src/usb-acl-helper.c
>  src/usb-device-manager.c
>  src/usb-device-widget.c
>  src/usbutil.c
> +src/vmcstream.c
> +src/win-usb-dev.c
> +src/wocky-http-proxy.c
>  tools/spice-cmdline.c
> diff --git a/src/channel-main.c b/src/channel-main.c
> index 4edd575..c035ce1 100644
> --- a/src/channel-main.c
> +++ b/src/channel-main.c
> @@ -17,6 +17,7 @@
>  */
>  #include "config.h"
>  
> +#include <libintl.h>
>  #include <math.h>
>  #include <spice/vd_agent.h>
>  #include <glib/gstdio.h>
> @@ -1900,7 +1901,7 @@ static void main_agent_handle_xfer_status(SpiceMainChannel *channel,
>      default:
>          g_warn_if_reached();
>          error = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "unhandled status type: %u", msg->result);
> +                            _("unhandled status type: %u"), msg->result);
>          break;
>      }
>  
> @@ -2906,12 +2907,16 @@ failed:
>  
>  static void file_transfer_operation_free(FileTransferOperation *xfer_op)
>  {
> +    const char *error_summary_fmt;
>      g_return_if_fail(xfer_op != NULL);
>  
> +    error_summary_fmt = ngettext(_("Transferring %u file: %u succeed, %u cancelled, %u failed"),
> +                                 _("Transferring %u files: %u succeed, %u cancelled, %u failed"),
> +                                 xfer_op->stats.num_files);
>      if (xfer_op->stats.failed != 0) {
>          GError *error = g_error_new(SPICE_CLIENT_ERROR,
>                                      SPICE_CLIENT_ERROR_FAILED,
> -                                    "Transferring %u files: %u succeed, %u cancelled, %u failed",
> +                                    error_summary_fmt,
>                                      xfer_op->stats.num_files,
>                                      xfer_op->stats.succeed,
>                                      xfer_op->stats.cancelled,
> @@ -2921,7 +2926,7 @@ static void file_transfer_operation_free(FileTransferOperation *xfer_op)
>      } else if (xfer_op->stats.cancelled != 0 && xfer_op->stats.succeed == 0) {
>          GError *error = g_error_new(G_IO_ERROR,
>                                      G_IO_ERROR_CANCELLED,
> -                                    "Transferring %u files: %u succeed, %u cancelled, %u failed",
> +                                    error_summary_fmt,
>                                      xfer_op->stats.num_files,
>                                      xfer_op->stats.succeed,
>                                      xfer_op->stats.cancelled,
> @@ -2962,7 +2967,7 @@ static void spice_main_channel_reset_all_xfer_operations(SpiceMainChannel *chann
>          }
>  
>          error = g_error_new(SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "Agent connection closed");
> +                            _("Agent connection closed"));
>          spice_file_transfer_task_completed(xfer_task, error);
>      }
>      g_list_free(keys);
> @@ -3119,7 +3124,7 @@ void spice_main_file_copy_async(SpiceMainChannel *channel,
>                                  spice_main_file_copy_async,
>                                  SPICE_CLIENT_ERROR,
>                                  SPICE_CLIENT_ERROR_FAILED,
> -                                "The agent is not connected");
> +                                _("The agent is not connected"));
>          return;
>      }
>  
> diff --git a/src/channel-port.c b/src/channel-port.c
> index d922e4b..9fb7f05 100644
> --- a/src/channel-port.c
> +++ b/src/channel-port.c
> @@ -17,6 +17,8 @@
>  */
>  #include "config.h"
>  
> +#include <glib/gi18n-lib.h>
> +
>  #include "spice-client.h"
>  #include "spice-common.h"
>  #include "spice-channel-priv.h"
> @@ -294,7 +296,7 @@ void spice_port_write_async(SpicePortChannel *self,
>          g_task_report_new_error(self, callback,
>              user_data, spice_port_write_async,
>              SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -            "The port is not opened");
> +            _("The port is not opened"));
>          return;
>      }
>  
> diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
> index fef62ce..615b959 100644
> --- a/src/channel-usbredir.c
> +++ b/src/channel-usbredir.c
> @@ -304,7 +304,7 @@ static gboolean spice_usbredir_channel_open_device(
>      rc = libusb_open(priv->device, &handle);
>      if (rc != 0) {
>          g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                    "Could not open usb device: %s [%i]",
> +                    _("Could not open usb device: %s [%i]"),
>                      spice_usbutil_libusb_strerror(rc), rc);
>          return FALSE;
>      }
> @@ -348,7 +348,7 @@ static void spice_usbredir_channel_open_acl_cb(
>      spice_usb_acl_helper_open_acl_finish(acl_helper, acl_res, &err);
>      if (!err && priv->state == STATE_DISCONNECTING) {
>          err = g_error_new_literal(G_IO_ERROR, G_IO_ERROR_CANCELLED,
> -                                  "USB redirection channel connect cancelled");
> +                                  _("USB redirection channel connect cancelled"));
>      }
>      if (!err) {
>          spice_usbredir_channel_open_device(channel, &err);
> @@ -425,14 +425,14 @@ void spice_usbredir_channel_connect_device_async(
>      if (!priv->host) {
>          g_task_return_new_error(task,
>                              SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "Error libusb context not set");
> +                            _("Error libusb context not set"));
>          goto done;
>      }
>  
>      if (priv->state != STATE_DISCONNECTED) {
>          g_task_return_new_error(task,
>                              SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "Error channel is busy");
> +                            _("Error channel is busy"));
>          goto done;
>      }
>  
> diff --git a/src/giopipe.c b/src/giopipe.c
> index 08aea9a..e9d4abe 100644
> --- a/src/giopipe.c
> +++ b/src/giopipe.c
> @@ -16,6 +16,9 @@
>    License along with this library; if not, see <http://www.gnu.org/licenses/>.
>  */
>  
> +#include "config.h"
> +
> +#include <glib/gi18n-lib.h>
>  #include <string.h>
>  #include <errno.h>
>  
> @@ -100,7 +103,7 @@ pipe_input_stream_read (GInputStream  *stream,
>  
>      if (g_input_stream_is_closed (stream) || self->peer_closed) {
>          g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
> -                             "Stream is already closed");
> +                             _("Stream is already closed"));
>          return -1;
>      }
>  
> @@ -288,7 +291,7 @@ pipe_output_stream_write (GOutputStream  *stream,
>      //g_debug("write %p :%"G_GSIZE_FORMAT, stream, count);
>      if (g_output_stream_is_closed (stream) || self->peer_closed) {
>          g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
> -                             "Stream is already closed");
> +                             _("Stream is already closed"));
>          return -1;
>      }
>  
> diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
> index 708f976..05e113d 100644
> --- a/src/smartcard-manager.c
> +++ b/src/smartcard-manager.c
> @@ -18,6 +18,7 @@
>  #include "config.h"
>  
>  #include <glib-object.h>
> +#include <glib/gi18n-lib.h>
>  #include <string.h>
>  
>  #ifdef USE_SMARTCARD_012
> @@ -439,7 +440,7 @@ static gboolean smartcard_manager_init(SmartcardManagerInitArgs *args)
>      if (options == NULL) {
>          args->err = g_error_new(SPICE_CLIENT_ERROR,
>                                  SPICE_CLIENT_ERROR_FAILED,
> -                                "vcard_emul_options() failed!");
> +                                _("vcard_emul_options() failed!"));

Sounds like an warning message instead. I'd change the error message to
"Failed to initialize smartcard" instead. (in preparatory patch to this
one?)

>          goto end;
>      }
>  
> @@ -453,7 +454,7 @@ init:
>              && (emul_init_status != VCARD_EMUL_INIT_ALREADY_INITED)) {
>          args->err = g_error_new(SPICE_CLIENT_ERROR,
>                                  SPICE_CLIENT_ERROR_FAILED,
> -                                "Failed to initialize smartcard");
> +                                _("Failed to initialize smartcard"));
>          goto end;
>      }
>  
> diff --git a/src/spice-channel.c b/src/spice-channel.c
> index 4c3db9d..9d720ab 100644
> --- a/src/spice-channel.c
> +++ b/src/spice-channel.c
> @@ -3138,7 +3138,7 @@ void spice_channel_flush_async(SpiceChannel *self, GCancellable *cancellable,
>          g_task_report_new_error(self, callback, user_data,
>              spice_channel_flush_async,
>              SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -            "The channel is not ready yet");
> +            _("The channel is not ready yet"));
>          return;
>      }
>  
> diff --git a/src/spice-client-glib-usb-acl-helper.c b/src/spice-client-glib-usb-acl-helper.c
> index 80cdced..9f021da 100644
> --- a/src/spice-client-glib-usb-acl-helper.c
> +++ b/src/spice-client-glib-usb-acl-helper.c
> @@ -300,7 +300,7 @@ polkit_authority_get_sync (GCancellable *cancellable, GError **error)
>  
>      authority = polkit_authority_get ();
>      if (!authority)
> -        g_set_error (error, 0, 0, "failed to get the PolicyKit authority");
> +        g_set_error (error, 0, 0, _("failed to get the PolicyKit authority"));
>  
>      return authority;
>  }
> diff --git a/src/spice-file-transfer-task.c b/src/spice-file-transfer-task.c
> index d0170da..46165f7 100644
> --- a/src/spice-file-transfer-task.c
> +++ b/src/spice-file-transfer-task.c
> @@ -17,6 +17,8 @@
>  
>  #include "config.h"
>  
> +#include <glib/gi18n-lib.h>
> +
>  #include "spice-file-transfer-task-priv.h"
>  
>  /**
> @@ -310,7 +312,7 @@ void spice_file_transfer_task_completed(SpiceFileTransferTask *self,
>          if (self->error == NULL) {
>              self->error = g_error_new(SPICE_CLIENT_ERROR,
>                                        SPICE_CLIENT_ERROR_FAILED,
> -                                      "Cannot complete task in pending state");
> +                                      _("Cannot complete task in pending state"));
>          }
>          return;
>      }
> @@ -426,7 +428,7 @@ void spice_file_transfer_task_read_async(SpiceFileTransferTask *self,
>                                  spice_file_transfer_task_read_async,
>                                  SPICE_CLIENT_ERROR,
>                                  SPICE_CLIENT_ERROR_FAILED,
> -                                "Cannot read data in pending state");
> +                                _("Cannot read data in pending state"));
>          return;
>      }
>  
> diff --git a/src/spice-pulse.c b/src/spice-pulse.c
> index 5248bc3..1706b74 100644
> --- a/src/spice-pulse.c
> +++ b/src/spice-pulse.c
> @@ -17,6 +17,8 @@
>  */
>  #include "config.h"
>  
> +#include <glib/gi18n-lib.h>
> +
>  #include "spice-pulse.h"
>  #include "spice-common.h"
>  #include "spice-session-priv.h"
> @@ -972,7 +974,7 @@ static void complete_task(SpicePulse *pulse, struct async_task *task, const gcha
>          g_task_return_new_error(task->gtask,
>                                  SPICE_CLIENT_ERROR,
>                                  SPICE_CLIENT_ERROR_FAILED,
> -                                "restore-info failed: %s",
> +                                _("restore-info failed: %s"),

If I'm not mistaken, this is 100% internal usage for debugging purposes
so it does not need to be translated.

>                                  err_msg);
>      /* Volume-info does not change if stream is not found */
>      } else if ((task->is_playback == TRUE && p->playback.info_updated == FALSE) ||
> @@ -980,7 +982,7 @@ static void complete_task(SpicePulse *pulse, struct async_task *task, const gcha
>          g_task_return_new_error(task->gtask,
>                                  SPICE_CLIENT_ERROR,
>                                  SPICE_CLIENT_ERROR_FAILED,
> -                                "Stream not found by pulse");
> +                                _("Stream not found by pulse"));

Same

>      } else {
>          g_task_return_boolean(task->gtask, TRUE);
>      }
> @@ -1216,7 +1218,7 @@ fail:
>                                  pulse_stream_restore_info_async,
>                                  SPICE_CLIENT_ERROR,
>                                  SPICE_CLIENT_ERROR_FAILED,
> -                                "Volume-Info failed: %s",
> +                                _("Volume-Info failed: %s"),

Same

>                                  pa_strerror(pa_context_errno(p->context)));
>          free_async_task(task);
>      }
> diff --git a/src/spice-session.c b/src/spice-session.c
> index 6f8cf5e..bf78aad 100644
> --- a/src/spice-session.c
> +++ b/src/spice-session.c
> @@ -2119,7 +2119,7 @@ static gboolean open_host_idle_cb(gpointer data)
>              address = G_SOCKET_CONNECTABLE(g_unix_socket_address_new(s->unix_path));
>  #else
>              g_set_error_literal(&open_host->error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                                "Unix path unsupported on this platform");
> +                                _("Unix path unsupported on this platform"));
>  #endif
>          } else {
>              SPICE_DEBUG("open host %s:%d", s->host, open_host->port);
> diff --git a/src/spice-uri.c b/src/spice-uri.c
> index 0376cd8..ec33bc6 100644
> --- a/src/spice-uri.c
> +++ b/src/spice-uri.c
> @@ -17,6 +17,7 @@
>  */
>  #include "config.h"
>  
> +#include <glib/gi18n-lib.h>
>  #include <stdlib.h>
>  #include <string.h>
>  
> @@ -137,7 +138,7 @@ gboolean spice_uri_parse(SpiceURI *self, const gchar *_uri, GError **error)
>          spice_uri_set_port(self, 3129);
>      } else {
>          g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                    "Invalid uri scheme for proxy: %s", spice_uri_get_scheme(self));
> +                    _("Invalid uri scheme for proxy: %s"), spice_uri_get_scheme(self));
>          goto end;
>      }
>      /* remove trailing slash */
> @@ -165,14 +166,14 @@ gboolean spice_uri_parse(SpiceURI *self, const gchar *_uri, GError **error)
>          uriv = g_strsplit(uri + 1, "]", 2);
>          if (uriv[1] == NULL) {
>              g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                        "Missing ']' in ipv6 uri");
> +                        _("Missing ']' in ipv6 uri"));
>              goto end;
>          }
>          if (*uriv[1] == ':') {
>              uri_port = uriv[1] + 1;
>          } else if (strlen(uriv[1]) > 0) { /* invalid string after the hostname */
>              g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                        "Invalid uri address");
> +                        _("Invalid uri address"));
>              goto end;
>          }
>      } else {
> @@ -184,7 +185,7 @@ gboolean spice_uri_parse(SpiceURI *self, const gchar *_uri, GError **error)
>  
>      if (uriv[0] == NULL || strlen(uriv[0]) == 0) {
>          g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                    "Invalid hostname in uri address");
> +                    _("Invalid hostname in uri address"));
>          goto end;
>      }
>  
> @@ -195,14 +196,16 @@ gboolean spice_uri_parse(SpiceURI *self, const gchar *_uri, GError **error)
>          gint64 port = g_ascii_strtoll(uri_port, &endptr, 10);
>          if (*endptr != '\0') {
>              g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                        "Invalid uri port: %s", uri_port);
> +                        _("Invalid uri port: %s"), uri_port);
>              goto end;
>          } else if (endptr == uri_port) {
> -            g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED, "Missing uri port");
> +            g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> +                        _("Missing uri port"));
>              goto end;
>          }
>          if (port <= 0 || port > 65535) {
> -            g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED, "Port out of range");
> +            g_set_error(error, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> +                        _("Port out of range"));
>              goto end;
>          }
>          spice_uri_set_port(self, port);
> diff --git a/src/spice-widget-egl.c b/src/spice-widget-egl.c
> index b50641c..8250afc 100644
> --- a/src/spice-widget-egl.c
> +++ b/src/spice-widget-egl.c
> @@ -17,6 +17,7 @@
>  */
>  #include "config.h"
>  
> +#include <glib/gi18n-lib.h>
>  #include <math.h>
>  #include <gdk/gdk.h>
>  
> @@ -108,7 +109,7 @@ static gboolean spice_egl_init_shaders(SpiceDisplay *display, GError **err)
>      if (!status) {
>          glGetShaderInfoLog(fs, sizeof(log), &len, log);
>          g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                    "failed to compile fragment shader: %s", log);
> +                    _("failed to compile fragment shader: %s"), log);
>          goto end;
>      }

This is internal spice_egl_init() called from spice-widget. Don't see
the need to translate it

>
> @@ -119,7 +120,7 @@ static gboolean spice_egl_init_shaders(SpiceDisplay *display, GError **err)
>      if (!status) {
>          glGetShaderInfoLog(vs, sizeof(log), &len, log);
>          g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                    "failed to compile vertex shader: %s", log);
> +                    _("failed to compile vertex shader: %s"), log);
>          goto end;
>      }

Same

>  
> @@ -131,7 +132,7 @@ static gboolean spice_egl_init_shaders(SpiceDisplay *display, GError **err)
>      if (!status) {
>          glGetProgramInfoLog(d->egl.prog, 1000, &len, log);
>          g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                    "error linking shaders: %s", log);
> +                    _("error linking shaders: %s"), log);
>          goto end;
>      }

Same

>  
> @@ -222,13 +223,13 @@ gboolean spice_egl_init(SpiceDisplay *display, GError **err)
>      d->egl.display = eglGetDisplay(dpy);
>      if (d->egl.display == EGL_NO_DISPLAY) {
>          g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "failed to get EGL display");
> +                            _("failed to get EGL display"));
>          return FALSE;
>      }

Same

>  
>      if (!eglInitialize(d->egl.display, &major, &minor)) {
>          g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "failed to init EGL display");
> +                            _("failed to init EGL display"));
>          return FALSE;

Same

>      }
>  
> @@ -243,7 +244,7 @@ gboolean spice_egl_init(SpiceDisplay *display, GError **err)
>      b = eglBindAPI(EGL_OPENGL_API);
>      if (!b) {
>          g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "cannot bind OpenGL API");
> +                            _("cannot bind OpenGL API"));
>          return FALSE;

Same

>      }
>  
> @@ -252,7 +253,7 @@ gboolean spice_egl_init(SpiceDisplay *display, GError **err)
>  
>      if (!b || n != 1) {
>          g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "cannot find suitable EGL config");
> +                            _("cannot find suitable EGL config"));
>          return FALSE;

Same

>      }
>  
> @@ -262,7 +263,7 @@ gboolean spice_egl_init(SpiceDisplay *display, GError **err)
>                                    ctx_att);
>      if (!d->egl.ctx) {
>          g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "cannot create EGL context");
> +                            _("cannot create EGL context"));
>          return FALSE;

Same

>      }
>
> @@ -303,7 +304,7 @@ gl_make_current(SpiceDisplay *display, GError **err)
>          if (success != EGL_TRUE) {
>              g_set_error_literal(err, SPICE_CLIENT_ERROR,
>                                  SPICE_CLIENT_ERROR_FAILED,
> -                                "failed to activate context");
> +                                _("failed to activate context"));
>              return FALSE;

Used in more functions, all internal (and only one really uses the err
argument)

>          }
>      }
> @@ -342,7 +343,7 @@ static gboolean spice_widget_init_egl_win(SpiceDisplay *display, GdkWindow *win,
>
>      if (!native) {
>          g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "this platform isn't supported");
> +                            _("this platform isn't supported"));
>          return FALSE;

It sounds something that application would like to have but that's still
internal here.

>      }
>
> @@ -352,7 +353,7 @@ static gboolean spice_widget_init_egl_win(SpiceDisplay *display, GdkWindow *win,
>  
>      if (!d->egl.surface) {
>          g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "failed to init egl surface");
> +                            _("failed to init egl surface"));
>          return FALSE;
>      }

Same

>  
> diff --git a/src/usb-acl-helper.c b/src/usb-acl-helper.c
> index fa845be..de2e60c 100644
> --- a/src/usb-acl-helper.c
> +++ b/src/usb-acl-helper.c
> @@ -21,6 +21,7 @@
>  
>  #include "config.h"
>  
> +#include <glib/gi18n-lib.h>
>  #include <errno.h>
>  #include <stdio.h>
>  #include <string.h>
> @@ -86,7 +87,7 @@ static void async_result_set_cancelled(GTask *task)
>  {
>      g_task_return_new_error(task,
>                  G_IO_ERROR, G_IO_ERROR_CANCELLED,
> -                "Setting USB device node ACL cancelled");
> +                _("Setting USB device node ACL cancelled"));

It can go all the way to
spice_usb_device_manager_connect_device_async(), looks good

>  }
>  
>  static gboolean cb_out_watch(GIOChannel    *channel,
> @@ -119,7 +120,7 @@ static gboolean cb_out_watch(GIOChannel    *channel,
>              } else {
>                  g_task_return_new_error(priv->task,
>                              SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "Error setting USB device node ACL: '%s'",
> +                            _("Error setting USB device node ACL: '%s'"),
>                              string);
>              }
>              g_free(string);
> @@ -130,7 +131,7 @@ static gboolean cb_out_watch(GIOChannel    *channel,
>          case G_IO_STATUS_EOF:
>              g_task_return_new_error(priv->task,
>                          SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                        "Unexpected EOF reading from acl helper stdout");
> +                        _("Unexpected EOF reading from acl helper stdout"));
>              break;
>          case G_IO_STATUS_AGAIN:
>              return TRUE; /* Wait for more input */
> @@ -202,7 +203,7 @@ void spice_usb_acl_helper_open_acl_async(SpiceUsbAclHelper *self,
>      if (priv->out_ch) {
>          g_task_return_new_error(task,
>                              SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "Error acl-helper already has an acl open");
> +                            _("Error acl-helper already has an acl open"));
>          goto done;
>      }
>  
> diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
> index 29f2846..8252f58 100644
> --- a/src/usb-device-manager.c
> +++ b/src/usb-device-manager.c
> @@ -304,7 +304,7 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
>          const char *desc = spice_usbutil_libusb_strerror(rc);
>          g_warning("Error initializing USB support: %s [%i]", desc, rc);
>          g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                    "Error initializing USB support: %s [%i]", desc, rc);
> +                    _("Error initializing USB support: %s [%i]"), desc, rc);
>          return FALSE;
>      }
>  
> @@ -337,7 +337,7 @@ static gboolean spice_usb_device_manager_initable_init(GInitable  *initable,
>          const char *desc = spice_usbutil_libusb_strerror(rc);
>          g_warning("Error initializing USB hotplug support: %s [%i]", desc, rc);
>          g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                  "Error initializing USB hotplug support: %s [%i]", desc, rc);
> +                    _("Error initializing USB hotplug support: %s [%i]"), desc, rc);
>          return FALSE;
>      }
>      spice_usb_device_manager_start_event_listening(self, NULL);
> @@ -1406,7 +1406,7 @@ _spice_usb_device_manager_connect_device_async(SpiceUsbDeviceManager *self,
>      if (spice_usb_device_manager_is_device_connected(self, device)) {
>          g_task_return_new_error(task,
>                              SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,
> -                            "Cannot connect an already connected usb device");
> +                            _("Cannot connect an already connected usb device"));
>          goto done;
>      }
>  
> diff --git a/src/vmcstream.c b/src/vmcstream.c
> index 0634bce..893df53 100644
> --- a/src/vmcstream.c
> +++ b/src/vmcstream.c
> @@ -17,6 +17,7 @@
>  */
>  #include "config.h"
>  
> +#include <glib/gi18n-lib.h>
>  #include <string.h>
>  
>  #include "vmcstream.h"
> @@ -180,7 +181,7 @@ read_cancelled(GCancellable *cancellable,
>      SPICE_DEBUG("read cancelled, %p", self->task);
>      g_task_return_new_error(self->task,
>                              G_IO_ERROR, G_IO_ERROR_CANCELLED,
> -                            "read cancelled");
> +                            _("read cancelled"));

Don't see a need to translate that

>
>      /* With GTask, we don't need to disconnect GCancellable when task is
>       * cancelled within cancellable callback as it could lead to deadlocks
> diff --git a/src/win-usb-dev.c b/src/win-usb-dev.c
> index ec3dd91..8d8a704 100644
> --- a/src/win-usb-dev.c
> +++ b/src/win-usb-dev.c
> @@ -143,7 +143,7 @@ g_udev_client_list_devices(GUdevClient *self, GList **devs,
>          const char *errstr = spice_usbutil_libusb_strerror(rc);
>          g_warning("%s: libusb_get_device_list failed - %s", name, errstr);
>          g_set_error(err, G_UDEV_CLIENT_ERROR, G_UDEV_CLIENT_LIBUSB_FAILED,
> -                    "%s: Error getting device list from libusb: %s [%"G_GSSIZE_FORMAT"]",
> +                    _("%s: Error getting device list from libusb: %s [%"G_GSSIZE_FORMAT"]"),
>                      name, errstr, rc);
>          return -4;
>      }
> @@ -195,7 +195,7 @@ g_udev_client_initable_init(GInitable *initable, GCancellable *cancellable,
>          const char *errstr = spice_usbutil_libusb_strerror(rc);
>          g_warning("Error initializing USB support: %s [%i]", errstr, rc);
>          g_set_error(err, G_UDEV_CLIENT_ERROR, G_UDEV_CLIENT_LIBUSB_FAILED,
> -                    "Error initializing USB support: %s [%i]", errstr, rc);
> +                    _("Error initializing USB support: %s [%i]"), errstr, rc);
>          return FALSE;
>      }
>  
> @@ -214,7 +214,7 @@ g_udev_client_initable_init(GInitable *initable, GCancellable *cancellable,
>          DWORD e = GetLastError();
>          g_warning("RegisterClass failed , %ld", (long)e);
>          g_set_error(err, G_UDEV_CLIENT_ERROR, G_UDEV_CLIENT_WINAPI_FAILED,
> -                    "RegisterClass failed: %ld", (long)e);
> +                    _("RegisterClass failed: %ld"), (long)e);
>          goto g_udev_client_init_failed;
>      }
>      priv->hwnd = CreateWindow(G_UDEV_CLIENT_WINCLASS_NAME,
> @@ -223,7 +223,7 @@ g_udev_client_initable_init(GInitable *initable, GCancellable *cancellable,
>          DWORD e = GetLastError();
>          g_warning("CreateWindow failed: %ld", (long)e);
>          g_set_error(err, G_UDEV_CLIENT_ERROR, G_UDEV_CLIENT_LIBUSB_FAILED,
> -                    "CreateWindow failed: %ld", (long)e);
> +                    _("CreateWindow failed: %ld"), (long)e);
>          goto g_udev_client_init_failed_unreg;
>      }
>  
> diff --git a/src/wocky-http-proxy.c b/src/wocky-http-proxy.c
> index 8120a55..7dcb5a1 100644
> --- a/src/wocky-http-proxy.c
> +++ b/src/wocky-http-proxy.c
> @@ -24,6 +24,7 @@
>  
>  #include "wocky-http-proxy.h"
>  
> +#include <glib/gi18n-lib.h>
>  #include <string.h>
>  #include <stdlib.h>
>  
> @@ -120,7 +121,7 @@ check_reply (const gchar *buffer, gboolean has_cred, GError **error)
>        || (*ptr != '0' && *ptr != '1'))
>      {
>        g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PROXY_FAILED,
> -          "Bad HTTP proxy reply");
> +          _("Bad HTTP proxy reply"));
>        return FALSE;
>      }
>
> @@ -153,17 +154,17 @@ check_reply (const gchar *buffer, gboolean has_cred, GError **error)
>          {
>            if (has_cred)
>              g_set_error (error, G_IO_ERROR, G_IO_ERROR_PROXY_AUTH_FAILED,
> -                "HTTP proxy authentication failed");
> +                _("HTTP proxy authentication failed"));
>            else
>              g_set_error (error, G_IO_ERROR, G_IO_ERROR_PROXY_NEED_AUTH,
> -                "HTTP proxy authentication required");
> +                _("HTTP proxy authentication required"));
>          }
>        else if (msg[0] == '\0')
>          g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PROXY_FAILED,
> -            "Connection failed due to broken HTTP reply");
> +            _("Connection failed due to broken HTTP reply"));
>        else
>          g_set_error (error, G_IO_ERROR, G_IO_ERROR_PROXY_FAILED,
> -            "HTTP proxy connection failed: %i %s",
> +            _("HTTP proxy connection failed: %i %s"),
>              err_code, msg);

Not sure how the proxy works nor if this translations are useful, I'd
guess it is.

Reviewed-by: Victor Toso <victortoso@xxxxxxxxxx>

>  
>        g_free (msg);
> -- 
> 2.13.0
> 

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]