main.cpp 622 B

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