Translate progress(1) as well

This commit is contained in:
Pierre Pronchery 2015-10-18 22:09:44 +02:00
parent 8d03db5e2b
commit 814b0026f1
5 changed files with 139 additions and 14 deletions

View File

@ -1,2 +1,3 @@
../src/compare.c ../src/compare.c
../src/fontsel.c ../src/fontsel.c
../src/progress.c

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Accessories 0.0.3\n" "Project-Id-Version: Accessories 0.0.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-18 21:56+0200\n" "POT-Creation-Date: 2015-10-18 22:06+0200\n"
"PO-Revision-Date: 2015-10-18 21:32+0200\n" "PO-Revision-Date: 2015-10-18 21:32+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: Spanish\n" "Language-Team: Spanish\n"
@ -42,3 +42,44 @@ msgstr ""
#, c-format #, c-format
msgid "Usage: %s\n" msgid "Usage: %s\n"
msgstr "" msgstr ""
#: ../src/progress.c:174
msgid "Progress"
msgstr ""
#: ../src/progress.c:194
msgid "File: "
msgstr ""
#: ../src/progress.c:216
msgid "Done: "
msgstr ""
#: ../src/progress.c:221
msgid "0.0 kB"
msgstr ""
#: ../src/progress.c:232
msgid "Remaining: "
msgstr ""
#: ../src/progress.c:327 ../src/progress.c:331
msgid "Error"
msgstr ""
#: ../src/progress.c:620
msgid "Unknown"
msgstr ""
#: ../src/progress.c:638
msgid "%H:%M:%S"
msgstr ""
#: ../src/progress.c:655
#, c-format
msgid ""
"Usage: %s [-x][-ez][-b buffer size][-f file][-l length][-p prefix]\n"
" [-t title] command [args...]\n"
" -e\tIgnored (for compatibility)\n"
" -x\tStart in embedded mode\n"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Accessories 0.0.3\n" "Project-Id-Version: Accessories 0.0.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-18 21:56+0200\n" "POT-Creation-Date: 2015-10-18 22:06+0200\n"
"PO-Revision-Date: 2015-10-18 21:32+0200\n" "PO-Revision-Date: 2015-10-18 21:32+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: French\n" "Language-Team: French\n"
@ -42,3 +42,48 @@ msgstr "Liste des fontes"
#, c-format #, c-format
msgid "Usage: %s\n" msgid "Usage: %s\n"
msgstr "Usage: %s\n" msgstr "Usage: %s\n"
#: ../src/progress.c:174
msgid "Progress"
msgstr "Progression"
#: ../src/progress.c:194
msgid "File: "
msgstr "Fichier : "
#: ../src/progress.c:216
msgid "Done: "
msgstr "Effectué : "
#: ../src/progress.c:221
msgid "0.0 kB"
msgstr "0.0 ko"
#: ../src/progress.c:232
msgid "Remaining: "
msgstr "Restant : "
#: ../src/progress.c:327 ../src/progress.c:331
msgid "Error"
msgstr "Erreur"
#: ../src/progress.c:620
msgid "Unknown"
msgstr "Inconnu"
#: ../src/progress.c:638
msgid "%H:%M:%S"
msgstr "%H:%M:%S"
#: ../src/progress.c:655
#, c-format
msgid ""
"Usage: %s [-x][-ez][-b buffer size][-f file][-l length][-p prefix]\n"
" [-t title] command [args...]\n"
" -e\tIgnored (for compatibility)\n"
" -x\tStart in embedded mode\n"
msgstr ""
"Usage: %s [-x][-ez][-b taille tampon][-f fichier][-l length][-p préfixe]\n"
" [-t titre] commande [arguments...]\n"
" -e\tIgnoré (compatibilité)\n"
" -x\tDémarrer en mode embarqué\n"

View File

