Imported Upstream version 2.6.0
[debian/amanda] / common-src / token.c
index 5dd8569a9a6206ed378de578317a72fd7c2b9680..6489da3581e7d375601912a35d901c7bcc2ebb1b 100644 (file)
@@ -135,7 +135,7 @@ printf_arglist_function(char *squotef, char *, format)
        /* Format the token */
 
        arglist_start(argp, format);
-       vsnprintf(linebuf, SIZEOF(linebuf), format, argp);
+       g_vsnprintf(linebuf, SIZEOF(linebuf), format, argp);
        arglist_end(argp);
 
        return quote(" ", linebuf);
@@ -149,7 +149,7 @@ printf_arglist_function1(char *quotef, char *, sep, char *, format)
        /* Format the token */
 
        arglist_start(argp, format);
-       vsnprintf(linebuf, SIZEOF(linebuf), format, argp);
+       g_vsnprintf(linebuf, SIZEOF(linebuf), format, argp);
        arglist_end(argp);
 
        return quote(sep, linebuf);
@@ -415,8 +415,19 @@ main(
        char *sr;
        int i;
 
+       /*
+        * Configure program for internationalization:
+        *   1) Only set the message locale for now.
+        *   2) Set textdomain for all amanda related programs to "amanda"
+        *      We don't want to be forced to support dozens of message catalogs
+        */  
+       setlocale(LC_MESSAGES, "C");
+       textdomain("amanda"); 
+
        safe_fd(-1, 0);
 
+       setlocale(LC_ALL, "C");
+
        /* shut up compiler */
        argc = argc;
        argv = argv;
@@ -430,36 +441,38 @@ main(
 
        erroutput_type = ERR_INTERACTIVE;
 
-       printf("Testing split() with \" \" token separator\n");
+       g_printf(_("Testing split() with \" \" token separator\n"));
        while(1) {
-               printf("Input string: ");
+               g_printf(_("Input string: "));
                amfree(str);
                if ((str = agets(stdin)) == NULL) {
-                       printf("\n");
+                       g_printf("\n");
                        break;
                }
                r = split(str, t, 20, " ");
-               printf("%d token%s:\n", r, (r == 1) ? "" : "s");
-               for (i=0; i <= r; i++) printf("tok[%d] = \"%s\"\n", i, t[i]);
+               g_printf(plural(_("%d token:\n"), _("%d token:\n"), r), r);
+               for (i=0; i <= r; i++)
+                       g_printf("tok[%d] = \"%s\"\n", i, t[i]);
        }
        amfree(str);
-       printf("\n");
+       g_printf("\n");
 
-       printf("Testing quote()\n");
+       g_printf(_("Testing quote()\n"));
        while(1) {
-               printf("Input string: ");
+               g_printf(_("Input string: "));
                amfree(str);
                if ((str = agets(stdin)) == NULL) {
-                       printf("\n");
+                       g_printf("\n");
                        break;
                }
                sr = squote(str);
-               printf("Quoted   = \"%s\"\n", sr);
+               g_printf(_("Quoted   = \"%s\"\n"), sr);
                strncpy(str,sr,SIZEOF(str)-1);
                str[SIZEOF(str)-1] = '\0';
                r = split(str, t, 20, " ");
-               if (r != 1) printf("split()=%d!\n", r);
-               printf("Unquoted = \"%s\"\n", t[1]);
+               if (r != 1)
+                       g_printf("split()=%d!\n", r);
+               g_printf(_("Unquoted = \"%s\"\n"), t[1]);
                amfree(sr);
        }
        amfree(str);