Translations:Development/73/en: Difference between revisions
Importing a new version from external source |
Importing a new version from external source |
||
Line 1: | Line 1: | ||
=== Translating text in the client === | ===Translating text in the client=== | ||
<code>Localize</code> can be used in the game client to get the translation for a specific string from the language file selected by the user.<syntaxhighlight lang="cpp"> | <code>Localize</code> can be used in the game client to get the translation for a specific string from the language file selected by the user.<syntaxhighlight lang="cpp"> | ||
DoButton(..., Localize("Connect"), ...); | DoButton(..., Localize("Connect"), ...); |
Latest revision as of 17:29, 4 May 2024
Translating text in the client
Localize
can be used in the game client to get the translation for a specific string from the language file selected by the user.
DoButton(..., Localize("Connect"), ...);
The string can also contain format specifiers. The translated string must contain the same format specifiers.
char aBuf[128];
str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers"), NumServers, TotalServers);
A script is used to scan the code for calls to Localize
and collect the strings to update the translation files. For this reason, the call to Localize
must not contain any other code, or the script cannot determine the text correctly.<syntaxhighlight lang="cpp">
// Do NOT do this: const char *pStr = Localize(Team == TEAM_RED ? "Red team" : "Blue team");