1
0

xlatstr.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef _XLATSTR_H
  2. #define _XLATSTR_H
  3. #include <api/locales/localesmgr.h>
  4. /**
  5. Provides string translation for the string
  6. used as the constructor parameter.
  7. The constructor will automatically lookup
  8. the translated value of the string it receives
  9. in the currently loaded locale.
  10. @short Translates a string using the currently loaded locale.
  11. @author Nullsoft
  12. @ver 1.0
  13. @see ComponentAPI::locales_getTranslation()
  14. */
  15. class _ {
  16. public:
  17. /**
  18. Automatically looks up the translated value of the string
  19. it receives as a parameter in the currently loaded
  20. locale. The same string is returned if there's no
  21. translation.
  22. @param str String to be translated.
  23. @ret Translation found, Translated string; Translation not found, Input string;
  24. */
  25. #if defined(WASABI_COMPILE_LOCALES)
  26. _(const wchar_t *str) { s=LocalesManager::getTranslation(str); }
  27. #else
  28. _(const wchar_t *str) { s=str; }
  29. #endif
  30. operator const wchar_t *() const { return s; }
  31. private:
  32. const wchar_t *s;
  33. };
  34. class __ {
  35. public:
  36. /**
  37. Automatically looks up the translated value of the string
  38. it receives as a parameter in the currently loaded
  39. locale. The same string is returned if there's no
  40. translation.
  41. @param str String to be translated.
  42. @ret Translation found, Translated string; Translation not found, Input string;
  43. */
  44. #if defined(WASABI_COMPILE_LOCALES)
  45. __(const wchar_t *str) { s=LocalesManager::lookupString(str); }
  46. #else
  47. __(const wchar_t *str) { s=str; }
  48. #endif
  49. operator const wchar_t *() const { return s; }
  50. private:
  51. const wchar_t *s;
  52. };
  53. #endif