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/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);
Note: See TracChangeset for help on using the changeset viewer.