Changeset 77


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

Add internationalization support.

Location:
branches/joshe
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/joshe/configure

    r69 r77  
    1212    --openssl-prefix=PATH  Location of OpenSSL headers and library
    1313    --disable-gtk          Don't build the GTK+ GUI
     14    --prefix=PATH          Install here instead of $INSTALL_PREFIX
    1415
    1516  Some influential environment variables:
     
    6364        GTKCCFLAGS=`pkg-config gtk+-2.0 --cflags`
    6465        GTKLINKLIBS=`pkg-config gtk+-2.0 --libs`
     66        GTKLOCALEDIR="$INSTALL_PREFIX/share/locale"
    6567      else
    6668        echo "GTK+:    no"
     
    9294GTKCCFLAGS=
    9395GTKLINKLIBS=
     96GTKLOCALEDIR=
     97if [ -n "$PREFIX" ]; then
     98    INSTALL_PREFIX=$PREFIX
     99else
     100    INSTALL_PREFIX=/usr/local
     101fi
    94102
    95103#
     
    108116    x--disable-gtk)
    109117      gtk_disable="1";
     118      ;;
     119    x--prefix=*)
     120      INSTALL_PREFIX="$param";
    110121      ;;
    111122    x--help)
     
    239250fi
    240251
     252if [ xyes = "x$GTK" ]; then
     253    rm -f gtk/defines.h
     254    cat > gtk/defines.h << EOF
     255#ifndef TG_DEFINES_H
     256#define TG_DEFINES_H
     257#define LOCALEDIR               "$GTKLOCALEDIR"
     258#endif
     259EOF
     260fi
     261
    241262echo
    242263echo "To build Transmission, run 'jam'."
  • branches/joshe/gtk/conf.c

    r73 r77  
    3737
    3838#include <gtk/gtk.h>
     39#include <glib/gi18n.h>
    3940
    4041#include "conf.h"
     
    7071  if(0 > (fd = open(file, O_RDWR | O_CREAT, 0666))) {
    7172    savederr = errno;
    72     *errstr = g_strdup_printf("Error opening file %s for writing:\n%s",
     73    *errstr = g_strdup_printf(_("Error opening file %s for writing:\n%s"),
    7374                              file, strerror(errno));
    7475    errno = savederr;
     
    8485    savederr = errno;
    8586    if(EAGAIN == errno)
    86       *errstr = g_strdup_printf("Another copy of %s is already running.",
     87      *errstr = g_strdup_printf(_("Another copy of %s is already running."),
    8788                                g_get_application_name());
    8889    else
    89       *errstr = g_strdup_printf("Error obtaining lock on file %s:\n%s",
     90      *errstr = g_strdup_printf(_("Error obtaining lock on file %s:\n%s"),
    9091                                file, strerror(errno));
    9192    close(fd);
     
    106107  if(0 > stat(dir, &sb)) {
    107108    if(ENOENT != errno)
    108       *errstr = g_strdup_printf("Failed to check directory %s:\n%s",
     109      *errstr = g_strdup_printf(_("Failed to check directory %s:\n%s"),
    109110                                dir, strerror(errno));
    110111    else {
     
    112113        return TRUE;
    113114      else
    114         *errstr = g_strdup_printf("Failed to create directory %s:\n%s",
     115        *errstr = g_strdup_printf(_("Failed to create directory %s:\n%s"),
    115116                                  dir, strerror(errno));
    116117    }
     
    121122    return TRUE;
    122123
    123   *errstr = g_strdup_printf("%s is not a directory", dir);
     124  *errstr = g_strdup_printf(_("%s is not a directory"), dir);
    124125  return FALSE;
    125126}
     
    155156  if(NULL != err) {
    156157    if(!g_error_matches(err, G_FILE_ERROR, G_FILE_ERROR_NOENT))
    157       *errstr = g_strdup_printf("Error opening file %s for reading:\n%s",
     158      *errstr = g_strdup_printf(_("Error opening file %s for reading:\n%s"),
    158159                                path, err->message);
    159160    goto done;
     
    166167    switch(g_io_channel_read_line(io, &line, &len, &termpos, &err)) {
    167168      case G_IO_STATUS_ERROR:
    168         *errstr = g_strdup_printf("Error reading file %s:\n%s",
     169        *errstr = g_strdup_printf(_("Error reading file %s:\n%s"),
    169170                                  path, err->message);
    170171        goto done;
     
    230231  if(0 > (fd = lockfile(tmpfile, errstr))) {
    231232    g_free(errstr);
    232     *errstr = g_strdup_printf("Error opening or locking file %s:\n%s",
     233    *errstr = g_strdup_printf(_("Error opening or locking file %s:\n%s"),
    233234                              tmpfile, strerror(errno));
    234235    goto done;
     
    250251  if(NULL != info.err ||
    251252     G_IO_STATUS_ERROR == g_io_channel_shutdown(io, TRUE, &info.err)) {
    252     *errstr = g_strdup_printf("Error writing to file %s:\n%s",
     253    *errstr = g_strdup_printf(_("Error writing to file %s:\n%s"),
    253254                              tmpfile, info.err->message);
    254255    g_error_free(info.err);
     
    257258
    258259  if(0 > rename(tmpfile, file)) {
    259     *errstr = g_strdup_printf("Error renaming %s to %s:\n%s",
     260    *errstr = g_strdup_printf(_("Error renaming %s to %s:\n%s"),
    260261                              tmpfile, file, strerror(errno));
    261262    goto done;
     
    318319  if(NULL != err) {
    319320    if(!g_error_matches(err, G_FILE_ERROR, G_FILE_ERROR_NOENT))
    320       *errstr = g_strdup_printf("Error opening file %s for reading:\n%s",
     321      *errstr = g_strdup_printf(_("Error opening file %s for reading:\n%s"),
    321322                                path, err->message);
    322323    goto done;
     
    329330    switch(g_io_channel_read_line(io, &line, &len, &termpos, &err)) {
    330331      case G_IO_STATUS_ERROR:
    331         *errstr = g_strdup_printf("Error reading file %s:\n%s",
     332        *errstr = g_strdup_printf(_("Error reading file %s:\n%s"),
    332333                                  path, err->message);
    333334        goto done;
     
    428429  if(0 > (fd = lockfile(tmpfile, errstr))) {
    429430    g_free(errstr);
    430     *errstr = g_strdup_printf("Error opening or locking file %s:\n%s",
     431    *errstr = g_strdup_printf(_("Error opening or locking file %s:\n%s"),
    431432                              tmpfile, strerror(errno));
    432433    goto done;
     
    468469  if(NULL != err ||
    469470     G_IO_STATUS_ERROR == g_io_channel_shutdown(io, TRUE, &err)) {
    470     *errstr = g_strdup_printf("Error writing to file %s:\n%s",
     471    *errstr = g_strdup_printf(_("Error writing to file %s:\n%s"),
    471472                              tmpfile, err->message);
    472473    g_error_free(err);
     
    475476
    476477  if(0 > rename(tmpfile, file)) {
    477     *errstr = g_strdup_printf("Error renaming %s to %s:\n%s",
     478    *errstr = g_strdup_printf(_("Error renaming %s to %s:\n%s"),
    478479                              tmpfile, file, strerror(errno));
    479480    goto done;
  • branches/joshe/gtk/dialogs.c

    r73 r77  
    3131
    3232#include <gtk/gtk.h>
     33#include <glib/gi18n.h>
    3334
    3435#include "conf.h"
     
    7172void
    7273makeprefwindow(GtkWindow *parent, tr_handle_t *tr) {
    73   char *title = g_strconcat(g_get_application_name(), " Preferences", NULL);
     74  char *title = g_strdup_printf(_("%s Preferences"), g_get_application_name());
    7475  GtkWidget *wind = gtk_dialog_new_with_buttons(title, parent,
    7576   GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
     
    7879  GtkWidget *table = gtk_table_new(4, 2, FALSE);
    7980  GtkWidget *portnum = gtk_spin_button_new_with_range(1, 0xffff, 1);
    80   GtkWidget *limitbox = gtk_check_button_new_with_label("Limit upload speed");
     81  GtkWidget *limitbox = gtk_check_button_new_with_label(_("Limit upload speed"));
    8182  GtkWidget *limitnum = gtk_spin_button_new_with_range(0, G_MAXLONG, 1);
    82   GtkWidget *dirstr = gtk_file_chooser_button_new("Choose download directory",
     83  GtkWidget *dirstr = gtk_file_chooser_button_new(_("Choose download directory"),
    8384    GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
    8485  GtkWidget *label;
     
    101102
    102103  /* port label and entry */
    103   label = gtk_label_new("Listening port:");
     104  label = gtk_label_new(_("Listening port:"));
    104105  gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
    105106  pref = cf_getpref(PREF_PORT);
     
    119120
    120121  /* limit label and entry */
    121   label = gtk_label_new("Maximum upload speed:");
     122  label = gtk_label_new(_("Maximum upload speed:"));
    122123  gtk_misc_set_alignment(GTK_MISC(label), 0, 1.0/3.0);
    123124  pref = cf_getpref(PREF_LIMIT);
     
    131132
    132133  /* directory label and chooser */
    133   label = gtk_label_new("Download Directory:");
     134  label = gtk_label_new(_("Download Directory:"));
    134135  gtk_misc_set_alignment(GTK_MISC(label), 0, .5);
    135136  if(NULL != (pref = cf_getpref(PREF_DIR)))
     
    166167    if(NULL != (strval = gtk_file_chooser_get_current_folder(data->dir))) {
    167168      if(!mkdir_p(strval, 0777)) {
    168         errmsg(data->parent, "Failed to create directory %s:\n%s",
     169        errmsg(data->parent, _("Failed to create directory %s:\n%s"),
    169170               strval, strerror(errno));
    170171        return;
     
    219220makeaddwind(add_torrent_func_t addfunc, GtkWindow *parent, tr_handle_t *tr,
    220221            torrents_added_func_t donefunc, void *donedata) {
    221   GtkWidget *wind = gtk_file_chooser_dialog_new("Add a Torrent", parent,
     222  GtkWidget *wind = gtk_file_chooser_dialog_new(_("Add a Torrent"), parent,
    222223    GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
    223224    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
     
    226227  GtkWidget *bbox = gtk_hbutton_box_new();
    227228  GtkWidget *autocheck = gtk_check_button_new_with_label(
    228     "Automatically start torrent");
     229    _("Automatically start torrent"));
    229230  GtkWidget *dircheck = gtk_check_button_new_with_label(
    230     "Use alternate download directory");
     231    _("Use alternate download directory"));
    231232  GtkFileFilter *filter = gtk_file_filter_new();
    232233  GtkFileFilter *unfilter = gtk_file_filter_new();
    233234  GtkWidget *getdir = gtk_file_chooser_button_new(
    234     "Choose a download directory", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
     235    _("Choose a download directory"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
    235236  const char *pref;
    236237
     
    258259  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dircheck), FALSE);
    259260
    260   gtk_file_filter_set_name(filter, "Torrent files");
     261  gtk_file_filter_set_name(filter, _("Torrent files"));
    261262  gtk_file_filter_add_pattern(filter, "*.torrent");
    262   gtk_file_filter_set_name(unfilter, "All files");
     263  gtk_file_filter_set_name(unfilter, _("All files"));
    263264  gtk_file_filter_add_pattern(unfilter, "*");
    264265
     
    322323#define INFOLINE(tab, ii, nam, val) \
    323324  do { \
     325    char *txt = g_markup_printf_escaped("<b>%s</b>", nam); \
    324326    GtkWidget *wid = gtk_label_new(NULL); \
    325327    gtk_misc_set_alignment(GTK_MISC(wid), 1, .5); \
    326     gtk_label_set_markup(GTK_LABEL(wid), "<b>" nam ":</b>"); \
     328    gtk_label_set_markup(GTK_LABEL(wid), txt); \
    327329    gtk_table_attach_defaults(GTK_TABLE(tab), wid, 0, 1, ii, ii + 1); \
    328330    wid = gtk_label_new(val); \
     
    330332    gtk_table_attach_defaults(GTK_TABLE(tab), wid, 1, 2, ii, ii + 1); \
    331333    ii++; \
     334    g_free(txt); \
    332335  } while(0);
    333336
     
    364367  if(id >= tr_torrentStat(tr, &sb))
    365368    assert(!"XXX ");
    366   str = g_strconcat(sb[id].info.name, " Properties", NULL);
     369  str = g_strdup_printf(_("%s Properties"), sb[id].info.name);
    367370  wind = gtk_dialog_new_with_buttons(str, parent,
    368371    GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
     
    384387  INFOSEP(table, ii);
    385388
    386   INFOLINEA(table, ii, "Tracker", g_strdup_printf("http://%s:%i",
     389  INFOLINEA(table, ii, _("Tracker:"), g_strdup_printf("http://%s:%i",
    387390            sb[id].info.trackerAddress, sb[id].info.trackerPort));
    388   INFOLINE(table, ii, "Announce", sb[id].info.trackerAnnounce);
    389   INFOLINEA(table, ii, "Piece Size", readablesize(sb[id].info.pieceSize, 1));
    390   INFOLINEF(table, ii, "%i", "Pieces", sb[id].info.pieceCount);
    391   INFOLINEA(table, ii, "Total Size", readablesize(sb[id].info.totalSize, 1));
     391  INFOLINE(table, ii, _("Announce:"), sb[id].info.trackerAnnounce);
     392  INFOLINEA(table, ii, _("Piece Size:"), readablesize(sb[id].info.pieceSize, 1));
     393  INFOLINEF(table, ii, "%i", _("Pieces:"), sb[id].info.pieceCount);
     394  INFOLINEA(table, ii, _("Total Size:"), readablesize(sb[id].info.totalSize, 1));
    392395
    393396  INFOSEP(table, ii);
    394397
    395   INFOLINE(table, ii, "Directory", sb[id].folder);
    396   INFOLINEA(table, ii, "Downloaded", readablesize(sb[id].downloaded, 1));
    397   INFOLINEA(table, ii, "Uploaded", readablesize(sb[id].uploaded, 1));
     398  INFOLINE(table, ii, _("Directory:"), sb[id].folder);
     399  INFOLINEA(table, ii, _("Downloaded:"), readablesize(sb[id].downloaded, 1));
     400  INFOLINEA(table, ii, _("Uploaded:"), readablesize(sb[id].uploaded, 1));
    398401
    399402  INFOSEP(table, ii);
  • 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  }
  • branches/joshe/gtk/util.c

    r24 r77  
    3333
    3434#include <gtk/gtk.h>
     35#include <glib/gi18n.h>
    3536
    3637#include "util.h"
     
    5960}
    6061
     62static const char *sizestrs[] = {
     63  N_("B"), N_("KiB"), N_("MiB"), N_("GiB"), N_("TiB"), N_("PiB"), N_("EiB"),
     64};
     65
    6166char *
    6267readablesize(guint64 size, int decimals) {
    63   const char *sizes[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"};
    6468  unsigned int ii;
    6569  double small = size;
    6670
    67   for(ii = 0; ii + 1 < ALEN(sizes) && 1024.0 <= small / 1024.0; ii++)
     71  for(ii = 0; ii + 1 < ALEN(sizestrs) && 1024.0 <= small / 1024.0; ii++)
    6872    small /= 1024.0;
    6973
     
    7377  }
    7478
    75   return g_strdup_printf("%.*f %s", decimals, small, sizes[ii]);
     79  return g_strdup_printf("%.*f %s", decimals, small, gettext(sizestrs[ii]));
    7680}
    7781
  • branches/joshe/gtk/util.h

    r24 r77  
    4545
    4646/* try to interpret a string as a textual representation of a boolean */
     47/* note that this isn't localized */
    4748gboolean
    4849strbool(const char *str);
Note: See TracChangeset for help on using the changeset viewer.