I am using Delphi 11 Alexandria and am building an FMX project for release on Windows, iOS, and Android.
I am building a manual language translation system, to this end I have generated a mapping document that maps language text to components mapped using the component name.
My customer has insisted that no auto translation technology should be used.
My code works fine for everything accept TComboBox
and TListItem
?
When I set the text value for the TListItem
on startup, it works. For instance, the design time values are in English, and if the save state determines the last used language was Deutschland then this function successfully changes the drop down text and header text of the TComboBox
(very odd).
However, when I change the language after startup to change all the text, it does not change the drop down text, but does change the header text value.
I.e. I initially load the text in English, the save state loads in English, and then I change to Deutschland.
When I change to Deutschland, the header text in the ComboBox says "Bereich" but the drop down value says "Area". This is true for all of the drop down values, only the header text changes and not the drop down values?
Please note: I have added the if
statement already if cmp is TListBoxItem then
for an easy place to position any additional code to make it work.
procedure setLangTextVal(cmp: TComponent; text: string);
var
Ctx: TRttiContext;
Prop: TRttiProperty;
begin
Prop := Ctx.GetType(cmp.ClassType).GetProperty('Text');
if (Prop <> nil) and (Prop.Visibility in [mvPublic, mvPublished]) then
begin
if cmp is TListBoxItem then
Prop.SetValue(cmp, text)
else
Prop.SetValue(cmp, text);
Exit;
end;
Prop := Ctx.GetType(cmp.ClassType).GetProperty('Caption');
if (Prop <> nil) and (Prop.Visibility in [mvPublic, mvPublished]) then
begin
Prop.SetValue(cmp, text);
Exit;
end;
end;