rtti多国语言

 

procedure TBaseForm.SetControlCaptions(Container: TWinControl);
var
  I: Integer;
  sCaption, sNewCaption, sLanguage: string;
  T: TRttiType;
  P: TRttiProperty;
begin
  if AppConfig.Language = lgOrigal then
    Exit;
  T := TRttiContext.Create.GetType(Container.ClassInfo);
  P := T.GetProperty('Caption');
  if P <> nil then
  begin
    sCaption := P.GetValue(Container).ToString;
    if (sCaption > '') and (sCaption < 'zzz') then
    begin
      sNewCaption := AppClient.GetDisplayText(ModuleId, sCaption);
      if sCaption <> sNewCaption then
        P.SetValue(Container, sNewCaption);
    end;
    FreeAndNil(P);
  end;
  if ((csAcceptsControls in Container.ControlStyle)
    or (csPannable in Container.ControlStyle)) then
  begin
    P := T.GetProperty('ControlCount');
    FreeAndNil(T);

    if P <> nil then
    begin
      FreeAndNil(P);
      for I := 0 to Container.ControlCount - 1 do
         SetControlCaptions(TWinControl(Container.Controls[I]));
    end;
  end
  else
    FreeAndNil(T);
end;

原文地址:https://www.cnblogs.com/hnxxcxg/p/2940579.html