diff options
author | Jay Hobson <jay.hobson@sun.com> | 2000-08-04 10:36:37 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2010-01-29 22:38:51 -0800 |
commit | b83ec6e3a79e30b8a7a3947679221ad76441b27f (patch) | |
tree | d6ea110d48df3ef8e702bc370a3c5b9bce6720a7 /xfd.c | |
parent | cf8659cf40ed338c00bde2b4248bc6e9f8766248 (diff) |
Internationalize xfd: Call gettext on strings printed to stderr
Originally done for Solaris 9 to fix Sun bug 4348474
http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=4348474
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Diffstat (limited to 'xfd.c')
-rw-r--r-- | xfd.c | 64 |
1 files changed, 45 insertions, 19 deletions
@@ -40,6 +40,8 @@ in this Software without prior written authorization from The Open Group. #include <X11/Xaw/Command.h> #include <stdio.h> #include <stdlib.h> +#include <libintl.h> +#include <locale.h> #include "grid.h" #ifdef XRENDER #include <X11/Xft/Xft.h> @@ -127,26 +129,31 @@ static XtResource Resources[] = { static void usage(void) { - fprintf (stderr, "usage: %s [-options ...] -fn font\n", ProgramName); + fprintf (stderr, gettext("usage: %s [-options ...] "), ProgramName); + fprintf (stderr, "-fn "); + fprintf (stderr, gettext("font\n\n")); #ifdef XRENDER - fprintf (stderr, " %s [-options ...] -fa font\n", ProgramName); + fprintf (stderr, gettext(" %s [-options ...] "), ProgramName); + fprintf (stderr, "-fa "); + fprintf (stderr, gettext("font\n\n")); #endif - fprintf (stderr, "where options include:\n"); - fprintf (stderr, - " -display dpy X server to contact\n"); - fprintf (stderr, - " -geometry geom size and location of window\n"); - fprintf (stderr, - " -start num first character to show\n"); - fprintf (stderr, - " -box show a box around each character\n"); - fprintf (stderr, - " -center center each character inside its grid\n"); - fprintf (stderr, - " -rows number number of rows in grid\n"); - fprintf (stderr, - " -columns number number of columns in grid\n"); - fprintf (stderr, "\n"); + fprintf (stderr, gettext("where options include:\n")); + fprintf (stderr, " -display "); + fprintf (stderr, gettext("display X server to contact\n")); + fprintf (stderr, " -geometry "); + fprintf (stderr, gettext("geometry size and location of window\n")); + fprintf (stderr, " -bc "); + fprintf (stderr, gettext("color color for ImageText boxes\n")); + fprintf (stderr, " -start "); + fprintf (stderr, gettext("number first character to show\n")); + fprintf (stderr, " -box "); + fprintf (stderr, gettext("show a box around each character\n")); + fprintf (stderr, " -center "); + fprintf (stderr, gettext("center each character inside its grid\n")); + fprintf (stderr, " -rows "); + fprintf (stderr, gettext("number number of rows in grid\n")); + fprintf (stderr, " -columns "); + fprintf (stderr, gettext("number number of columns in grid\n")); exit (1); } @@ -170,13 +177,31 @@ main(int argc, char *argv[]) XftFont *xft; #endif char *fontname; + char *domaindir; long minn, maxn; + XtSetLanguageProc(NULL, NULL, NULL); + ProgramName = argv[0]; toplevel = XtAppInitialize (&xtcontext, "Xfd", xfd_options, XtNumber(xfd_options), &argc, argv, NULL, NULL, 0); + + textdomain("xfd"); + + /* mainly for debugging */ + if ((domaindir = getenv ("TEXTDOMAINDIR")) == NULL) { + domaindir = "/usr/share/locale"; + } + bindtextdomain ("xfd", domaindir); + + Resources[0].default_addr = gettext(DEF_SELECT_FORMAT); + Resources[1].default_addr = gettext(DEF_METRICS_FORMAT); + Resources[2].default_addr = gettext(DEF_RANGE_FORMAT); + Resources[3].default_addr = gettext(DEF_START_FORMAT); + Resources[4].default_addr = gettext(DEF_NOCHAR_FORMAT); + if (argc != 1) usage (); XtAppAddActions (xtcontext, xfd_actions, XtNumber (xfd_actions)); XtOverrideTranslations @@ -271,10 +296,11 @@ main(int argc, char *argv[]) XtSetArg (av[i], XtNfont, &fs); i++; XtGetValues (fontGrid, av, i); if (!fs || fontConversionFailed) { - fprintf (stderr, "%s: no font to display\n", ProgramName); + fprintf (stderr, gettext("%s: no font to display\n"), ProgramName); exit (1); } fontname = get_font_name (XtDisplay(toplevel), fs); + if (!fontname) fontname = gettext("unknown font!"); } i = 0; XtSetArg (av[i], XtNlabel, fontname); i++; |