1*63eb84d1Schristos // Example for use of GNU gettext. 2*63eb84d1Schristos // Copyright (C) 2003 Free Software Foundation, Inc. 3*63eb84d1Schristos // This file is in the public domain. 4*63eb84d1Schristos 5*63eb84d1Schristos // Source code of the C++ program. 6*63eb84d1Schristos 7*63eb84d1Schristos 8*63eb84d1Schristos // Avoid deprecation warnings from g++ 3.1 or newer. 9*63eb84d1Schristos #if defined __GNUG__ && defined __DEPRECATED 10*63eb84d1Schristos # include <iostream> 11*63eb84d1Schristos using namespace std; 12*63eb84d1Schristos #else 13*63eb84d1Schristos # include <iostream.h> 14*63eb84d1Schristos #endif 15*63eb84d1Schristos 16*63eb84d1Schristos // Get setlocale() declaration. 17*63eb84d1Schristos #include <locale.h> 18*63eb84d1Schristos 19*63eb84d1Schristos // Get getpid() declaration. 20*63eb84d1Schristos #if HAVE_UNISTD_H 21*63eb84d1Schristos # include <unistd.h> 22*63eb84d1Schristos #endif 23*63eb84d1Schristos 24*63eb84d1Schristos // Get gettext(), textdomain(), bindtextdomain() declaration. 25*63eb84d1Schristos #include "gettext.h" 26*63eb84d1Schristos // Define shortcut for gettext(). 27*63eb84d1Schristos #define _(string) gettext (string) 28*63eb84d1Schristos 29*63eb84d1Schristos // Get autosprintf class declaration. 30*63eb84d1Schristos #include "autosprintf.h" 31*63eb84d1Schristos using gnu::autosprintf; 32*63eb84d1Schristos 33*63eb84d1Schristos int main()34*63eb84d1Schristosmain () 35*63eb84d1Schristos { 36*63eb84d1Schristos setlocale (LC_ALL, ""); 37*63eb84d1Schristos textdomain ("hello-c++"); 38*63eb84d1Schristos bindtextdomain ("hello-c++", LOCALEDIR); 39*63eb84d1Schristos 40*63eb84d1Schristos cout << _("Hello, world!") << endl; 41*63eb84d1Schristos cout << autosprintf (_("This program is running as process number %d."), 42*63eb84d1Schristos getpid ()) 43*63eb84d1Schristos << endl; 44*63eb84d1Schristos } 45