Skip to main content Skip to footer

Format Cells Dialog Shows Previous Locale After Changing Culture

When changing the culture from code, the Format Cells dialog may initially display the previous locale and its date formats.

For example, if a date cell uses the m/d/yyyy formatter and the culture is changed to ja-JP, the dialog may still show English (United States) when opened on the Date category. Switching to another category and back to Date displays the expected Japanese locale.

Case

This is the current design. The m/d/yyyy format is a predefined Date format for en-US, but it is not included in the predefined Date formats for ja-JP.

When the dialog is opened, SpreadJS determines the locale based on the existing formatter. Since m/d/yyyy belongs to en-US, the dialog initially displays the English locale.

Workaround

You can add the existing formatter to the predefined Date formats for ja-JP.

const jaCulture = GC.Spread.Common.CultureManager.getCultureInfo("ja-JP");

if (!jaCulture.predefinedFormats.Date.includes("m/d/yyyy")) {
    jaCulture.predefinedFormats.Date.push("m/d/yyyy");
}

GC.Spread.Common.CultureManager.addCultureInfo("ja-JP", jaCulture);
GC.Spread.Common.CultureManager.culture("ja-JP");

This allows the Format Cells dialog to display Japanese (Japan) and the corresponding Japanese date formats immediately when opened on the Date category.

The behavior has been confirmed as the current design.

Kristina Ismail

Technical Engagement Engineer