summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ferretti <elle.uca@libero.it>2008-01-18 10:07:14 +0000
committerLuca Ferretti <lferrett@src.gnome.org>2008-01-18 10:07:14 +0000
commit32140fb6e6ba62f8eab55b749fd83f75742269cf (patch)
treec4304bdd1dcef4e74e37900a160dd33b4a785ea6
parent71500d8d36e2157397d275110c34bbe0d658f1e1 (diff)
downloadgvfs-32140fb6e6ba62f8eab55b749fd83f75742269cf.tar.gz
Add i18n/l10n to gvfs-cat, plus indentation. For details see
2008-01-18 Luca Ferretti <elle.uca@libero.it> * programs/Makefile.am: * programs/gvfs-cat.c: (cat), (main): Add i18n/l10n to gvfs-cat, plus indentation. For details see http://mail.gnome.org/archives/gnome-vfs-list/2008-January/msg00020.html po/POTFILES.in: Added programs/gvfs-cat.c svn path=/trunk/; revision=1149
-rw-r--r--ChangeLog7
-rw-r--r--po/ChangeLog4
-rw-r--r--po/POTFILES.in1
-rw-r--r--programs/Makefile.am39
-rw-r--r--programs/gvfs-cat.c155
5 files changed, 137 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index 140254c9..58065b1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-01-18 Luca Ferretti <elle.uca@libero.it>
+
+ * programs/Makefile.am:
+ * programs/gvfs-cat.c: (cat), (main):
+ Add i18n/l10n to gvfs-cat, plus indentation. For details see
+ http://mail.gnome.org/archives/gnome-vfs-list/2008-January/msg00020.html
+
2008-01-18 David Zeuthen <davidz@redhat.com>
The volume monitor bits of gphoto2 support. The actual backend
diff --git a/po/ChangeLog b/po/ChangeLog
index ccb06393..79441446 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,3 +1,7 @@
+2008-01-18 Luca Ferretti <elle.uca@libero.it>
+
+ * POTFILES.in: Added programs/gvfs-cat.c
+
2008-01-17 Jorge Gonzalez <jorgegonz@svn.gnome.org>
* es.po: Updated Spanish translation
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ec19b50b..06bbd1f8 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -57,3 +57,4 @@ hal/ghaldrive.c
hal/ghalmount.c
hal/ghalvolume.c
hal/ghalvolumemonitor.c
+programs/gvfs-cat.c
diff --git a/programs/Makefile.am b/programs/Makefile.am
index 23569728..4d2d8a21 100644
--- a/programs/Makefile.am
+++ b/programs/Makefile.am
@@ -1,30 +1,31 @@
NULL =
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- $(GLIB_CFLAGS) \
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ $(GLIB_CFLAGS) \
+ -DGVFS_LOCALEDIR=\""$(localedir)"\" \
-DG_DISABLE_DEPRECATED
-libraries = \
+libraries = \
$(GLIB_LIBS)
-bin_PROGRAMS = \
- gvfs-mount \
- gvfs-cat \
- gvfs-save \
- gvfs-ls \
- gvfs-info \
- gvfs-trash \
- gvfs-rm \
- gvfs-copy \
- gvfs-move \
- gvfs-monitor-file \
- gvfs-monitor-dir \
+bin_PROGRAMS = \
+ gvfs-mount \
+ gvfs-cat \
+ gvfs-save \
+ gvfs-ls \
+ gvfs-info \
+ gvfs-trash \
+ gvfs-rm \
+ gvfs-copy \
+ gvfs-move \
+ gvfs-monitor-file \
+ gvfs-monitor-dir \
$(NULL)
-bin_SCRIPTS = \
- gvfs-less \
+bin_SCRIPTS = \
+ gvfs-less \
$(NULL)
gvfs_cat_SOURCES = gvfs-cat.c
diff --git a/programs/gvfs-cat.c b/programs/gvfs-cat.c
index 0d6c9b41..351f8714 100644
--- a/programs/gvfs-cat.c
+++ b/programs/gvfs-cat.c
@@ -1,3 +1,5 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
/* GIO - GLib Input, Output and Streaming Library
*
* Copyright (C) 2006-2007 Red Hat, Inc.
@@ -28,70 +30,87 @@
#include <errno.h>
#include <glib.h>
+#include <glib/gi18n.h>
#include <gio/gio.h>
-static GOptionEntry entries[] =
-{
- { NULL }
+static gchar **locations = NULL;
+
+static GOptionEntry entries[] = {
+ {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &locations, "locations", NULL},
+ {NULL}
};
static void
-cat (GFile *file)
+cat (GFile * file)
{
GInputStream *in;
- char buffer[1024*8 + 1];
+ char buffer[1024 * 8 + 1];
char *p;
gssize res;
gboolean close_res;
GError *error;
-
+
error = NULL;
- in = (GInputStream *)g_file_read (file, NULL, &error);
+ in = (GInputStream *) g_file_read (file, NULL, &error);
if (in == NULL)
{
- g_printerr ("Error opening file: %s\n", error->message);
+ /* Translators: the first %s is the program name, the second one */
+ /* is the URI of the file, the third is the error message. */
+ g_printerr (_("%s: %s: error opening file: %s\n"),
+ g_get_prgname (), g_file_get_uri (file), error->message);
g_error_free (error);
return;
}
while (1)
{
- res = g_input_stream_read (in, buffer, sizeof (buffer) - 1, NULL, &error);
+ res =
+ g_input_stream_read (in, buffer, sizeof (buffer) - 1, NULL, &error);
if (res > 0)
- {
- ssize_t written;
-
- p = buffer;
- while (res > 0)
- {
- written = write (STDOUT_FILENO, p, res);
-
- if (written == -1 && errno != EINTR)
- {
- perror ("Error writing to stdout");
- goto out;
- }
- res -= written;
- p += written;
- }
- }
+ {
+ ssize_t written;
+
+ p = buffer;
+ while (res > 0)
+ {
+ written = write (STDOUT_FILENO, p, res);
+
+ if (written == -1 && errno != EINTR)
+ {
+ /* Translators: the first %s is the program name, the */
+ /* second one is the URI of the file. */
+ g_printerr (_("%s: %s, error writing to stdout"),
+ g_get_prgname (), g_file_get_uri (file));
+ goto out;
+ }
+ res -= written;
+ p += written;
+ }
+ }
else if (res < 0)
- {
- g_printerr ("Error reading: %s\n", error->message);
- g_error_free (error);
- error = NULL;
- break;
- }
+ {
+ /* Translators: the first %s is the program name, the second one */
+ /* is the URI of the file, the third is the error message. */
+ g_printerr (_("%s: %s: error reading: %s\n"),
+ g_get_prgname (), g_file_get_uri (file),
+ error->message);
+ g_error_free (error);
+ error = NULL;
+ break;
+ }
else if (res == 0)
- break;
+ break;
}
out:
-
+
close_res = g_input_stream_close (in, NULL, &error);
if (!close_res)
{
- g_printerr ("Error closing: %s\n", error->message);
+ /* Translators: the first %s is the program name, the second one */
+ /* is the URI of the file, the third is the error message. */
+ g_printerr (_("%s: %s:error closing: %s\n"),
+ g_get_prgname (), g_file_get_uri (file), error->message);
g_error_free (error);
}
}
@@ -99,30 +118,66 @@ cat (GFile *file)
int
main (int argc, char *argv[])
{
- GError *error;
- GOptionContext *context;
+ GError *error = NULL;
+ GOptionContext *context = NULL;
GFile *file;
-
+ gchar *summary;
+
setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GVFS_LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
g_type_init ();
-
- error = NULL;
- context = g_option_context_new ("- output files at <location>");
+
+ /* Translators: this message will appear immediately after the */
+ /* usage string - Usage: COMMAND [OPTION]... <THIS_MESSAGE> */
+ context =
+ g_option_context_new (_("LOCATION... - concatenate LOCATIONS "
+ "to standard output."));
+
+ /* Translators: this message will appear after the usage string */
+ /* and before the list of options. */
+ summary = g_strconcat (_("Concatenate files at locations and print to the "
+ "standard output. Works just like the traditional "
+ "cat utility, but using gvfs location instead "
+ "local files: for example you can use something "
+ "like smb://server/resource/file.txt as location "
+ "to concatenate."),
+ "\n\n",
+ _("Note: just pipe through cat if you need its "
+ "formatting option like -n, -T or other."), NULL);
+
+ g_option_context_set_summary (context, summary);
+
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_parse (context, &argc, &argv, &error);
+
g_option_context_free (context);
-
- if (argc > 1)
+ g_free (summary);
+
+ if (!locations)
+ {
+ /* Translators: the %s is the program name. This error message */
+ /* means the user is calling gvfs-cat without any argument. */
+ g_printerr (_("%s: missing locations"), g_get_prgname ());
+ g_printerr ("\n");
+ g_printerr (_("Try \"%s --help\" for more information."),
+ g_get_prgname ());
+ g_printerr ("\n");
+ return 1;
+ }
+
+ int i = 0;
+
+ do
{
- int i;
-
- for (i = 1; i < argc; i++) {
- file = g_file_new_for_commandline_arg (argv[i]);
- cat (file);
- g_object_unref (file);
- }
+ file = g_file_new_for_commandline_arg (locations[i]);
+ cat (file);
+ g_object_unref (file);
}
+ while (locations[++i] != NULL);
return 0;
}