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