@ -26,13 +26,27 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <locale.h>
#include <libintl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
# include <gtk/gtkx.h> # include <gtk/gtkx.h>
#endif #endif
#include "../config.h"
#define _(string) gettext(string)
/* constants */
#ifndef PROGNAME #ifndef PROGNAME
# define PROGNAME "progress" # define PROGNAME "progress"
#endif
#ifndef PREFIX
# define PREFIX "/usr/local"
#endif
#ifndef DATADIR
# define DATADIR PREFIX "/share"
#endif
#ifndef LOCALEDIR
# define LOCALEDIR DATADIR "/locale"
#endif #endif
@ -79,7 +93,14 @@ typedef struct _Progress
int pulse; /* tells when to pulse */ int pulse; /* tells when to pulse */
} Progress; } Progress;
/* prototypes */
static int _error(char const * message, int ret);
static int _usage(void);
/* functions */ /* functions */
/* progress */
static int _progress_error(Progress * progress, char const * message, int ret); static int _progress_error(Progress * progress, char const * message, int ret);
static int _progress_gerror(Progress * progress, char const * message, static int _progress_gerror(Progress * progress, char const * message,
GError * error, int ret); GError * error, int ret);
@ -150,7 +171,7 @@ static int _progress(Prefs * prefs, char * argv[])
gtk_window_set_has_resize_grip(GTK_WINDOW(p.window), FALSE); gtk_window_set_has_resize_grip(GTK_WINDOW(p.window), FALSE);
#endif #endif
gtk_window_set_title(GTK_WINDOW(p.window), prefs->title != NULL gtk_window_set_title(GTK_WINDOW(p.window), prefs->title != NULL
? prefs->title : "Progress"); ? prefs->title : _("Progress"));
g_signal_connect_swapped(p.window, "delete-event", G_CALLBACK( g_signal_connect_swapped(p.window, "delete-event", G_CALLBACK(
_progress_closex), p.window); _progress_closex), p.window);
} }
@ -170,7 +191,7 @@ static int _progress(Prefs * prefs, char * argv[])
left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
right = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); right = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
/* file */ /* file */
widget = gtk_label_new("File: "); widget = gtk_label_new(_("File: "));
bold = pango_font_description_new(); bold = pango_font_description_new();
pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD); pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD);
gtk_widget_modify_font(widget, bold); gtk_widget_modify_font(widget, bold);
@ -192,12 +213,12 @@ static int _progress(Prefs * prefs, char * argv[])
#else #else
hbox = gtk_hbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0);
#endif #endif
widget = gtk_label_new("Done: "); widget = gtk_label_new(_("Done: "));
gtk_widget_modify_font(widget, bold); gtk_widget_modify_font(widget, bold);
gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
gtk_size_group_add_widget(left, widget); gtk_size_group_add_widget(left, widget);
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
p.done = gtk_label_new("0.0 kB"); p.done = gtk_label_new(_("0.0 kB"));
gtk_misc_set_alignment(GTK_MISC(p.done), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(p.done), 0.0, 0.5);
gtk_size_group_add_widget(right, p.done); gtk_size_group_add_widget(right, p.done);
gtk_box_pack_start(GTK_BOX(hbox), p.done, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), p.done, TRUE, TRUE, 0);
@ -208,7 +229,7 @@ static int _progress(Prefs * prefs, char * argv[])
#else #else
hbox = gtk_hbox_new(FALSE, 0); hbox = gtk_hbox_new(FALSE, 0);
#endif #endif
widget = gtk_label_new("Remaining: "); widget = gtk_label_new(_("Remaining: "));
gtk_widget_modify_font(widget, bold); gtk_widget_modify_font(widget, bold);
gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
gtk_size_group_add_widget(left, widget); gtk_size_group_add_widget(left, widget);
@ -303,11 +324,11 @@ static int _error_do(Progress * progress, char const * message,
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
#if GTK_CHECK_VERSION(2, 6, 0) #if GTK_CHECK_VERSION(2, 6, 0)
"%s", "Error"); "%s", _("Error"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
#endif #endif
"%s: %s", message, error); "%s: %s", message, error);
gtk_window_set_title(GTK_WINDOW(dialog), "Error"); gtk_window_set_title(GTK_WINDOW(dialog), _("Error"));
gtk_dialog_run(GTK_DIALOG(dialog)); gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
return ret; return ret;
@ -595,7 +616,8 @@ static void _timeout_remaining(Progress * progress, guint64 rate)
if(progress->prefs->length == 0 || rate == 0) if(progress->prefs->length == 0 || rate == 0)
{ {
gtk_label_set_text(GTK_LABEL(progress->remaining), "Unknown"); gtk_label_set_text(GTK_LABEL(progress->remaining),
_("Unknown"));
return; return;
} }
remaining = (progress->prefs->length - progress->cnt) / rate; remaining = (progress->prefs->length - progress->cnt) / rate;
@ -613,19 +635,28 @@ static void _timeout_remaining(Progress * progress, guint64 rate)
tm.tm_hour = tm.tm_min / 60; tm.tm_hour = tm.tm_min / 60;
tm.tm_min = tm.tm_min - (tm.tm_hour * 60); tm.tm_min = tm.tm_min - (tm.tm_hour * 60);
} }
strftime(buf, sizeof(buf), "%H:%M:%S", &tm); strftime(buf, sizeof(buf), _("%H:%M:%S"), &tm);
gtk_label_set_text(GTK_LABEL(progress->remaining), buf); gtk_label_set_text(GTK_LABEL(progress->remaining), buf);
} }
/* error */
static int _error(char const * message, int ret)
{
fputs(PROGNAME ": ", stderr);
perror(message);
return ret;
}
/* usage */ /* usage */
static int _usage(void) static int _usage(void)
{ {
fputs("Usage: " PROGNAME " [-x][-ez][-b buffer size][-f file][-l length]" fprintf(stderr, _("Usage: %s [-x][-ez][-b buffer size][-f file][-l length]"
"[-p prefix]\n" "[-p prefix]\n"
" [-t title] command [args...]\n" " [-t title] command [args...]\n"
" -e Ignored (for compatibility)\n" " -e Ignored (for compatibility)\n"
" -x Start in embedded mode\n", stderr); " -x Start in embedded mode\n"), PROGNAME);
return 1; return 1;
} }
@ -639,6 +670,10 @@ int main(int argc, char * argv[])
memset(&prefs, 0, sizeof(prefs)); memset(&prefs, 0, sizeof(prefs));
prefs.bufsiz = 65536; prefs.bufsiz = 65536;
if(setlocale(LC_ALL, "") == NULL)
_error("setlocale", 1);
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
while((o = getopt(argc, argv, "b:ef:l:p:t:xz")) != -1) while((o = getopt(argc, argv, "b:ef:l:p:t:xz")) != -1)
switch(o) switch(o)

View File

@ -32,3 +32,6 @@ sources=progress.c
#cflags=`pkg-config --cflags gtk+-x11-3.0` #cflags=`pkg-config --cflags gtk+-x11-3.0`
#ldflags=`pkg-config --cflags gtk+-x11-3.0` #ldflags=`pkg-config --cflags gtk+-x11-3.0`
install=$(BINDIR) install=$(BINDIR)
[progress.c]
depends=../config.h