View Issue Details

IDProjectCategoryView StatusLast Update
0005261The Dark ModDesign/Codingpublic05.10.2021 03:21
Reporterstgatilov Assigned Tostgatilov  
Status resolvedResolutionfixed 
Product VersionTDM 2.08 
Target VersionTDM 2.10Fixed in VersionTDM 2.10 
Summary0005261: Extend localization system to understand string placeholders
DescriptionCurrently localized strings have format #str_02389, which is a big pain to work with.
When I see such string in debugger, I have no idea what it means.
Perhaps it's better to allow string keywords in localization system.
Of course, it means some performance loss due to dictionary search, but I think strings should not take too much time anyway.
Additional InformationSee discussion:
TagsNo tags attached.


related to 0003191 closedstgatilov Extend string template replacement 




23.05.2020 07:02

administrator   ~0012544

I suggest extending keywords to anything of format #str_lockpicking_difficulty
I.e. allow any string starting with five characters "#str_" and 1-50 alphanum characters (0-9a-zA-Z_) after that.


05.12.2020 11:36

administrator   ~0013097

Also probably review the generation script?...


11.12.2020 15:48

administrator   ~0013117

Actually, the game engine works perfectly well with something like "#str_frontend_parallel".
The perl script does not let it pass, which can be fixed pretty easily.
So... I have no idea why we are stuck with those unreadable numbers.

I found something like this on forums:
  Darkradiant currently does not support the dictionaries, so strings will look like "#str_07118" instead of the "OK".
Along with much shit regarding localization framework and process =(

Also I see the following test in all.lang:
   FM specific strings have the ID 20000 .. 89999 and are NOT to be
   stored in this file. Instead they go into "strings/fm/[language].lang".
So I guess there is some convention about ID ranges.
Obviously, similar convention must be made for arbitrary strings too.


12.12.2020 17:45

administrator   ~0013118

DarkRadiant does not do anything with these #str_ string, it just displays them "as is".
It does not care if placeholders is integer or string.

So I guess there is no reason to use numbers actually.
After 2.09 is over, I'll try to fix the script and use some strings for graphics menu.
Obviously, FM-specific strings should start with #str_fm_ to avoid accidental name conflicts.


18.04.2021 11:18

administrator   ~0013874

Committed the changes:

r9289. Use generic string hash in idLangDict::GetHashKey and don't assert if characters are not digits.
  The engine code seems to perfectly supports arbitrary string placeholders.
  Aside from this little hash function, which is suited to #str_ddddd arguments and asserts for digits.

r16230. Allow #str_{...} placeholders to have from 5 to 31 alphanumeric characters instead of just five digits.
  This is a fix in gen_lang script, since previously it only accepted 5 digits in placeholder.

r16231. Changed names of two recent strings to use string placeholders.
  This is done in order to test the new system.

Note that it is NOT a good idea to convert all names yet!
Better leave it as it is for some time, and see how it goes.

Issue History

Date Modified Username Field Change
23.05.2020 07:00 stgatilov New Issue
23.05.2020 07:01 stgatilov Description Updated
23.05.2020 07:02 stgatilov Note Added: 0012544
05.12.2020 11:36 stgatilov Note Added: 0013097
05.12.2020 11:36 stgatilov Target Version TDM 2.09 => TDM 2.10
11.12.2020 15:48 stgatilov Note Added: 0013117
12.12.2020 17:45 stgatilov Note Added: 0013118
18.02.2021 11:58 stgatilov Assigned To => stgatilov
18.02.2021 11:58 stgatilov Status new => assigned
18.04.2021 11:18 stgatilov Note Added: 0013874
18.04.2021 11:19 stgatilov Status assigned => resolved
18.04.2021 11:19 stgatilov Resolution open => fixed
18.04.2021 11:19 stgatilov Fixed in Version => TDM 2.10
05.10.2021 03:15 nbohr1more Relationship added has duplicate 0003191
05.10.2021 03:20 stgatilov Relationship deleted has duplicate 0003191
05.10.2021 03:21 stgatilov Relationship added related to 0003191