[Spice-devel] [PATCH spice-gtk v2] gettext: fix ngettext usage
Frediano Ziglio
fziglio at redhat.com
Thu Apr 18 07:33:28 UTC 2019
----- Original Message -----
> From: "Jakub Janků" <jjanku at redhat.com>
> To: spice-devel at lists.freedesktop.org
> Sent: Wednesday, 17 April, 2019 10:46:57 PM
> Subject: [Spice-devel] [PATCH spice-gtk v2] gettext: fix ngettext usage
>
> _() should not be used in conjunction with ngettext(),
> otherwise it's impossible to properly translate the message into
> languages that have multiple plural forms, such as Czech.
>
> Additionally, spice-gtk must use dngettext instead of ngettext,
> otherwise the translation strings are searched within a wrong domain.
>
> Fix ngettext usage in usb-device-widget.c and
> update the PO files accordingly.
>
> Signed-off-by: Jakub Janků <jjanku at redhat.com>
> ---
> po/de.po | 9 +++------
> po/fr.po | 11 ++++-------
> po/it.po | 12 +++++-------
> src/usb-device-widget.c | 7 ++++---
> 4 files changed, 16 insertions(+), 23 deletions(-)
>
> diff --git a/po/de.po b/po/de.po
> index eb24de7..3ae6ae0 100644
> --- a/po/de.po
> +++ b/po/de.po
> @@ -288,12 +288,9 @@ msgstr "Auswahl des USB-Geräts zum Weiterleiten"
> #: src/usb-device-widget.c:393
> #, c-format
> msgid "Select USB devices to redirect (%d free channel)"
> -msgstr "Auswahl des USB-Geräts zum Weiterleiten (%d freier Kanal)"
> -
> -#: src/usb-device-widget.c:394
> -#, c-format
> -msgid "Select USB devices to redirect (%d free channels)"
> -msgstr "Auswahl des USB-Geräts zum Weiterleiten (%d freie Kanäle)"
> +msgid_plural "Select USB devices to redirect (%d free channels)"
> +msgstr[0] "Auswahl des USB-Geräts zum Weiterleiten (%d freier Kanal)"
> +msgstr[1] "Auswahl des USB-Geräts zum Weiterleiten (%d freie Kanäle)"
>
> #: src/usb-device-widget.c:411
> msgid "Redirecting USB Device..."
> diff --git a/po/fr.po b/po/fr.po
> index e2dd3ad..6120ee0 100644
> --- a/po/fr.po
> +++ b/po/fr.po
> @@ -271,15 +271,12 @@ msgstr ""
> msgid "Select USB devices to redirect"
> msgstr ""
>
> -#: src/usb-device-widget.c:420
> +#: src/usb-device-widget.c:393
> #, c-format
> msgid "Select USB devices to redirect (%d free channel)"
> -msgstr ""
> -
> -#: src/usb-device-widget.c:421
> -#, c-format
> -msgid "Select USB devices to redirect (%d free channels)"
> -msgstr ""
> +msgid_plural "Select USB devices to redirect (%d free channels)"
> +msgstr[0] ""
> +msgstr[1] ""
>
> #: src/usb-device-widget.c:439
> msgid "Redirecting USB Device..."
> diff --git a/po/it.po b/po/it.po
> index a4e40e9..b7899a8 100644
> --- a/po/it.po
> +++ b/po/it.po
> @@ -16,6 +16,7 @@ msgstr ""
> "MIME-Version: 1.0\n"
> "Content-Type: text/plain; charset=UTF-8\n"
> "Content-Transfer-Encoding: 8bit\n"
> +"Plural-Forms: nplurals=2; plural=n != 1;\n"
> "X-Generator: Poedit 1.8.8\n"
>
> #: src/channel-main.c:1868
> @@ -286,15 +287,12 @@ msgstr "%s %s %s a %d-%d"
> msgid "Select USB devices to redirect"
> msgstr "Selezionare dispositivo USB da redirigere"
>
> -#: src/usb-device-widget.c:420
> +#: src/usb-device-widget.c:393
> #, c-format
> msgid "Select USB devices to redirect (%d free channel)"
> -msgstr "Selezionare dispositivo USB da redirigere (%d canale libero)"
> -
> -#: src/usb-device-widget.c:421
> -#, c-format
> -msgid "Select USB devices to redirect (%d free channels)"
> -msgstr "Selezionare dispositivo USB da redirigere (%d canali liberi)"
> +msgid_plural "Select USB devices to redirect (%d free channels)"
> +msgstr[0] "Selezionare dispositivo USB da redirigere (%d canale libero)"
> +msgstr[1] "Selezionare dispositivo USB da redirigere (%d canali liberi)"
The proper translation for "devices" here is "dispositivi" but this is not
a regression. Also "un canale libero" would be better.
I'll send a follow up, nothing to do with this commit.
>
> #: src/usb-device-widget.c:439
> msgid "Redirecting USB Device..."
> diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
> index de62564..55a9687 100644
> --- a/src/usb-device-widget.c
> +++ b/src/usb-device-widget.c
> @@ -390,9 +390,10 @@ static gboolean
> spice_usb_device_widget_update_status(gpointer user_data)
> redirecting = spice_usb_device_manager_is_redirecting(priv->manager);
>
> g_object_get(priv->manager, "free-channels", &free_channels, NULL);
> - free_channels_str = ngettext(_("Select USB devices to redirect (%d free
> channel)"),
> - _("Select USB devices to redirect (%d free
> channels)"),
> - free_channels);
> + free_channels_str = g_dngettext(GETTEXT_PACKAGE,
> + "Select USB devices to redirect (%d free
> channel)",
> + "Select USB devices to redirect (%d free
> channels)",
> + free_channels);
> str = g_strdup_printf(free_channels_str, free_channels);
> markup_str = g_strdup_printf("<b>%s</b>", str);
> gtk_label_set_markup(GTK_LABEL (priv->label), markup_str);
Acked-by: Frediano Ziglio <fziglio at redhat.com>
Frediano
More information about the Spice-devel
mailing list