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 // Avoid deprecation warnings from g++ 3.1 or newer. 9*946379e7Schristos #if defined __GNUG__ && defined __DEPRECATED 10*946379e7Schristos # include <iostream> 11*946379e7Schristos using namespace std; 12*946379e7Schristos #else 13*946379e7Schristos # include <iostream.h> 14*946379e7Schristos #endif 15*946379e7Schristos 16*946379e7Schristos // Get setlocale() declaration. 17*946379e7Schristos #include <locale.h> 18*946379e7Schristos 19*946379e7Schristos // Get getpid() declaration. 20*946379e7Schristos #if HAVE_UNISTD_H 21*946379e7Schristos # include <unistd.h> 22*946379e7Schristos #endif 23*946379e7Schristos 24*946379e7Schristos // Get gettext(), textdomain(), bindtextdomain() declaration. 25*946379e7Schristos #include "gettext.h" 26*946379e7Schristos // Define shortcut for gettext(). 27*946379e7Schristos #define _(string) gettext (string) 28*946379e7Schristos 29*946379e7Schristos // Get autosprintf class declaration. 30*946379e7Schristos #include "autosprintf.h" 31*946379e7Schristos using gnu::autosprintf; 32*946379e7Schristos 33*946379e7Schristos int main()34*946379e7Schristosmain () 35*946379e7Schristos { 36*946379e7Schristos setlocale (LC_ALL, ""); 37*946379e7Schristos textdomain ("hello-c++"); 38*946379e7Schristos bindtextdomain ("hello-c++", LOCALEDIR); 39*946379e7Schristos 40*946379e7Schristos cout << _("Hello, world!") << endl; 41*946379e7Schristos cout << autosprintf (_("This program is running as process number %d."), 42*946379e7Schristos getpid ()) 43*946379e7Schristos << endl; 44*946379e7Schristos } 45