-1

As i mentioned in the title how can i translate filter buttons text to other language ? enter image description here

Umut Palabiyik
  • 313
  • 6
  • 16

1 Answers1

1

You can achieve this using localization, to do so you need to import:

import 'devextreme-intl';
import { locale } from "devextreme/localization";

and then add the below line in your AppComponent:

export class AppComponent {
    constructor() {
        locale(navigator.language || 'en'); // Set "en" as our default locale. OR set the appropriate value to whichever language you wish to translate to
    }
}

OR

You could also achieve the same with the Globalize package. Activating Globalize in your project requires the following files:

  1. Globalize library
  2. CLDR library
  3. CLDR JSON files for each required language.

You can find the Globalize and CLDR libraries on your local machine in the DevExtreme installation folder's or ZIP archive's Lib\js directory.

Install the cldr-data and globalize packages:

npm install --save-dev cldr-data globalize

Globalize internationalization and localization library leverages the official Unicode CLDR JSON data. The library works both for the browser and as a Node.js module. It provides number formatting and parsing, date and time formatting and parsing, currency formatting, and message formatting. To achieve localization with the help globalize library you need to take the below steps:

import Globalize from 'globalize'; 

and then add the below line in your AppComponent:

export class AppComponent {
    constructor() {
        Globalize.locale(navigator.language || 'en'); // Set "en" as our default locale. OR set the appropriate value to whichever language you wish to translate to
    }
}
kavigun
  • 2,219
  • 2
  • 14
  • 33
  • Actually i translated some text with that : `loadMessages({ en: { 'dxList-selectAll': 'Select All', }, tr: { 'dxList-selectAll': 'Hepsini Seç', } }) locale(navigator.language);` but i don't know which property to should use to translate "OK" and "Cancel" buttons. – Umut Palabiyik Sep 14 '22 at 18:06
  • For OK use: `dxDataGrid-headerFilterOK` and for Cancel use: `dxDataGrid-headerFilterCancel` – kavigun Sep 14 '22 at 18:15
  • Thank you so much. Lastly how do you get name of props to be translated ? – Umut Palabiyik Sep 14 '22 at 18:21
  • You are welcome :) It is available in the `devextreme` documentation. If you found this helpful please accept the answer and upvote. Happy Coding! – kavigun Sep 14 '22 at 18:23