Skip to main content Skip to footer

SpreadJS v12 Service Pack 2 - Custom Localization

We're pleased to announce the release of SpreadJS v12 sp2. We've been working hard to add requested and new features to expand how you use SpreadJS—it's so much more than a spreadsheet.

Read the full release

Custom Localization

SpreadJS supports several languages including English, Japanese, Chinese, and Korean by default. But what if you need to support other languages such as German, French or Spanish? SpreadJS v12 sp2 now supports custom localization, giving you full control over the language of the displayed properties and words in the SpreadJS instance.

Defining a language is simple and can be done in a single variable:

var lang = {
 // localization config goes here
 Common = {
  End: "Ends With..." ,
  Equal: "Equals..."
  ...
 },
 Sheets = {
  "Tip_Row": "行 = ",  //No parameters, will add the row number
  "Tip_Column": "列 = ",
  "Tip_Height": "高度: {0} 像素",   //Use the parameters
  "Tip_Width": "寬度: {0} 像素",
 },
 CalcEngine: {
  Fbx_Summary: "概要"
 },
 Functions: {
  SUM: {
   description: "此函數返回某一單元格區域中所有數字之和。",
   parameters: ["值1", "值2"]
  },
  NOW: {
   description: "此函數返回當前的日期和時間。"
  },
  IF: {
   description: "使用邏輯函數 IF 函數時,如果條件為真,該函數將返回一個值;如果條件為假,函數將返回另一個值。",
   parameters: ["判断条件", "值1", "值2"]
  },
 }
};

Once the customized language has been defined, it can be added as a language resource and then set as the culture of the SpreadJS instance with a couple lines of code:

GC.Spread.Common.CultureManager.addCultureInfo("zh-tw", null, lang);   //Add the language
GC.Spread.Common.CultureManager.culture("zh-tw");    //Set the culture

When defining the language, it is worth noting that not setting a statement will result in a default English translation. In addition, the custom language is not saved when using to/fromJSON, so it will need to be added back when required.

If needed, there is also added API to get the custom language that was defined:

/**
 * Gets the custom language.
 * @static
 * @param {string} cultureName Culture name
 * @returns {object} language object
 */
GC.Spread.Common.CultureManager.getLanguage (cultureName);

That's all that is needed to get started adding custom language resources to SpreadJS!

To get access to these features and enhancements, download SpreadJS v12 Service Pack 2 today!

Kevin Ashley - Spread Product Manager

Kevin Ashley

Product Manager
comments powered by Disqus