[gitg] Implement i18n support in libgitg



commit 423da7de8f6e7eb45e03d2d88aa7e2db05e261d1
Author: Manish Sinha <manishsinha ubuntu com>
Date:   Thu Jun 27 01:51:43 2013 -0700

    Implement i18n support in libgitg
    
    Fix #703167 and #699635 by implementing i18n support using gettext.

 gitg/gitg-window.vala    |    6 +++---
 libgitg/Makefile.am      |    3 ++-
 libgitg/gitg-commit.vala |    8 ++++----
 po/POTFILES.in           |   15 ++++++++-------
 po/POTFILES.skip         |    1 +
 5 files changed, 18 insertions(+), 15 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index b24e551..a17fdca 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -374,7 +374,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
 
                        if (Ggit.Config.find_global().get_path() == null)
                        {
-                               show_config_error(user_information_dialog, "Unable to open the .gitconfig 
file", "");
+                               show_config_error(user_information_dialog, _("Unable to open the .gitconfig 
file."), "");
                                return;
                        }
                }
@@ -447,7 +447,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
                                }
                                catch (Error e)
                                {
-                                       show_config_error(user_information_dialog, "Failed to set Git user 
config.", e.message);
+                                       show_config_error(user_information_dialog, _("Failed to set Git user 
config."), e.message);
                                        d.destroy();
                                        return;
                                }
@@ -668,7 +668,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
                catch (Error e)
                {
                        string repo_name = path.get_basename();
-                       var primary_msg = ("\"%s\" is not a Git repository!").printf(repo_name);
+                       var primary_msg = _("'%s' is not a Git repository.").printf(repo_name);
                        show_infobar(primary_msg, e.message, Gtk.MessageType.WARNING);
                        return;
                }
diff --git a/libgitg/Makefile.am b/libgitg/Makefile.am
index 1a64c5b..168676a 100644
--- a/libgitg/Makefile.am
+++ b/libgitg/Makefile.am
@@ -6,7 +6,8 @@ AM_CPPFLAGS =                                                           \
        $(LIBGITG_CFLAGS)                                               \
        $(WARN_CFLAGS)                                                  \
        -DDATADIR=\""$(datadir)"\"                                      \
-       -DLIBDIR=\""$(libdir)"\"
+       -DLIBDIR=\""$(libdir)"\"                                        \
+       -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\"
 
 libgitg_1_0_la_LDFLAGS =               \
        -export-dynamic -no-undefined -export-symbols-regex "^[^_].*"
diff --git a/libgitg/gitg-commit.vala b/libgitg/gitg-commit.vala
index 16546ae..eaf383f 100644
--- a/libgitg/gitg-commit.vala
+++ b/libgitg/gitg-commit.vala
@@ -100,21 +100,21 @@ public class Commit : Ggit.Commit
                if (t < TimeSpan.MINUTE * 29.5)
                {
                        int rounded_minutes = (int) Math.round((float) t / TimeSpan.MINUTE);
-                       return rounded_minutes <= 1 ? "A minute ago" : "%d minutes 
ago".printf(rounded_minutes);
+                       return ngettext(_("A minute ago"), _("%d minutes ago"), 
rounded_minutes).printf(rounded_minutes);
                }
                else if (t < TimeSpan.MINUTE * 45)
                {
-                       return "Half an hour ago";
+                       return _("Half an hour ago");
                }
                else if (t < TimeSpan.HOUR * 23.5)
                {
                        int rounded_hours = (int) Math.round((float) t / TimeSpan.HOUR);
-                       return rounded_hours == 1 ? "An hour ago" : "%d hours ago".printf(rounded_hours);
+                       return ngettext(_("An hour ago"), _("%d hours ago"), 
rounded_hours).printf(rounded_hours);
                }
                else if (t < TimeSpan.DAY * 7)
                {
                        int rounded_days = (int) Math.round((float) t / TimeSpan.DAY);
-                       return rounded_days == 1 ? "A day ago" : "%d days ago".printf(rounded_days);
+                       return ngettext(_("A day ago"), _("%d days ago"), rounded_days).printf(rounded_days);
                }
                // FIXME: Localize these date formats, Bug 699196
                else if (dt.get_year() == new DateTime.now_local().get_year())
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6b01ca0..4349c64 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,19 +7,20 @@ gitg/gitg-application.vala
 gitg/gitg-preferences-interface.vala
 gitg/gitg.vala
 gitg/gitg-window.vala
-[type: gettext/glade]gitg/resources/ui/gitg-clone-dialog.ui
-[type: gettext/glade]gitg/resources/ui/gitg-menus.ui
-[type: gettext/glade]gitg/resources/ui/gitg-preferences-interface.ui
-[type: gettext/glade]gitg/resources/ui/gitg-preferences.ui
-[type: gettext/glade]gitg/resources/ui/gitg-user-dialog.ui
-[type: gettext/glade]gitg/resources/ui/gitg-window.ui
+libgitg/gitg-commit.vala
 plugins/diff/gitg-diff.vala
 plugins/files/gitg-files.vala
-[type: gettext/glade]plugins/files/resources/view-files.ui
 plugins/history/gitg-history-command-line.vala
 plugins/history/gitg-history-navigation.vala
 plugins/history/gitg-history-preferences.vala
 plugins/history/gitg-history.vala
 plugins/history/org.gnome.gitg.history.gschema.xml.in.in
+[type: gettext/glade]gitg/resources/ui/gitg-clone-dialog.ui
+[type: gettext/glade]gitg/resources/ui/gitg-menus.ui
+[type: gettext/glade]gitg/resources/ui/gitg-preferences-interface.ui
+[type: gettext/glade]gitg/resources/ui/gitg-preferences.ui
+[type: gettext/glade]gitg/resources/ui/gitg-user-dialog.ui
+[type: gettext/glade]gitg/resources/ui/gitg-window.ui
+[type: gettext/glade]plugins/files/resources/view-files.ui
 [type: gettext/glade]plugins/history/resources/preferences.ui
 [type: gettext/glade]plugins/history/resources/view-history.ui
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 8d07380..8d0f507 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -4,6 +4,7 @@ gitg/gitg-application.c
 gitg/gitg.c
 gitg/gitg-preferences-interface.c
 gitg/gitg-window.c
+libgitg/gitg-commit.c
 libgd/libgd/gd-header-bar.c
 libgd/libgd/gd-stack-switcher.c
 plugins/dash/gitg-dash.c


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