xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/examples/hello-c/hello.c (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1*946379e7Schristos /* Example for use of GNU gettext.
2*946379e7Schristos    Copyright (C) 2003 Free Software Foundation, Inc.
3*946379e7Schristos    This file is in the public domain.
4*946379e7Schristos 
5*946379e7Schristos    Source code of the C program.  */
6*946379e7Schristos 
7*946379e7Schristos 
8*946379e7Schristos /* Get setlocale() declaration.  */
9*946379e7Schristos #include <locale.h>
10*946379e7Schristos 
11*946379e7Schristos /* Get printf() declaration.  */
12*946379e7Schristos #include <stdio.h>
13*946379e7Schristos 
14*946379e7Schristos /* Get getpid() declaration.  */
15*946379e7Schristos #if HAVE_UNISTD_H
16*946379e7Schristos # include <unistd.h>
17*946379e7Schristos #endif
18*946379e7Schristos 
19*946379e7Schristos /* Get gettext(), textdomain(), bindtextdomain() declaration.  */
20*946379e7Schristos #include "gettext.h"
21*946379e7Schristos /* Define shortcut for gettext().  */
22*946379e7Schristos #define _(string) gettext (string)
23*946379e7Schristos 
24*946379e7Schristos int
main()25*946379e7Schristos main ()
26*946379e7Schristos {
27*946379e7Schristos   setlocale (LC_ALL, "");
28*946379e7Schristos   textdomain ("hello-c");
29*946379e7Schristos   bindtextdomain ("hello-c", LOCALEDIR);
30*946379e7Schristos 
31*946379e7Schristos   printf ("%s\n", _("Hello, world!"));
32*946379e7Schristos   printf (_("This program is running as process number %d."), getpid ());
33*946379e7Schristos   putchar ('\n');
34*946379e7Schristos 
35*946379e7Schristos   return 0;
36*946379e7Schristos }
37