Translations:Development/73/en

From DDraceNetwork

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