1 // Copyright Vladimir Prus 2003. 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt 4 // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 7 #include <locale.h> 8 #include <libintl.h> 9 #define i18n(s) gettext(s) 10 11 #include <iostream> 12 using namespace std; 13 main()14int main() 15 { 16 // Specify that translations are stored in directory 17 // "messages". 18 bindtextdomain("main", "messages"); 19 textdomain("main"); 20 21 // Switch to russian locale. 22 setlocale(LC_MESSAGES, "ru_RU.KOI8-R"); 23 24 // Output localized message. 25 std::cout << i18n("hello") << "\n"; 26 27 return 0; 28 } 29