Bladeren bron

Initial gettext support

Héctor García 10 jaren geleden
bovenliggende
commit
17856d70a9
2 gewijzigde bestanden met toevoegingen van 18 en 8 verwijderingen
  1. 11 8
      src/mssh-window.c
  2. 7 0
      src/mssh.c

+ 11 - 8
src/mssh-window.c

@@ -6,6 +6,9 @@
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
 
+#define GETTEXT_PACKAGE "gtk20"
+#include <glib/gi18n-lib.h>
+
 #include "mssh-terminal.h"
 #include "mssh-pref.h"
 #include "mssh-gconf.h"
@@ -470,20 +473,20 @@ static void mssh_window_init(MSSHWindow* window)
     GtkWidget *file_menu = gtk_menu_new();
     GtkWidget *edit_menu = gtk_menu_new();
 
-    GtkWidget *file_item = gtk_menu_item_new_with_label("File");
-    GtkWidget *edit_item = gtk_menu_item_new_with_label("Edit");
-    GtkWidget *server_item = gtk_menu_item_new_with_label("Servers");
-    GtkWidget *command_item = gtk_menu_item_new_with_label("Commands");
+    GtkWidget *file_item = gtk_menu_item_new_with_label(_("File"));
+    GtkWidget *edit_item = gtk_menu_item_new_with_label(_("Edit"));
+    GtkWidget *server_item = gtk_menu_item_new_with_label(_("Servers"));
+    GtkWidget *command_item = gtk_menu_item_new_with_label(_("Commands"));
 
     GtkWidget *file_quit = gtk_image_menu_item_new_with_label(
-        "Quit");
+        _("Quit"));
     GtkWidget *file_sendhost = gtk_image_menu_item_new_with_label(
-        "Send hostname");
+        _("Send hostname"));
     GtkWidget *file_add = gtk_menu_item_new_with_label(
-        "Add session");
+        _("Add session"));
 
     GtkWidget *edit_pref = gtk_image_menu_item_new_with_label(
-        "Edit");
+        _("Edit"));
 
     GtkAccelGroup *accel = gtk_accel_group_new();
 

+ 7 - 0
src/mssh.c

@@ -4,6 +4,9 @@
 #include <getopt.h>
 #include <errno.h>
 
+#define GETTEXT_PACKAGE "gtk20"
+#include <glib/gi18n-lib.h>
+
 #include <gtk/gtk.h>
 
 #include "config.h"
@@ -243,6 +246,10 @@ int main(int argc, char* argv[], char* env[])
         {0, 0, 0, 0}
     };
 
+    bindtextdomain(GETTEXT_PACKAGE, PROGRAMNAME_LOCALEDIR);
+    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+    textdomain(GETTEXT_PACKAGE);
+
     if((home = getenv("HOME")) != NULL)
     {
         int len = strlen(home) + strlen(CONFFILE) + 2;