Ignore:
Timestamp:
Jan 31, 2006, 7:54:07 AM (15 years ago)
Author:
joshe
Message:

Add internationalization support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/joshe/gtk/main.c

    r73 r77  
    3535
    3636#include <gtk/gtk.h>
     37#include <glib/gi18n.h>
     38
     39#include "defines.h"
    3740
    3841#include "conf.h"
     
    143146  int avail; const char *ttext; const char *tpriv; }
    144147actionitems[] = {
    145   {"Add",         GTK_STOCK_ADD,          ACT_OPEN,   FALSE,  0,
    146    "Add a new torrent file", "XXX"},
    147   {"Start",       GTK_STOCK_EXECUTE,      ACT_START,  FALSE,
     148  {N_("Add"),         GTK_STOCK_ADD,          ACT_OPEN,   FALSE,  0,
     149   N_("Add a new torrent file"), "XXX"},
     150  {N_("Start"),       GTK_STOCK_EXECUTE,      ACT_START,  FALSE,
    148151   (TR_STATUS_STOPPING | TR_STATUS_PAUSE),
    149    "Resume a torrent that has been paused", "XXX"},
    150   {"Stop",        GTK_STOCK_STOP,         ACT_STOP,   FALSE,
     152   N_("Resume a torrent that has been paused"), "XXX"},
     153  {N_("Stop"),        GTK_STOCK_STOP,         ACT_STOP,   FALSE,
    151154   ~(TR_STATUS_STOPPING | TR_STATUS_PAUSE),
    152    "Pause a torrent", "XXX"},
    153   {"Remove",      GTK_STOCK_REMOVE,       ACT_DELETE, FALSE, ~0,
    154    "Remove a torrent from the list", "XXX"},
    155   {"Properties",  GTK_STOCK_PROPERTIES,   ACT_INFO,   FALSE, ~0,
    156    "Get additional information for a torrent", "XXX"},
    157   {"Preferences", GTK_STOCK_PREFERENCES,  ACT_PREF,   TRUE,   0,
    158    "Open preferences dialog", "XXX"},
     155   N_("Pause a torrent"), "XXX"},
     156  {N_("Remove"),      GTK_STOCK_REMOVE,       ACT_DELETE, FALSE, ~0,
     157   N_("Remove a torrent from the list"), "XXX"},
     158  {N_("Properties"),  GTK_STOCK_PROPERTIES,   ACT_INFO,   FALSE, ~0,
     159   N_("Get additional information for a torrent"), "XXX"},
     160  {N_("Preferences"), GTK_STOCK_PREFERENCES,  ACT_PREF,   TRUE,   0,
     161   N_("Open preferences dialog"), "XXX"},
    159162};
    160163
     
    171174  gtk_init(&argc, &argv);
    172175
    173   g_set_application_name("Transmission");
     176  bindtextdomain("transmission-gtk", LOCALEDIR);
     177  textdomain("transmission-gtk");
     178
     179  g_set_application_name(_("Transmission"));
    174180
    175181  tr = tr_init();
     
    416422    item = gtk_tool_button_new_from_stock(actionitems[ii].id);
    417423    data->buttons[ii] = GTK_WIDGET(item);
    418     gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), actionitems[ii].name);
     424    gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), gettext(actionitems[ii].name));
    419425    gtk_tool_item_set_tooltip(GTK_TOOL_ITEM(item), GTK_TOOLBAR(bar)->tooltips,
    420                               actionitems[ii].ttext, actionitems[ii].tpriv);
     426                              gettext(actionitems[ii].ttext), actionitems[ii].tpriv);
    421427    g_object_set_data(G_OBJECT(item), LIST_ACTION,
    422428                      GINT_TO_POINTER(actionitems[ii].act));
     
    462468
    463469  namerend = gtk_cell_renderer_text_new();
    464   col = gtk_tree_view_column_new_with_attributes("Name", namerend, NULL);
     470  col = gtk_tree_view_column_new_with_attributes(_("Name"), namerend, NULL);
    465471  gtk_tree_view_column_set_cell_data_func(col, namerend, dfname, NULL, NULL);
    466472  gtk_tree_view_column_set_expand(col, TRUE);
     
    469475  progrend = tr_cell_renderer_torrent_new();
    470476  g_object_set(progrend, "label", "<big>  fnord    fnord  </big>", NULL);
    471   col = gtk_tree_view_column_new_with_attributes("Progress", progrend, NULL);
     477  col = gtk_tree_view_column_new_with_attributes(_("Progress"), progrend, NULL);
    472478  gtk_tree_view_column_set_cell_data_func(col, progrend, dfprog, NULL, NULL);
    473479  gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
     
    544550
    545551  if(status & TR_STATUS_CHECK)
    546     top = g_strdup_printf("Checking existing files (%.1f%%)", prog);
     552    top = g_strdup_printf(_("Checking existing files (%.1f%%)"), prog);
    547553  else if(status & TR_STATUS_DOWNLOAD)
    548     top = g_strdup_printf("Finishing in %02i:%02i:%02i (%.1f%%)",
     554    top = g_strdup_printf(_("Finishing in %02i:%02i:%02i (%.1f%%)"),
    549555                           eta / 60 / 60, eta / 60 % 60, eta % 60, prog);
    550556  else if(status & TR_STATUS_SEED)
    551     top = g_strdup_printf("Seeding, uploading to %d of %d peer%s",
    552                            dpeers, tpeers, (1 == tpeers ? "" : "s"));
     557    top = g_strdup_printf(ngettext("Seeding, uploading to %d of %d peer",
     558                                   "Seeding, uploading to %d of %d peers",
     559                                   tpeers), dpeers, tpeers);
    553560  else if(status & TR_STATUS_STOPPING)
    554     top = g_strdup("Stopping...");
     561    top = g_strdup(_("Stopping..."));
    555562  else if(status & TR_STATUS_PAUSE)
    556     top = g_strdup_printf("Paused (%.1f%%)", prog);
     563    top = g_strdup_printf(_("Paused (%.1f%%)"), prog);
    557564  else {
    558565    top = g_strdup("");
     
    562569  if(status & TR_TRACKER_ERROR) {
    563570    gtk_tree_model_get(model, iter, MC_ERR, &err, -1);
    564     bottom = g_strconcat("Error: ", err, NULL);
     571    bottom = g_strconcat(_("Error: "), err, NULL);
    565572    g_free(err);
    566573  }
    567574  else if(status & TR_STATUS_DOWNLOAD)
    568     bottom = g_strdup_printf("Downloading from %i of %i peer%s",
    569                              upeers, tpeers, (1 == tpeers ? "" : "s"));
     575    bottom = g_strdup_printf(ngettext("Downloading from %i of %i peer",
     576                                      "Downloading from %i of %i peer",
     577                                      tpeers), upeers, tpeers);
    570578  else
    571579    bottom = NULL;
     
    584592dfprog(GtkTreeViewColumn *col SHUTUP, GtkCellRenderer *rend,
    585593       GtkTreeModel *model, GtkTreeIter *iter, gpointer gdata SHUTUP) {
    586   char *dlstr, *ulstr, *str;
     594  char *dlstr, *ulstr, *fmt, *str;
    587595  gfloat prog, dl, ul;
    588596
     
    597605  dlstr = readablesize(dl * 1024.0, 2);
    598606  ulstr = readablesize(ul * 1024.0, 2);
    599   str = g_strdup_printf("<small>DL: %s/s\nUL: %s/s</small>", dlstr, ulstr);
     607  fmt = g_markup_printf_escaped("<small>%s\n%s</small>",
     608                                _("DL: %s/s"), _("UL: %s/s"));
     609  str = g_strdup_printf(fmt, dlstr, ulstr);
    600610  g_object_set(rend, "text", str, "value", prog, NULL);
    601611  g_free(dlstr);
    602612  g_free(ulstr);
     613  g_free(fmt);
    603614  g_free(str);
    604615}
     
    611622  GtkTreeIter iter;
    612623  float up, down;
    613   char *upstr, *downstr, *str;
     624  char *upstr, *downstr, *fmt, *str;
    614625
    615626  blocksigs();
     
    642653  downstr = readablesize(down * 1024.0, 2);
    643654  upstr = readablesize(up * 1024.0, 2);
    644   str = g_strdup_printf("     Total DL: %s/s     Total UL: %s/s", upstr, downstr);
     655  fmt = g_strdup_printf("     %s     %s", _("Total DL: %s/s"),
     656                        _("Total UL: %s/s"));
     657  str = g_strdup_printf(fmt, upstr, downstr);
    645658  gtk_statusbar_pop(data->bar, 0);
    646659  gtk_statusbar_push(data->bar, 0, str);
    647660  g_free(str);
     661  g_free(fmt);
    648662  g_free(upstr);
    649663  g_free(downstr);
     
    735749        (NULL == ids || !(actionitems[ii].avail & status))))
    736750      continue;
    737     item = gtk_menu_item_new_with_label(actionitems[ii].name);
     751    item = gtk_menu_item_new_with_label(gettext(actionitems[ii].name));
    738752    /* set the action for the menu item */
    739753    g_object_set_data(G_OBJECT(item), LIST_ACTION,
     
    906920  if(NULL == dir && NULL != (dir = cf_getpref(PREF_DIR))) {
    907921    if(!mkdir_p(dir, 0777)) {
    908       errmsg(parentwind, "Failed to create download directory %s:\n%s",
     922      errmsg(parentwind, _("Failed to create download directory %s:\n%s"),
    909923             dir, strerror(errno));
    910924      return FALSE;
     
    917931    unblocksigs();
    918932    /* XXX would be nice to have errno strings, are they printed to stdout? */
    919     errmsg(parentwind, "Failed to open torrent file %s", torrent);
     933    errmsg(parentwind, _("Failed to open torrent file %s"), torrent);
    920934    return FALSE;
    921935  }
Note: See TracChangeset for help on using the changeset viewer.