How to apply localization in grid?

Hello. Im having some trouble figuring how to apply localization to the grid texts. Im using "ej.Grid.Locale" from the documentation but im getting an error as "ej" is not to be found. 

1 Reply

BS Balaji Sekar Syncfusion Team May 12, 2020 07:20 AM UTC

Hi Konnos, 
 
Thanks for contacting Syncfusion support. 
 
As per your query, we are unable to reproduce the reported problem and we have created a sample for your reference. Please refer the below steps and help documentation link for more information.  
 
By default, grid component default  culture is en-US  so in the below sample, we have change the culture to “de” in button click. 
 
  • Import the L10n and setCulture etc, from ej2-base
 
import { L10n, loadCldr, setCulture, setCurrencyCode } from '@syncfusion/ej2-base'; 

 
  • Load the corresponding culture file using loadCldr method
 
import * as cagregorian from "./ca-gregorian.json"; 
import * as currencies from "./currencies.json"; 
import * as numbers from "./numbers.json"; 
import * as timeZoneNames from "./timeZoneNames.json"; 
 
loadCldr(cagregorian, currencies, numbers, timeZoneNames); // load json files 
 
 
  • Then dynamically change the locale and load the locale string using L10n and use setCulture , setCurrencyCode(based on the cldr file it apply format for the columns) for internalization.
              
const localede = { 
  'de': { 
    grid: { 
      EmptyRecord: 'Keine Aufzeichnungen angezeigt', 
      . . . . . 
  } 
} 
 
buttonClick(args) { 
  this.grid.locale='de'; // need to change the locale dynamically for grid 
  L10n.load(localede); // load corresponding culture text  
  setCulture('de'); // Change the Grid culture 
  setCurrencyCode('EUR');// Change the currency code 
} 

 
 
 
If you still faced any  problem then share the sample or hosted link of your sample that will helpful for us to validate further at our end.  
 
Regards, 
Balaji Sekar 


Loader.
Up arrow icon