Translations:Development/73/en

From DDraceNetwork
Revision as of 17:29, 4 May 2024 by FuzzyBot (talk | contribs) (Importing a new version from external source)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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");