Localized player classes

Moderator: GZDoom Developers

Post Reply
User avatar
Kostov
 
 
Posts: 2020
Joined: Thu Dec 26, 2013 3:26 pm
Location: Sweden
Contact:

Localized player classes

Post by Kostov »

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
Kotti
Posts: 86
Joined: Tue Dec 27, 2016 4:08 am

Re: Localized player classes

Post by Kotti »

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.
User avatar
Kostov
 
 
Posts: 2020
Joined: Thu Dec 26, 2013 3:26 pm
Location: Sweden
Contact:

Re: Localized player classes

Post by Kostov »

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.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Localized player classes

Post by _mental_ »

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.
User avatar
Kostov
 
 
Posts: 2020
Joined: Thu Dec 26, 2013 3:26 pm
Location: Sweden
Contact:

Re: Localized player classes

Post by Kostov »

So what would be the best solution for translating these? Making a new class?
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Localized player classes

Post by _mental_ »

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.
Kotti
Posts: 86
Joined: Tue Dec 27, 2016 4:08 am

Re: Localized player classes

Post by Kotti »

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:

Code: Select all

string name = player.displayname
string lookup = "TXT_PLAYERCLASSNAME_" + name
string translated = Localize(lookup)
if translated.length = 0 translated = name
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Localized player classes

Post by _mental_ »

Existing display names can contain spaces, lines without translation are “localized” to themselves but in general this should work.
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: Localized player classes

Post by Gez »

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.
User avatar
Kostov
 
 
Posts: 2020
Joined: Thu Dec 26, 2013 3:26 pm
Location: Sweden
Contact:

Re: Localized player classes

Post by Kostov »

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.
Exactly! Better to deal with this kind of thing ASAP.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”