Changeset 86 for trunk/gtk


Ignore:
Timestamp:
Feb 4, 2006, 6:03:05 PM (16 years ago)
Author:
joshe
Message:

Add internationalization support for the GTK GUI.

Location:
trunk/gtk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/conf.c

    r72 r86  
    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                               file, strerror(errno));
     73    *errstr = g_strdup_printf(
     74      _("An error occurred while opening the file %s for writing:\n%s"),
     75      file, strerror(errno));
    7476    errno = savederr;
    7577    return -1;
     
    8486    savederr = errno;
    8587    if(EAGAIN == errno)
    86       *errstr = g_strdup_printf("Another copy of %s is already running.",
     88      *errstr = g_strdup_printf(_("Another copy of %s is already running."),
    8789                                g_get_application_name());
    8890    else
    89       *errstr = g_strdup_printf("Error obtaining lock on file %s:\n%s",
    90                                 file, strerror(errno));
     91      *errstr = g_strdup_printf(
     92        _("An error occurred while locking the file %s:\n%s"),
     93        file, strerror(errno));
    9194    close(fd);
    9295    errno = savederr;
     
    106109  if(0 > stat(dir, &sb)) {
    107110    if(ENOENT != errno)
    108       *errstr = g_strdup_printf("Failed to check directory %s:\n%s",
    109                                 dir, strerror(errno));
     111      *errstr = g_strdup_printf(
     112        _("An error occurred while checking the directory %s:\n%s"),
     113        dir, strerror(errno));
    110114    else {
    111115      if(0 == mkdir(dir, 0777))
    112116        return TRUE;
    113117      else
    114         *errstr = g_strdup_printf("Failed to create directory %s:\n%s",
    115                                   dir, strerror(errno));
     118        *errstr = g_strdup_printf(
     119          _("An error occurred while creating the directory %s:\n%s"),
     120          dir, strerror(errno));
    116121    }
    117122    return FALSE;
     
    121126    return TRUE;
    122127
    123   *errstr = g_strdup_printf("%s is not a directory", dir);
     128  *errstr = g_strdup_printf(_("%s is not a directory"), dir);
    124129  return FALSE;
    125130}
     
    155160  if(NULL != err) {
    156161    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                                 path, err->message);
     162      *errstr = g_strdup_printf(
     163        _("An error occurred while opening the file %s for reading:\n%s"),
     164        path, err->message);
    159165    goto done;
    160166  }
     
    166172    switch(g_io_channel_read_line(io, &line, &len, &termpos, &err)) {
    167173      case G_IO_STATUS_ERROR:
    168         *errstr = g_strdup_printf("Error reading file %s:\n%s",
    169                                   path, err->message);
     174        *errstr = g_strdup_printf(
     175          _("An error occurred while reading from the file %s:\n%s"),
     176          path, err->message);
    170177        goto done;
    171178      case G_IO_STATUS_NORMAL:
     
    230237  if(0 > (fd = lockfile(tmpfile, errstr))) {
    231238    g_free(errstr);
    232     *errstr = g_strdup_printf("Error opening or locking file %s:\n%s",
    233                               tmpfile, strerror(errno));
     239    *errstr = g_strdup_printf(
     240      _("An error occurred while opening or locking the file %s:\n%s"),
     241      tmpfile, strerror(errno));
    234242    goto done;
    235243  }
     
    250258  if(NULL != info.err ||
    251259     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                               tmpfile, info.err->message);
     260    *errstr = g_strdup_printf(
     261      _("An error occurred while writing to the file %s:\n%s"),
     262      tmpfile, info.err->message);
    254263    g_error_free(info.err);
    255264    goto done;
     
    257266
    258267  if(0 > rename(tmpfile, file)) {
    259     *errstr = g_strdup_printf("Error renaming %s to %s:\n%s",
    260                               tmpfile, file, strerror(errno));
     268    *errstr = g_strdup_printf(
     269      _("An error occurred while renaming the file %s to %s:\n%s"),
     270      tmpfile, file, strerror(errno));
    261271    goto done;
    262272  }
     
    318328  if(NULL != err) {
    319329    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                                 path, err->message);
     330      *errstr = g_strdup_printf(
     331        _("An error occurred while opening the file %s for reading:\n%s"),
     332        path, err->message);
    322333    goto done;
    323334  }
     
    329340    switch(g_io_channel_read_line(io, &line, &len, &termpos, &err)) {
    330341      case G_IO_STATUS_ERROR:
    331         *errstr = g_strdup_printf("Error reading file %s:\n%s",
    332                                   path, err->message);
     342        *errstr = g_strdup_printf(
     343          _("An error occurred while reading from the file %s:\n%s"),
     344          path, err->message);
    333345        goto done;
    334346      case G_IO_STATUS_NORMAL:
     
    428440  if(0 > (fd = lockfile(tmpfile, errstr))) {
    429441    g_free(errstr);
    430     *errstr = g_strdup_printf("Error opening or locking file %s:\n%s",
    431                               tmpfile, strerror(errno));
     442    *errstr = g_strdup_printf(
     443      _("An error occurred while opening or locking the file %s:\n%s"),
     444      tmpfile, strerror(errno));
    432445    goto done;
    433446  }
     
    468481  if(NULL != err ||
    469482     G_IO_STATUS_ERROR == g_io_channel_shutdown(io, TRUE, &err)) {
    470     *errstr = g_strdup_printf("Error writing to file %s:\n%s",
    471                               tmpfile, err->message);
     483    *errstr = g_strdup_printf(
     484      _("An error occurred while writing to the file %s:\n%s"),
     485      tmpfile, err->message);
    472486    g_error_free(err);
    473487    goto done;
     
    475489
    476490  if(0 > rename(tmpfile, file)) {
    477     *errstr = g_strdup_printf("Error renaming %s to %s:\n%s",
    478                               tmpfile, file, strerror(errno));
     491    *errstr = g_strdup_printf(
     492      _("An error occurred while renaming the file %s to %s:\n%s"),
     493      tmpfile, file, strerror(errno));
    479494    goto done;
    480495  }
  • trunk/gtk/dialogs.c

    r70 r86  
    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,
     170               _("An error occurred while creating the directory %s:\n%s"),
    169171               strval, strerror(errno));
    170172        return;
     
    219221makeaddwind(add_torrent_func_t addfunc, GtkWindow *parent, tr_handle_t *tr,
    220222            torrents_added_func_t donefunc, void *donedata) {
    221   GtkWidget *wind = gtk_file_chooser_dialog_new("Add a Torrent", parent,
     223  GtkWidget *wind = gtk_file_chooser_dialog_new(_("Add a Torrent"), parent,
    222224    GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
    223225    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
     
    226228  GtkWidget *bbox = gtk_hbutton_box_new();
    227229  GtkWidget *autocheck = gtk_check_button_new_with_label(
    228     "Automatically start torrent");
     230    _("Automatically start torrent"));
    229231  GtkWidget *dircheck = gtk_check_button_new_with_label(
    230     "Use alternate download directory");
     232    _("Use alternate download directory"));
    231233  GtkFileFilter *filter = gtk_file_filter_new();
    232234  GtkFileFilter *unfilter = gtk_file_filter_new();
    233235  GtkWidget *getdir = gtk_file_chooser_button_new(
    234     "Choose a download directory", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
     236    _("Choose a download directory"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
    235237  const char *pref;
    236238
     
    258260  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dircheck), FALSE);
    259261
    260   gtk_file_filter_set_name(filter, "Torrent files");
     262  gtk_file_filter_set_name(filter, _("Torrent files"));
    261263  gtk_file_filter_add_pattern(filter, "*.torrent");
    262   gtk_file_filter_set_name(unfilter, "All files");
     264  gtk_file_filter_set_name(unfilter, _("All files"));
    263265  gtk_file_filter_add_pattern(unfilter, "*");
    264266
     
    322324#define INFOLINE(tab, ii, nam, val) \
    323325  do { \
     326    char *txt = g_markup_printf_escaped("<b>%s</b>", nam); \
    324327    GtkWidget *wid = gtk_label_new(NULL); \
    325328    gtk_misc_set_alignment(GTK_MISC(wid), 1, .5); \
    326     gtk_label_set_markup(GTK_LABEL(wid), "<b>" nam ":</b>"); \
     329    gtk_label_set_markup(GTK_LABEL(wid), txt); \
    327330    gtk_table_attach_defaults(GTK_TABLE(tab), wid, 0, 1, ii, ii + 1); \
    328331    wid = gtk_label_new(val); \
     
    330333    gtk_table_attach_defaults(GTK_TABLE(tab), wid, 1, 2, ii, ii + 1); \
    331334    ii++; \
     335    g_free(txt); \
    332336  } while(0);
    333337
     
    364368  if(id >= tr_torrentStat(tr, &sb))
    365369    assert(!"XXX ");
    366   str = g_strconcat(sb[id].info.name, " Properties", NULL);
     370  str = g_strdup_printf(_("%s Properties"), sb[id].info.name);
    367371  wind = gtk_dialog_new_with_buttons(str, parent,
    368372    GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
     
    384388  INFOSEP(table, ii);
    385389
    386   INFOLINEA(table, ii, "Tracker", g_strdup_printf("http://%s:%i",
     390  INFOLINEA(table, ii, _("Tracker:"), g_strdup_printf("http://%s:%i",
    387391            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));
     392  INFOLINE(table, ii, _("Announce:"), sb[id].info.trackerAnnounce);
     393  INFOLINEA(table, ii, _("Piece Size:"), readablesize(sb[id].info.pieceSize, 1));
     394  INFOLINEF(table, ii, "%i", _("Pieces:"), sb[id].info.pieceCount);
     395  INFOLINEA(table, ii, _("Total Size:"), readablesize(sb[id].info.totalSize, 1));
    392396
    393397  INFOSEP(table, ii);
    394398
    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));
     399  INFOLINE(table, ii, _("Directory:"), sb[id].folder);
     400  INFOLINEA(table, ii, _("Downloaded:"), readablesize(sb[id].downloaded, 1));
     401  INFOLINEA(table, ii, _("Uploaded:"), readablesize(sb[id].uploaded, 1));
    398402
    399403  INFOSEP(table, ii);
  • trunk/gtk/main.c

    r70 r86  
    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"), "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_("Start a torrent that is not running"), "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_("Stop a torrent that is running"), "XXX"},
     156  {N_("Remove"),      GTK_STOCK_REMOVE,       ACT_DELETE, FALSE, ~0,
     157   N_("Remove a torrent"), "XXX"},
     158  {N_("Properties"),  GTK_STOCK_PROPERTIES,   ACT_INFO,   FALSE, ~0,
     159   N_("Show additional information about a torrent"), "XXX"},
     160  {N_("Preferences"), GTK_STOCK_PREFERENCES,  ACT_PREF,   TRUE,   0,
     161   N_("Customize application behavior"), "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));
     
    451457  GtkTreeSelection *sel;
    452458  GtkCellRenderer *namerend, *progrend;
     459  char *str;
    453460
    454461  assert(MC_ROW_COUNT == ALEN(types));
     
    462469
    463470  namerend = gtk_cell_renderer_text_new();
    464   col = gtk_tree_view_column_new_with_attributes("Name", namerend, NULL);
     471  col = gtk_tree_view_column_new_with_attributes(_("Name"), namerend, NULL);
    465472  gtk_tree_view_column_set_cell_data_func(col, namerend, dfname, NULL, NULL);
    466473  gtk_tree_view_column_set_expand(col, TRUE);
     
    468475
    469476  progrend = tr_cell_renderer_torrent_new();
    470   g_object_set(progrend, "label", "<big>  fnord    fnord  </big>", NULL);
    471   col = gtk_tree_view_column_new_with_attributes("Progress", progrend, NULL);
     477  /* this string is only used to determing the size of the progress bar */
     478  str = g_markup_printf_escaped("<big>%s</big>", _("  fnord    fnord  "));
     479  g_object_set(progrend, "label", str, NULL);
     480  g_free(str);
     481  col = gtk_tree_view_column_new_with_attributes(_("Progress"), progrend, NULL);
    472482  gtk_tree_view_column_set_cell_data_func(col, progrend, dfprog, NULL, NULL);
    473483  gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
     
    544554
    545555  if(status & TR_STATUS_CHECK)
    546     top = g_strdup_printf("Checking existing files (%.1f%%)", prog);
     556    top = g_strdup_printf(_("Checking existing files (%.1f%%)"), prog);
    547557  else if(status & TR_STATUS_DOWNLOAD)
    548     top = g_strdup_printf("Finishing in %02i:%02i:%02i (%.1f%%)",
     558    top = g_strdup_printf(_("Finishing in %02i:%02i:%02i (%.1f%%)"),
    549559                           eta / 60 / 60, eta / 60 % 60, eta % 60, prog);
    550560  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"));
     561    top = g_strdup_printf(ngettext("Seeding, uploading to %d of %d peer",
     562                                   "Seeding, uploading to %d of %d peers",
     563                                   tpeers), dpeers, tpeers);
    553564  else if(status & TR_STATUS_STOPPING)
    554     top = g_strdup("Stopping...");
     565    top = g_strdup(_("Stopping..."));
    555566  else if(status & TR_STATUS_PAUSE)
    556     top = g_strdup_printf("Paused (%.1f%%)", prog);
     567    top = g_strdup_printf(_("Stopped (%.1f%%)"), prog);
    557568  else {
    558569    top = g_strdup("");
     
    562573  if(status & TR_TRACKER_ERROR) {
    563574    gtk_tree_model_get(model, iter, MC_ERR, &err, -1);
    564     bottom = g_strconcat("Error: ", err, NULL);
     575    bottom = g_strconcat(_("Error: "), err, NULL);
    565576    g_free(err);
    566577  }
    567578  else if(status & TR_STATUS_DOWNLOAD)
    568     bottom = g_strdup_printf("Downloading from %i of %i peer%s",
    569                              upeers, tpeers, (1 == tpeers ? "" : "s"));
     579    bottom = g_strdup_printf(ngettext("Downloading from %i of %i peer",
     580                                      "Downloading from %i of %i peers",
     581                                      tpeers), upeers, tpeers);
    570582  else
    571583    bottom = NULL;
     
    584596dfprog(GtkTreeViewColumn *col SHUTUP, GtkCellRenderer *rend,
    585597       GtkTreeModel *model, GtkTreeIter *iter, gpointer gdata SHUTUP) {
    586   char *dlstr, *ulstr, *str;
     598  char *dlstr, *ulstr, *str, *marked;
    587599  gfloat prog, dl, ul;
    588600
     
    597609  dlstr = readablesize(dl * 1024.0, 2);
    598610  ulstr = readablesize(ul * 1024.0, 2);
    599   str = g_strdup_printf("<small>DL: %s/s\nUL: %s/s</small>", dlstr, ulstr);
     611  str = g_strdup_printf(_("DL: %s/s\nUL: %s/s"), dlstr, ulstr);
     612  marked = g_markup_printf_escaped("<small>%s</small>", str);
    600613  g_object_set(rend, "text", str, "value", prog, NULL);
    601614  g_free(dlstr);
    602615  g_free(ulstr);
    603616  g_free(str);
     617  g_free(marked);
    604618}
    605619
     
    642656  downstr = readablesize(down * 1024.0, 2);
    643657  upstr = readablesize(up * 1024.0, 2);
    644   str = g_strdup_printf("     Total DL: %s/s     Total UL: %s/s", upstr, downstr);
     658  str = g_strdup_printf(_("     Total DL: %s/s     Total UL: %s/s"),
     659                        upstr, downstr);
    645660  gtk_statusbar_pop(data->bar, 0);
    646661  gtk_statusbar_push(data->bar, 0, str);
     
    735750        (NULL == ids || !(actionitems[ii].avail & status))))
    736751      continue;
    737     item = gtk_menu_item_new_with_label(actionitems[ii].name);
     752    item = gtk_menu_item_new_with_label(gettext(actionitems[ii].name));
    738753    /* set the action for the menu item */
    739754    g_object_set_data(G_OBJECT(item), LIST_ACTION,
     
    906921  if(NULL == dir && NULL != (dir = cf_getpref(PREF_DIR))) {
    907922    if(!mkdir_p(dir, 0777)) {
    908       errmsg(parentwind, "Failed to create download directory %s:\n%s",
     923      errmsg(parentwind,
     924             _("An error occurred while creating directory %s:\n%s"),
    909925             dir, strerror(errno));
    910926      return FALSE;
     
    917933    unblocksigs();
    918934    /* XXX would be nice to have errno strings, are they printed to stdout? */
    919     errmsg(parentwind, "Failed to open torrent file %s", torrent);
     935    errmsg(parentwind,
     936           _("An error occurred while opening the torrent file %s"), torrent);
    920937    return FALSE;
    921938  }
  • trunk/gtk/util.c

    r24 r86  
    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
  • trunk/gtk/util.h

    r24 r86  
    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.