Collections items don't have unique identifiers in LRT file
Original Reporter info from Mantis: cobines
-
Reporter name:
Original Reporter info from Mantis: cobines
- Reporter name:
Description:
If a control has collections as published properties then collections items do not have unique identifiers in LRT file, and so they cannot be properly localized.
For example Columns property of TStringGrid in LFM:
Columns = <
item
Title.Caption = 'First'
end
item
Title.Caption = 'Second'
end
item
Title.Caption = 'Third'
end>
In the generated LRT file each title has the same identifier (this is pre SVN 25431):
TFORM1.STRINGGRID1.COLUMNS.TITLE.CAPTION=First
TFORM1.STRINGGRID1.COLUMNS.TITLE.CAPTION=Second
TFORM1.STRINGGRID1.COLUMNS.TITLE.CAPTION=Third
This issue is a more general variant of issue #15180 (closed). There were two patches proposed there, the second one was applied to SVN in rev. 25431 which works fine for TStringGrid, but I don't think it is satisfactory in general case.
I have attached example which doesn't work (included run and design time package with custom control). The produced LRT must have a unique path for each value and it doesn't.
For example in LFM we have control with collection having two items:
object ExamCtrl1: TExamCtrl
Col1 = <
item
Title = 'Random value 210'
Inner.Title = 'Random value 827'
end
item
Title = 'Random value 827'
Inner.Title = 'Random value 1207'
end>
end
With SVN < 25431 the LRT is:
TFORM1.EXAMCTRL1.COL1.TITLE=Random value 210
TFORM1.EXAMCTRL1.COL1.INNER.TITLE=Random value 827
TFORM1.EXAMCTRL1.COL1.TITLE=Random value 827
TFORM1.EXAMCTRL1.COL1.INNER.TITLE=Random value 1207
With SVN >= 25431 the LRT is:
TFORM1.EXAMCTRL1.COL1[0].TITLE=Random value 210
TFORM1.TMYCOLLECTION[0].TITLE=Random value 827
TFORM1.EXAMCTRL1.COL1[1].TITLE=Random value 827
TFORM1.TMYCOLLECTION[0].TITLE=Random value 1207
Here, TMYCOLLECTION is outputted by GetNamePath, because the Inner collection has a collection item as an owner and the Inner collection is not available as a property from this collection item. Hence this not a good solution I think, because it needs TPersistent to be directly available as a property from its Owner.
Desired LRT would be something like this:
TFORM1.EXAMCTRL1.COL1[0].TITLE=Random value 210
TFORM1.EXAMCTRL1.COL1[0].INNER.TITLE=Random value 827
TFORM1.EXAMCTRL1.COL1[1].TITLE=Random value 827
TFORM1.EXAMCTRL1.COL1[1].INNER.TITLE=Random value 1207
or
TFORM1.EXAMCTRL1.COL1.ITEM0.TITLE=Random value 210
TFORM1.EXAMCTRL1.COL1.ITEM0.INNER.TITLE=Random value 827
TFORM1.EXAMCTRL1.COL1.ITEM1.TITLE=Random value 827
TFORM1.EXAMCTRL1.COL1.ITEM1.INNER.TITLE=Random value 1207
Each Item should produce a unique identifier.
With SVN < 25431 the code that writes LRT is using cached nodes names from LRS writer to create identifiers, but LRS writer does not number the collections items. The 'Title' and 'Inner.Title' are simply written one after another:
'TExamCtrl'#9
+'ExamCtrl1'#4'Left'#2#24#6'Height'#2'j'#3'Top'#2#16#5'Width'#3#184#0#4'Col1'
+#14#1#5'Title'#6#16'Random value 210'#11'Inner.Title'#6#16'Random value 827'
+#0#1#5'Title'#6#16'Random value 827'#11'Inner.Title'#6#17'Random value 1207'
+#0#0#4'Col2'#14#1#5'Title'#6#16'Random value 805'#11'Inner.Title'#6#16'Rando'
+'m value 822'#0#1#5'Title'#6#16'Random value 822'#11'Inner.Title'#6#16'Rando'
+'m value 569'#0#0#0#0
In LRT there must be a unique part inserted between 'Col1' and 'Title', and between 'Col1' and 'Inner Title'.
Mantis conversion info:
- Mantis ID: 16742
- OS: Debian
- OS Build: Sid
- Build: 26042
- Platform: Linux
- Version: 0.9.29 (SVN)
- Fixed in revision: 29201 (#3168fd2e)
- Target version: 0.9.30