OZ8HP
OZ8HP

Reputation: 1513

Localizing DevExpress

Here in Denmark I am working on creating an app using DevExpress. But I need to localize the DevExpress controls to speak Danish. But before I go to work and do the translation my self, I was wondering if someone already have done it. I am using the cxLocalizerEditor to create the .ini file with the translation.

Does a Danish translation already exist?

Anyone got the localizing of Custom Resource Strings to work? I can't get it to work.

The example from the help is like following. But I can't get that to work at all. uses 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;

But what I can get to work is: (cxLanguage is the unit I created with custom resourcestrings using the Localizer UI and @sHpDbSettingsCaption is just a random resourcestring)

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.

Upvotes: 1

Views: 6263

Answers (3)

Rayan Albouni
Rayan Albouni

Reputation: 179

1- create localizer classfor each control

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- call the class from the form containing the grid:

GridLocalizer.Active = new cls_GridLocalizer();

3- Enjoy

this is arabic grid

Upvotes: -1

Ravaut123
Ravaut123

Reputation: 2808

I did't use the cxLocalizerEditor but for ResourceString I made a constant unit to translate with cxSetResourceString and it works.

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.

Upvotes: 4

shamp00
shamp00

Reputation: 11326

VCL localizations exist for Dutch, German and Italian here. I don't know of anything available in Danish.

Regarding the localization of Custom Resource Strings, you have not been clear enough about your exact problem, but there are several related issues in the support center:

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

TcxLocalizer - Add the capability to create multiple custom products

If none of those help, I suggest you open a new question on the DevExpress support forums.

Upvotes: 3

Related Questions