Berserker
Posts: 16657
|
RoseKavalier, brilliant work!
I recomment to use only translation keys in json in English.
{
"caption": "have a nive day"
}
All other translations can be released by enthusiasts as standalone mods and they will virtually overwrite your file.
Or create Lang directory in your mod with *.json,
{ "ebq": { all key value pairs }
}
And use
Code:
typedef char* (__stdcall *TTr) (const char* key, const char** params, int highParams);
TTr _tr = NULL;
/**
* Returns translation for given complex key ('xxx.yyy.zzz') with substituted parameters.
* Pass vector of (parameter name, parameter value) pairs to substiture named parameters.
* Example: Mod\Lang\*.json file: { "eqs": { "greeting": "Hello, @name@" } }
* Example: ShowMessage(tr("eqs.greeting", { "name", "igrik" }).c_str());
*
* @param key Key to get translation for.
* @param params Vector of (parameter name, parameter value pairs).
* @return Translation string.
*/
std::string tr (const char *key, const std::vector<std::string> params = {}) {
const int MAX_PARAMS = 64;
const char* _params[MAX_PARAMS];
int numParams = params.size() <= MAX_PARAMS ? params.size() : MAX_PARAMS;
for (int i = 0; i < numParams; i++) {
_params[i] = params[i].c_str();
}
char* buf = _tr(key, _params, numParams - 1);
MemFree(buf);
return buf;
}
hEra = LoadLibrary("era.dll");
_tr = (TTr) GetProcAddress(hEra, "tr");
Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
|
|
16.06.2020 13:47 |
|