Localized player classes
Moderator: GZDoom Developers
Localized player classes
Redoing this because my last pull request was a mess. Sorry about that.
This moves all default player class names and color options to language.enu so that they can be translated to other languages.
https://github.com/coelckers/gzdoom/pull/396
This moves all default player class names and color options to language.enu so that they can be translated to other languages.
https://github.com/coelckers/gzdoom/pull/396
Re: Localized player classes
Assuming I understand it correctly these texts cannot be localized. At least the color names can be used as identifiers in strings (See rh-log.txt for August 30, 2006) and I remember that some time ago it was also mentioned that the player classes' display name is actually more than a display name and in some places being used as a selector for picking a class. So if you replace those by stringtable placeholders any old mod using them would break.
Re: Localized player classes
I believe that's correct, as I had to modify a file related to Hexen that determines difficulty names depending on which class you pick. It seems to be the only file in GZDoom that uses such a function, though.
Anyway, the display name should probably be just that: a display name. It seems like it'd be better if anything that has to refer to the class should use the actual class actor name, for example DoomPlayer.
Anyway, the display name should probably be just that: a display name. It seems like it'd be better if anything that has to refer to the class should use the actual class actor name, for example DoomPlayer.
Re: Localized player classes
There is no place in source code where DisplayName is treated as localized string. I.e., instead of "Marine" in case of Doom games "$DOOMPLAYER_DSPLYNAME" will be used.
At the same time DisplayName is exposed to ZScript, it affects saved games, skins, KEYCONF lump, menus. Your changes handle only the latter.
I see no way to fix all these retroactively. To be honest this PR can bring more problems than it tries to solve.
At the same time DisplayName is exposed to ZScript, it affects saved games, skins, KEYCONF lump, menus. Your changes handle only the latter.
I see no way to fix all these retroactively. To be honest this PR can bring more problems than it tries to solve.
Re: Localized player classes
So what would be the best solution for translating these? Making a new class?
Re: Localized player classes
The best solution is do not touch display names.
If you desperately want to do a translation then potentially working solution is to handle localized display names separately.
There should be new member variable that unlike existing one is used only to represent player class in UI.
If you desperately want to do a translation then potentially working solution is to handle localized display names separately.
There should be new member variable that unlike existing one is used only to represent player class in UI.
Re: Localized player classes
Without adding a new field, an option would be to synthesize a string label from the actual display name, look that up and if present use that version for printing. The same could be applied to colors as well.
As pseudocode:
As pseudocode:
Code: Select all
string name = player.displayname
string lookup = "TXT_PLAYERCLASSNAME_" + name
string translated = Localize(lookup)
if translated.length = 0 translated = name
Re: Localized player classes
Existing display names can contain spaces, lines without translation are “localized” to themselves but in general this should work.
Re: Localized player classes
Using "displayname" as an internal name is one of these shortsighted things that bit ZDoom in the butt.
If it were possible to deprecate that kludge and use a real internal class name with localizable title, it would be so much better.
Honestly, ZScript seems to be the perfect opportunity for that. You can introduce new properties as needed and only keep the displayname as a fallback for backward compatibility.
If it were possible to deprecate that kludge and use a real internal class name with localizable title, it would be so much better.
Honestly, ZScript seems to be the perfect opportunity for that. You can introduce new properties as needed and only keep the displayname as a fallback for backward compatibility.
Re: Localized player classes
Exactly! Better to deal with this kind of thing ASAP.Gez wrote:Using "displayname" as an internal name is one of these shortsighted things that bit ZDoom in the butt.
If it were possible to deprecate that kludge and use a real internal class name with localizable title, it would be so much better.
Honestly, ZScript seems to be the perfect opportunity for that. You can introduce new properties as needed and only keep the displayname as a fallback for backward compatibility.