aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/locales/xlatstr.h
blob: aca8dac1f8b3f6d56e15716c26e99003f08a8768 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef _XLATSTR_H
#define _XLATSTR_H

#include <api/locales/localesmgr.h>

/**
  Provides string translation for the string
  used as the constructor parameter.
  
  The constructor will automatically lookup
  the translated value of the string it receives
  in the currently loaded locale.

  @short Translates a string using the currently loaded locale.
  @author Nullsoft
  @ver 1.0
  @see ComponentAPI::locales_getTranslation()
*/

class _ {
  public:
  /**
	Automatically looks up the translated value of the string
	it receives as a parameter in the currently loaded
	locale. The same string is returned if there's no
	translation.

	@param str String to be translated.
	@ret Translation found, Translated string; Translation not found, Input string;
  */

#if defined(WASABI_COMPILE_LOCALES)
		_(const wchar_t *str) { s=LocalesManager::getTranslation(str); }
#else
	_(const wchar_t *str) { s=str; }
#endif
	operator const wchar_t *() const { return s; }

  private:
	const wchar_t *s;
};


class __ {
  public:
  /**
	Automatically looks up the translated value of the string
	it receives as a parameter in the currently loaded
	locale. The same string is returned if there's no
	translation.

	@param str String to be translated.
	@ret Translation found, Translated string; Translation not found, Input string;
  */

#if defined(WASABI_COMPILE_LOCALES)
		__(const wchar_t *str) { s=LocalesManager::lookupString(str); }
#else
	__(const wchar_t *str) { s=str; }
#endif
	operator const wchar_t *() const { return s; }

  private:
	const wchar_t *s;
};


#endif