Hello,

the N_ macro doesn't translate the string, it just marks it for
translation so it ends up in the po file. You also need to call _
(a.k.a. gettext) to actually get the translation.

Attached is a patch to fix this for moserial.

HTH,
Abderrahim

2017-12-22 19:03 GMT+01:00 Dr. Michael J. Chudobiak <m...@avtechpulse.com>:
> Hi all,
>
> I'm having trouble with i18n. The _("") macros in my program work, but the
> N_("") ones (for initializing string arrays) don't. Any pointers on what the
> issue could be?
>
> This is the program:
> https://git.gnome.org/browse/moserial
>
> If you run it, see if the Help > About > License text comes out in your
> language... It doesn't if I run:
>
> LC_ALL=fr_CA moserial
>
>
> - Mike
> _______________________________________________
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
From 4e2673eb1c160e67ed6fe06f38c7b0687759d1c9 Mon Sep 17 00:00:00 2001
From: Abderrahim Kitouni <a.kito...@gmail.com>
Date: Thu, 28 Dec 2017 09:38:01 +0100
Subject: [PATCH] correctly call gettext

constants translated with N_ need to call _ when used.
---
 src/MainWindow.vala | 4 ++--
 src/MoUtils.vala    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index 47bec6a..9a4036f 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -762,14 +762,14 @@ public class moserial.MainWindow : Gtk.Window //Have to extend Gtk.Winow to get
 
         private void showAboutDialog () {
 
-                string license_trans = license[0] + "\n" + license[1] + "\n" + license[2];
+                string license_trans = _(license[0]) + "\n" + _(license[1]) + "\n" + _(license[2]);
 
                 show_about_dialog (gtkWindow,
                                    "version", Config.VERSION,
                                    "copyright", "Copyright © 2009-2017\nMichael J. Chudobiak\n<m...@svn.gnome.org>",
                                    "comments", _("A serial terminal for the GNOME desktop, optimized for logging and file capture."),
                                    "authors", authors,
-                                   "translator-credits", translators,
+                                   "translator-credits", _(translators),
                                    "logo-icon-name", "moserial",
                                    "wrap-license", true,
                                    "license", license_trans,
diff --git a/src/MoUtils.vala b/src/MoUtils.vala
index 3c66ac3..773475f 100644
--- a/src/MoUtils.vala
+++ b/src/MoUtils.vala
@@ -104,7 +104,7 @@ public class MoUtils : GLib.Object
                 foreach (string val_item in val_array) {
                         TreeIter iter;
                         Model.append(out iter);
-                        Model.set(iter,0,val_item);
+                        Model.set(iter, 0, _(val_item));
                 }
                 Combo.set_model(Model);
                 CellRenderer Cell = new CellRendererText();
-- 
2.11.0

_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to