Engine: Localization DEF token should use abstract, unique keys as first input, instead of exact English strings
This is a problem of how the strings are currently defined within the engine, and would require a far-reaching refactoring to clean up.
It is a minor issue and shouldn't cause any problems right now, but the potential for trouble exists.
Namely, strings visible to the player are currently inlined directly inside the source code, like such:
source/duke3d/src/menus.cpp:435:static MenuEntry_t ME_GAMESETUP_SAVESETUP = MAKE_MENUENTRY( "Save setup", &MF_Redfont, &MEF_BigOptionsRt, &MEO_GAMESETUP_SAVESETUP, Link );
source/duke3d/src/menus.cpp:1526:static MenuMenu_t M_SAVESETUP = MAKE_MENUMENU( "Save Setup", &MMF_BigOptions, MEL_SAVESETUP );
This is an example of an ambiguous string that may cause problems when translated.
In the location where this string is used, "Save Setup" refers to the menu where the settings for savegames can be set up.
However, assume we have another menu, where the final entry of a range of gameplay settings that reads "Save Setup", where selecting it applies the selected settings.
In this case, the string carries the meaning of "Save the selected setup" but holds the exact same characters.
Now assume an outside observer wants to translate this string to German. He will define the following DEF code:
localization "de"
{
str "Save Setup" "Einstellungen Speichern"
}
The problem is that in German, the two meanings cannot be expressed using the same string. If you wish to translate the "Save Setup" menu, you would write something akin to "Speicher-Einstellungen". But if you wish to translate "save current setup", you would write "Einstellungen Speichern" as above. No matter the quality of the translation, you would not be able to translate both instances of the string appropriately.
There are of course other problems:
- Each time the English string is changed in the source code, translations for that string no longer apply.
- There is code duplication that could be simplified if the same string is required in different locations, as is the case in the first grep result.
To fix this, the strings inside the code should be replaced by a string representing a unique key (preferably with a leading character like "__") that is used in combination with an external mapping, which assigns each unique key to the actual visible string to be seen by the player. This would then be loaded into the localization system, and used for the "en" locale.