soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
STranslator-i.h
1#ifndef __STRANSLATOR_I__H__
2#define __STRANSLATOR_I__H__
3
4#include <interface/obj-ref-i.h>
5#include <interface/sstring-i.h>
6
7SNSBEGIN
8
9enum
10{
11 TR_MAX_NAME_LEN = 64
12};
13
14/**
15 * @struct ITranslator
16 * @brief Language Translation Interface
17 *
18 * This interface defines the methods for language translation.
19 */
20#undef INTERFACE
21#define INTERFACE ITranslator
22DECLARE_INTERFACE_(ITranslator, IObjRef)
23{
24 /**
25 * @brief Increments the reference count.
26 * @return The new reference count.
27 */
28 STDMETHOD_(long, AddRef)(THIS) PURE;
29
30 /**
31 * @brief Decrements the reference count.
32 * @return The new reference count.
33 */
34 STDMETHOD_(long, Release)(THIS) PURE;
35
36 /**
37 * @brief Finalizes the release of the object.
38 * @return void
39 */
40 STDMETHOD_(void, OnFinalRelease)(THIS) PURE;
41
42 /**
43 * @brief Loads language translation data from a resource.
44 * @param pData Pointer to the resource data, interpretation depends on the implementation.
45 * @param uType Type of the resource, interpretation depends on the implementation.
46 * @return TRUE if loading is successful, FALSE otherwise.
47 */
48 STDMETHOD_(BOOL, Load)(THIS_ LPVOID pData, UINT uType) PURE;
49
50 /**
51 * @brief Retrieves the name of the translation resource.
52 * @param szBuf Buffer to receive the translation resource name.
53 * @return void
54 */
55 STDMETHOD_(void, GetName)(CTHIS_ wchar_t szBuf[TR_MAX_NAME_LEN]) SCONST PURE;
56
57 /**
58 * @brief Retrieves the name of the translation resource.
59 * @param str Pointer to the IStringA object to receive the translation resource name.
60 * @return void
61 */
62 STDMETHOD_(void, GetNameA)(CTHIS_ IStringA * str) SCONST PURE;
63
64 /**
65 * @brief Compares the translation resource name.
66 * @param pszName Translation resource name to compare.
67 * @return TRUE if the names are the same, FALSE otherwise.
68 */
69 STDMETHOD_(BOOL, NameEqual)(CTHIS_ LPCWSTR pszName) SCONST PURE;
70
71 /**
72 * @brief Compares the translation resource name.
73 * @param str Pointer to the IStringA object containing the translation resource name to compare.
74 * @return TRUE if the names are the same, FALSE otherwise.
75 */
76 STDMETHOD_(BOOL, NameEqualA)(CTHIS_ const IStringA *str) SCONST PURE;
77
78 /**
79 * @brief Retrieves the GUID of the translation resource.
80 * @return GUID of the translation resource.
81 */
82 STDMETHOD_(GUID, guid)(CTHIS) SCONST PURE;
83
84 /**
85 * @brief Translates a string.
86 * @param strSrc Pointer to the IStringW object containing the source string.
87 * @param strCtx Pointer to the IStringW object containing the translation context.
88 * @param pszOut Buffer to receive the translated string.
89 * @param nLen Length of the buffer.
90 * @return Length of the translated string, 0 if no translation, -1 if buffer size is not enough.
91 */
92 STDMETHOD_(int, tr)
93 (CTHIS_ const IStringW *strSrc, const IStringW *strCtx, wchar_t *pszOut, int nLen) SCONST PURE;
94
95 /**
96 * @brief Retrieves the default font information for translation.
97 * @param strFont Pointer to the IStringW object to receive the font information.
98 * @return void
99 */
100 STDMETHOD_(void, getFontInfo)(CTHIS_ IStringW * strFont) SCONST PURE;
101};
102
103/**
104 * @struct ITranslatorMgr
105 * @brief Language Translation Interface Manager
106 *
107 * This interface defines the methods for managing language translation interfaces.
108 */
109#undef INTERFACE
110#define INTERFACE ITranslatorMgr
111DECLARE_INTERFACE_(ITranslatorMgr, IObjRef)
112{
113 /**
114 * @brief Increments the reference count.
115 * @return The new reference count.
116 */
117 STDMETHOD_(long, AddRef)(THIS) PURE;
118
119 /**
120 * @brief Decrements the reference count.
121 * @return The new reference count.
122 */
123 STDMETHOD_(long, Release)(THIS) PURE;
124
125 /**
126 * @brief Finalizes the release of the object.
127 * @return void
128 */
129 STDMETHOD_(void, OnFinalRelease)(THIS) PURE;
130
131 /**
132 * @brief Checks if the manager is valid.
133 * @return TRUE if valid, FALSE otherwise.
134 */
135 STDMETHOD_(BOOL, IsValid)(CTHIS) SCONST PURE;
136
137 /**
138 * @brief Sets the current language for the translation module.
139 * @param pszLang Language to set.
140 * @return void
141 * @remark Automatically clears modules with different languages.
142 */
143 STDMETHOD_(void, SetLanguage)(THIS_ LPCWSTR pszLang) PURE;
144
145 /**
146 * @brief Sets the current language for the translation module.
147 * @param pszLang Language to set.
148 * @return void
149 * @remark Automatically clears modules with different languages.
150 */
151 STDMETHOD_(void, SetLanguageA)(THIS_ LPCSTR pszLang) PURE;
152
153 /**
154 * @brief Retrieves the current language for the translation module.
155 * @param szOut Buffer to receive the current language.
156 * @return void
157 */
158 STDMETHOD_(void, GetLanguage)(CTHIS_ wchar_t szOut[TR_MAX_NAME_LEN]) SCONST PURE;
159
160 /**
161 * @brief Retrieves the current language for the translation module.
162 * @param out Pointer to the IStringA object to receive the current language.
163 * @return void
164 */
165 STDMETHOD_(void, GetLanguageA)(CTHIS_ IStringA * out) SCONST PURE;
166
167 /**
168 * @brief Creates a language translation object.
169 * @param ppTranslator Pointer to receive the language translation object.
170 * @return TRUE if successful, FALSE otherwise.
171 */
172 STDMETHOD_(BOOL, CreateTranslator)(THIS_ ITranslator * *ppTranslator) PURE;
173
174 /**
175 * @brief Installs a language translation object into the manager.
176 * @param ppTranslator Language translation object to install.
177 * @return TRUE if successful, FALSE otherwise.
178 */
179 STDMETHOD_(BOOL, InstallTranslator)(THIS_ ITranslator * ppTranslator) PURE;
180
181 /**
182 * @brief Uninstalls a language translation object from the manager.
183 * @param id GUID of the language translation object to uninstall.
184 * @return TRUE if successful, FALSE otherwise.
185 */
186 STDMETHOD_(BOOL, UninstallTranslator)(THIS_ REFGUID id) PURE;
187
188 /**
189 * @brief Translates a string.
190 * @param strSrc Pointer to the IStringW object containing the source string.
191 * @param strCtx Pointer to the IStringW object containing the translation context.
192 * @param pszOut Buffer to receive the translated string.
193 * @param nLen Length of the buffer.
194 * @return Length of the translated string, 0 if no translation, -1 if buffer size is not enough.
195 */
196 STDMETHOD_(int, tr)
197 (CTHIS_ const IStringW *strSrc, const IStringW *strCtx, wchar_t *pszOut, int nLen) SCONST PURE;
198};
199
200SNSEND
201#endif // __STRANSLATOR_I__H__
Interface for reference counting.
Definition obj-ref-i.h:19
Language Translation Interface.
BOOL Load(LPVOID pData, UINT uType) PURE
Loads language translation data from a resource.
long AddRef() PURE
Increments the reference count.
GUID guid() SCONST PURE
Retrieves the GUID of the translation resource.
void GetName(wchar_t szBuf[TR_MAX_NAME_LEN]) SCONST PURE
Retrieves the name of the translation resource.
void getFontInfo(IStringW *strFont) SCONST PURE
Retrieves the default font information for translation.
long Release() PURE
Decrements the reference count.
int tr(const IStringW *strSrc, const IStringW *strCtx, wchar_t *pszOut, int nLen) SCONST PURE
Translates a string.
void GetNameA(IStringA *str) SCONST PURE
Retrieves the name of the translation resource.
void OnFinalRelease() PURE
Finalizes the release of the object.
BOOL NameEqual(LPCWSTR pszName) SCONST PURE
Compares the translation resource name.
BOOL NameEqualA(const IStringA *str) SCONST PURE
Compares the translation resource name.
Language Translation Interface Manager.
long Release() PURE
Decrements the reference count.
BOOL InstallTranslator(ITranslator *ppTranslator) PURE
Installs a language translation object into the manager.
BOOL IsValid() SCONST PURE
Checks if the manager is valid.
void GetLanguage(wchar_t szOut[TR_MAX_NAME_LEN]) SCONST PURE
Retrieves the current language for the translation module.
BOOL CreateTranslator(ITranslator **ppTranslator) PURE
Creates a language translation object.
void GetLanguageA(IStringA *out) SCONST PURE
Retrieves the current language for the translation module.
void OnFinalRelease() PURE
Finalizes the release of the object.
void SetLanguage(LPCWSTR pszLang) PURE
Sets the current language for the translation module.
int tr(const IStringW *strSrc, const IStringW *strCtx, wchar_t *pszOut, int nLen) SCONST PURE
Translates a string.
BOOL UninstallTranslator(REFGUID id) PURE
Uninstalls a language translation object from the manager.
void SetLanguageA(LPCSTR pszLang) PURE
Sets the current language for the translation module.
long AddRef() PURE
Increments the reference count.