本地化DevExpress

时间:2012-03-28 07:54:21

标签: delphi localization devexpress

在丹麦,我正致力于使用DevExpress创建应用程序。 但我需要将DevExpress控件本地化以说丹麦语。但在我上班和自己翻译之前,我想知道是否有人已经完成了。 我正在使用cxLocalizerEditor创建带有翻译的.ini文件。

丹麦语翻译是否已存在?

任何人都有自定义资源字符串的本地化工作?我无法让它发挥作用。

  • 编辑帖子以添加我稍后讨论的示例代码。

帮助中的示例如下所示。但我根本无法工作。     使用       cxLocalization,dxCore,cxClasses ,;

type
  TForm1 = class(TForm, IdxLocalizerListener)
  cxLocalizer1: TcxLocalizer;
  constructor Create(AOwner: TComponent); override;
  destructor Destroy; override;
// ...
  public
    procedure TranslationChanged;
  end;
// ...

procedure TForm1.Create(AOwner: TComponent);
begin
  dxResourceStringsRepository.AddListener(Self);
  inherited Create(AOwner);
end;

procedure TForm1.Destroy;
begin
  dxResourceStringsRepository.RemoveListener(Self);
  inherited;
end;

procedure TForm1.TranslationChanged;
begin
  Caption := cxGetResourceString(@sAppName);
  // ...
end;

但我可以开始工作的是:(cxLanguage是我使用Localizer UI创建的自定义资源串的单位,而@sHpDbSettingsCaption只是一个随机资源字符串)

unit Unit1;

interface

uses
  cxLocalization, dxCore, cxClasses, cxLanguage,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm, IdxLocalizerListener)
  procedure FormShow(Sender: TObject);
  private
  public
    procedure TranslationChanged;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
  TranslationChanged;
end;

procedure TForm1.TranslationChanged;
begin
  Caption := cxGetResourceString(@sHpDbSettingsCaption);
end;


end.

3 个答案:

答案 0 :(得分:3)

我没有使用cxLocalizerEditor但是对于ResourceString,我使用cxSetResourceString创建了一个常量单位,并且它可以工作。

unit craDevExpressConsts;

interface

uses
  Classes,
  cxClasses,
  sysutils;

//GetDevExpressResourceString changed in ChangeResourceStrings
procedure ChangeResourceStrings;    
 implementation

uses
  cxFilterConsts,
  cxFilterControlStrs,
  cxEditConsts,
  cxGridStrs;

procedure ChangeResourceStrings;      
begin
  //================================
  // cxFilterControlStrs
  //================================
  // cxFilterBoolOperator
  cxSetResourceString(@cxSFilterBoolOperatorAnd, 'EN');
  cxSetResourceString(@cxSFilterBoolOperatorOr, 'OF');
  cxSetResourceString(@cxSFilterBoolOperatorNotAnd, 'NIET EN'); // not all
  cxSetResourceString(@cxSFilterBoolOperatorNotOr, 'NIET OF'); // not any
  cxSetResourceString(@cxSFilterFooterAddCondition, 'Selectie Toevoegen');


  //================================
  // cxEditConsts
  //================================
  // Invalid input value. Use escape key to abandon changes.
  cxSetResourceString(@cxSEditValidateErrorText, 'Ongeldige invoer waarde. Gebruik escape toets om wijzigingen te annuleren.');

  // Date
  cxSetResourceString(@cxSDatePopupClear, 'Ledigen'); // Clear
  cxSetResourceString(@cxSDatePopupNow, 'Nu'); // Now
  cxSetResourceString(@cxSDatePopupOK, 'Ok'); // OK
  cxSetResourceString(@cxSDatePopupToday, 'Vandaag'); // Today
  cxSetResourceString(@cxSDateError, 'Ongeldige Datum'); // Invalid Date

  ...

 end;

end.

答案 1 :(得分:3)

荷兰语,德语和意大利语here存在VCL本地化。我不知道丹麦语中有什么可用。

关于自定义资源字符串的本地化,您对确切的问题还不够清楚,但支持中心有几个相关问题:

cxLocalizerEditor - Make created custom resource units compilable with the {$TYPEDADDRESS ON} compiler directive

TcxLocalizer - Add the capability to create multiple custom products

如果这些都没有帮助,我建议您在DevExpress支持论坛上打开一个新问题。

答案 2 :(得分:0)

1-为每个控件创建本地化程序类

using DevExpress.XtraGrid.Localization;


 using System;    
    using System.Collections.Generic;
    using System.Linq;

    class cls_GridLocalizer : GridLocalizer
        {
 public override string Language { get { return "Arabic"; } }
        public override string GetLocalizedString(GridStringId id)
        {
            string ret = "";
            switch (id)
            {
                case GridStringId.MenuColumnSortAscending: return "فرز تصاعدي";
                case GridStringId.MenuColumnSortDescending: return "فرز تنازلي";
                case GridStringId.MenuColumnClearSorting: return "الغاء 

الفرز";
                    case GridStringId.MenuColumnGroup: return "تجميع حسب هذا العمود";
.
.
.
.
  default:
                    ret = base.GetLocalizedString(id);

                    break;
            }
            return ret;
        }
    }
}

2-从包含网格的表单中调用该类:

GridLocalizer.Active = new cls_GridLocalizer();

3-享受

this is arabic grid