GridJs Multi-Language Configuration Guide

Aspose.Cells GridJs Multi-Language Configuration Guide

Overview

This tutorial will guide you through configuring multi-language support in your Aspose.Cells GridJs project. It covers both frontend and backend configurations.

The tutorial is based on the demo project, please adjust according to the actual situation.

Frontend Configuration

In your frontend pages, set the interface language using the local option.

In the demo project, you need to modify the index.html file.

Here’s an example:

const loadNormalContext = (sheet) => {
    const option = {
        updateMode: 'server',
        updateUrl: '/GridJs2/UpdateCell',
        showToolbar: true,
        mode: 'edit',
        // Supported languages: en/zh/es/pt/de/ru/nl/pl
        local: 'pl', // Set to Polish in this example
    };
    loadWithOption(jsondata, option);
};

Backend Configuration

In the backend code, you need to set the appropriate CultureInfo before processing Excel data.

In the demo project, you need to modify the Application file.

Set locale settings in main method

public static void main(String[] args) {
		
	// Set Polish locale for current thread
    Locale polishLocale = new Locale("pl", "PL");
    Locale.setDefault(polishLocale);
    
    // Demonstration of locale settings
    System.out.println("Current Locale: " + Locale.getDefault());
 
    ApplicationContext context = SpringApplication.run(GridjsdemoApplication.class, args);
     
    MyConfig myConfig = context.getBean(MyConfig.class);
	
	// Set license for Aspose.Cells
    com.aspose.cells.License lic = new com.aspose.cells.License();
	if ((new File(myConfig.asposeLicensePath)).exists()) {
		lic.setLicense(myConfig.asposeLicensePath);
	}
}

Important Notes

  1. Frontend and backend language settings must be consistent.
  2. CultureInfo must be set before processing Excel data.
  3. Supported languages: en (English), zh (Chinese), es (Spanish), pt (Portuguese), de (German), ru (Russian), nl (Dutch), pl (Polish).
  4. The example uses Polish (pl‑PL), but you can change it to any other supported locale.