To use language, you need to import the resource js file as follows:
You can use following code to switch language package
When you want to change another language, please recalculate the spread formula by calling the following code:
Language Package Effection
Function name resource like 'SUM' will changes to 'SOMME' in French.
Table function name resource like '#ALL, #Data' will changes to '#Tout, #Données' in French.
Special function logic like 'LENB' will be different result in different language.
CalcError name resource like '#NULL!' will be '#NOM?' in French.
Boolean value resource like 'FALSE' will be 'FAUX' in French.
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'));
initSpread(spread);
};
function initSpread(spread) {
var sheet = spread.getActiveSheet();
spread.suspendPaint();
sheet.setColumnWidth(0, 20);
sheet.setColumnWidth(1, 130);
sheet.setColumnWidth(2, 70);
sheet.setColumnWidth(3, 70);
sheet.setColumnWidth(4, 70);
sheet.setColumnWidth(5, 100);
var source = [
{ Course: "Calculus", Term: 1, Credit: 5, Score: 80, Teacher: "Nancy Feehafer" },
{ Course: "P.E.", Term: 1, Credit: 3.5, Score: 85, Teacher: "Andrew Cencini" },
{ Course: "Political Economics", Term: 1, Credit: 3.5, Score: 95, Teacher: "Jan Kotas" },
{ Course: "Basic of Computer", Term: 1, Credit: 2, Score: 85, Teacher: "Steven Thorpe" },
{ Course: "Micro-Economics", Term: 1, Credit: 4, Score: 62, Teacher: "Jan Kotas" },
{ Course: "Linear Algebra", Term: 2, Credit: 5, Score: 73, Teacher: "Nancy Feehafer" },
{ Course: "Accounting", Term: 2, Credit: 3.5, Score: 86, Teacher: "Nancy Feehafer" },
{ Course: "Statistics", Term: 2, Credit: 5, Score: 85, Teacher: "Robert Zare" },
{ Course: "Marketing", Term: 2, Credit: 4, Score: 70, Teacher: "Laura Giussani" }
];
sheet.tables.addFromDataSource("Table1", 2, 1, source, GC.Spread.Sheets.Tables.TableThemes.medium7);
sheet.setValue(0, 1, "Switch the language and check the SUM formula changes");
sheet.setValue(13, 2, "SUM:");
sheet.setFormula(13, 3, "=SUM(Table1[[#Data], [Credit]])");
sheet.setFormula(13, 4, "=FORMULATEXT(D14)");
sheet.getRange(13, 4, 1, 3)
.foreColor("rgb(130, 188, 0)");
sheet.addSpan(13, 4, 1, 3);
sheet.setValue(15, 2, "LENB:");
sheet.setFormula(15, 3, '=LENB("SpreadJS")');
sheet.setFormula(15, 4, "=FORMULATEXT(D16)");
sheet.getRange(15, 4, 1, 3)
.foreColor("rgb(130, 188, 0)");
sheet.addSpan(15, 4, 1, 3);
spread.resumePaint();
var selectDiv = document.getElementById('languageSelect');
selectDiv.addEventListener('change',function() {
var languageName = this.value;
GC.Spread.CalcEngine.LanguagePackages.languagePackages(languageName);
sheet.recalcAll(true);
});
}
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-languagepackages/dist/gc.spread.calcengine.languagepackages.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="sample-tutorial">
<div id="ss" class="sample-spreadsheets"></div>
<div class="options-container">
<div class="option-row">
Please choose one language from the drop-down list and check the localized function changes.
<select id="languageSelect" class="drop-down-list">
<option value="en">English</option>
<option value="zh">China</option>
<option value="ja">Japan</option>
<option value="ko">Korea/Korean </option>
<option value="fr">French</option>
<option value="nl">Dutch</option>
<option value="de">German</option>
<option value="es">Spanish</option>
<option value="pt">Portuguese</option>
<option value="ru">Russian</option>
<option value="sv">Swedish</option>
<option value="it">Italian</option>
<option value="da">Danish</option>
<option value="pl">Polish</option>
<option value="fi">Finnish</option>
<option value="no">Norwegian</option>
<option value="cs">Czech </option>
<option value="hu">Hungarian</option>
<option value="tr">Turkish</option>
</select>
</div>
</div>
</div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: calc(100% - 280px);
height:100%;
overflow: hidden;
float: left;
}
.options-container {
float: right;
width: 280px;
overflow: auto;
padding: 12px;
height: 100%;
box-sizing: border-box;
background: #fbfbfb;
}
.option-row {
margin-bottom: 12px;
}
.drop-down-list {
margin-top: 10px;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}