gettext.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef GETTEXT_HEADER
  17. #define GETTEXT_HEADER
  18. //#include "config.h" // for USE_GETTEXT
  19. #if USE_GETTEXT
  20. #include <libintl.h>
  21. #else
  22. #define gettext(String) String
  23. #endif
  24. #define _(String) gettext(String)
  25. #define gettext_noop(String) String
  26. #define N_(String) gettext_noop (String)
  27. #ifdef _MSC_VER
  28. void init_gettext(const char *path, const std::string &configured_language, int argc, char** argv);
  29. #else
  30. void init_gettext(const char *path, const std::string &configured_language);
  31. #endif
  32. extern const wchar_t *narrow_to_wide_c(const char *mbs);
  33. extern std::wstring narrow_to_wide(const std::string &mbs);
  34. // You must free the returned string!
  35. inline const wchar_t *wgettext(const char *str)
  36. {
  37. return narrow_to_wide_c(gettext(str));
  38. }
  39. inline std::wstring wstrgettext(const std::string &text)
  40. {
  41. return narrow_to_wide(gettext(text.c_str()));
  42. }
  43. inline std::string strgettext(const std::string &text)
  44. {
  45. return gettext(text.c_str());
  46. }
  47. #endif