summaryrefslogtreecommitdiff
path: root/xload.c
diff options
context:
space:
mode:
authorJay Hobson <jay.hobson@sun.com>2000-08-25 14:29:09 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2010-01-15 22:17:15 -0800
commit6d96dd3d2df7d896a41d770ba380629948ead4d6 (patch)
tree22d51ce05129707f1bf73362cc00030a7969ca5f /xload.c
parentd957cad1a453a84309cef3e30237c39d0541ecc4 (diff)
Internationalize xload: Call gettext on strings printed to stderr
Originally done for Solaris 9 to fix Sun bug 4365629 http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4365629 Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Diffstat (limited to 'xload.c')
-rw-r--r--xload.c93
1 files changed, 65 insertions, 28 deletions
diff --git a/xload.c b/xload.c
index e423e65..7cfcb86 100644
--- a/xload.c
+++ b/xload.c
@@ -29,6 +29,29 @@ other dealings in this Software without prior written authorization
from the X Consortium.
*/
+/*
+ * Copyright © 2000 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
/*
* xload - display system load average in a window
@@ -50,6 +73,9 @@ from the X Consortium.
#include <X11/Xmu/SysUtil.h>
#include "xload.h"
+#include <libintl.h>
+#include <X11/Xlocale.h>
+
#include "xload.bit"
static char *ProgramName;
@@ -109,32 +135,32 @@ static int light_update = 10 * 1000;
static void usage(void)
{
- fprintf (stderr, "usage: %s [-options ...]\n\n", ProgramName);
- fprintf (stderr, "where options include:\n");
- fprintf (stderr,
- " -display dpy X server on which to display\n");
- fprintf (stderr,
- " -geometry geom size and location of window\n");
- fprintf (stderr,
- " -fn font font to use in label\n");
- fprintf (stderr,
- " -scale number minimum number of scale lines\n");
- fprintf (stderr,
- " -update seconds interval between updates\n");
- fprintf (stderr,
- " -label string annotation text\n");
- fprintf (stderr,
- " -bg color background color\n");
- fprintf (stderr,
- " -fg color graph color\n");
- fprintf (stderr,
- " -hl color scale and text color\n");
- fprintf (stderr,
- " -nolabel removes the label from above the chart.\n");
- fprintf (stderr,
- " -jumpscroll value number of pixels to scroll on overflow\n");
- fprintf (stderr,
- " -remote host remote host to monitor\n");
+ fprintf (stderr, gettext("usage: %s [-options ...]\n\n"), ProgramName);
+ fprintf (stderr, gettext("where options include:\n"));
+ fprintf (stderr, " -display %s",
+ gettext("display X server on which to display\n"));
+ fprintf (stderr, " -geometry %s",
+ gettext("geometry size and location of window\n"));
+ fprintf (stderr, " -fn %s",
+ gettext("font font to use in label\n"));
+ fprintf (stderr, " -scale %s",
+ gettext("number minimum number of scale lines\n"));
+ fprintf (stderr, " -update %s",
+ gettext("seconds interval between updates\n"));
+ fprintf (stderr, " -label %s",
+ gettext("string annotation text\n"));
+ fprintf (stderr, " -bg %s",
+ gettext("color background color\n"));
+ fprintf (stderr, " -fg %s",
+ gettext("color graph color\n"));
+ fprintf (stderr, " -hl %s",
+ gettext("color scale and text color\n"));
+ fprintf (stderr, " -nolabel %s",
+ gettext("removes the label from above the chart.\n"));
+ fprintf (stderr, " -jumpscroll %s",
+ gettext("value number of pixels to scroll on overflow\n"));
+ fprintf (stderr, " -lights %s",
+ gettext("use keyboard leds to display current load\n"));
fprintf (stderr, "\n");
exit(1);
}
@@ -147,6 +173,9 @@ main(int argc, char **argv)
Arg args[1];
Pixmap icon_pixmap = None;
char *label, host[256];
+ char *domaindir;
+
+ XtSetLanguageProc ( NULL, NULL, NULL );
ProgramName = argv[0];
@@ -155,12 +184,12 @@ main(int argc, char **argv)
InitLoadPoint();
/* reset gid first while still (maybe) root */
if (setgid(getgid()) == -1) {
- fprintf(stderr, "%s: setgid failed: %s\n",
+ fprintf(stderr, gettext("%s: setgid failed: %s\n"),
ProgramName, strerror(errno));
exit(1);
}
if (setuid(getuid()) == -1) {
- fprintf(stderr, "%s: setuid failed: %s\n",
+ fprintf(stderr, gettext("%s: setuid failed: %s\n"),
ProgramName, strerror(errno));
exit(1);
}
@@ -169,6 +198,14 @@ main(int argc, char **argv)
toplevel = XtAppInitialize(&app_con, "XLoad", options, XtNumber(options),
&argc, argv, NULL, NULL, (Cardinal) 0);
+
+ textdomain("xload");
+
+ if ((domaindir = getenv ( "TEXTDOMAINDIR" )) == NULL) {
+ domaindir = "/usr/share/locale"; /*XLOCALEDIR;*/
+ }
+ bindtextdomain("xload", domaindir);
+
if (argc != 1) usage();
XtGetApplicationResources( toplevel, (XtPointer) &resources,