カスタムローカライゼーション

カスタムローカライゼーションは、特定の言語でSpreadJSをカスタマイズする機能を提供します。 現在のカルチャまたは特定のカルチャの言語リソースを取得し、リソースをカスタマイズすることもできます。

この機能を使うには、スキーマを使用してローカライズオブジェクトを定義し、CultureManagerに追加してから、定義されたカルチャに切り替える必要があります。 ワークシートには、定義された単語とともに異なるプロパティが表示されます。 以下は、中国語でカスタマイズするサンプルです。 または、特定のカルチャに基づいたリソースを修正します。 使用時のヒント: 一部のステートメントが設定されていない場合、SpreadJSは英語を表示します(空の文字列 "" に設定されている場合、何も表示されません)。 引数は、表示に{0}、{1}、…を使用します(例:「無効な{0}:{1}({2}と{3}の間でなければなりません)。」、「高さ:{0}ピクセル」)。 カスタムローカライゼーションはfromJson / toJsonをサポートしていないため、ユーザーは必要になるたびに追加する必要があります。 サンプルのネームスペース(「common」、「Sheets」、「Filter」)はオプションです。 ただし、「Functions」と「TableFunctions」は必須です。 以下も有効な形式です。
<template> <div class="sample-tutorial"> <div class="sample-container"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> <gc-worksheet> </gc-worksheet> </gc-spread-sheets> <div id="statusBar"></div> </div> <div class="sample-options"> <div class="options-container"> カルチャの切り替え: <select id="CultureSelect" @change="changeCultureName"> <option value="en">en</option> <option value="zh_tw">zh-tw</option> <option value="fr">fr</option> <option value="de">de</option> <option value="ha_ha">Ha-Ha</option> </select> <p>{{ l_descriptionRef }}</p> <textarea id="language" cols="85" rows="40" style="max-width: 98%; height: 500px" readonly="readonly" :value="languageRef"></textarea> <div class="sample-options"> <div class="options-container"> </div> </div> </div> </div> </div> </template> <script setup> import '@mescius/spread-sheets-vue'; import { ref } from "vue"; import GC from "@mescius/spread-sheets"; import '@mescius/spread-sheets-resources-zh'; import '@mescius/spread-sheets-resources-ja'; GC.Spread.Common.CultureManager.culture("ja-jp"); const spreadRef = ref(null); const languageRef = ref(""); const l_descriptionRef = ref("基本およびデフォルトの言語。"); const initSpread = (spread) => { spreadRef.value = spread; let sheet = spread.getActiveSheet(); spread.suspendPaint(); spread.options.showScrollTip = 3; spread.options.showResizeTip = 3; let table = sheet.tables.addFromDataSource("table1", 0, 0, source, GC.Spread.Sheets.Tables.TableThemes.medium9) table.showFooter(true); table.showHeader(true); table.highlightFirstColumn(true); table.setColumnFormula(2, "=SUM(C2:C10)"); table.setColumnFormula(3, "=SUM(D2:D10)"); table.setColumnValue(0, "Total"); sheet.setColumnWidth(0, 130); sheet.setColumnWidth(4, 100); GC.Spread.Common.CultureManager.addCultureInfo("de", null, de); var zhResources = GC.Spread.Common.CultureManager.getResources("zh-cn"); zhResources.Sheets.Tip_Column = zh_tw.Sheet.Tip_Column; zhResources.Sheets.Tip_Height = zh_tw.Sheet.Tip_Height; zhResources.Sheets.Tip_Row = zh_tw.Sheet.Tip_Row; zhResources.Sheets.Tip_Width = zh_tw.Sheet.Tip_Width; zhResources.Sheets.NewTab = zh_tw.Sheet.NewTab; zhResources.StatusBar = zh_tw.StatusBar; zhResources.CalcEngine.Fbx_Summary = zh_tw.CalcEngine.Fbx_Summary; zhResources.Functions.SUM = zh_tw.Functions.SUM; zhResources.Functions.NOW = zh_tw.Functions.NOW; zhResources.Functions.IF = zh_tw.Functions.IF; GC.Spread.Common.CultureManager.addCultureInfo("zh_tw", null, zhResources); GC.Spread.Common.CultureManager.addCultureInfo("fr", null, fr); GC.Spread.Common.CultureManager.addCultureInfo("ha_ha", null, ha_ha); let statusBar = new GC.Spread.Sheets.StatusBar.StatusBar(document.getElementById('statusBar')); statusBar.bind(spread); spread.resumePaint(); }; const changeCultureName = (e) => { let culture = e.target.value; GC.Spread.Common.CultureManager.culture(culture); l_descriptionRef.value = langDescription[culture]; if (culture === "en") { languageRef.value = ""; } else if (culture === "zh_tw") { languageRef.value = JSON.stringify(GC.Spread.Common.CultureManager.getResources("zh_tw"), null, 2) } else { languageRef.value = JSON.stringify(window[culture], null, 2); } }; </script> <style scoped> #app { height: 100%; } * { -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .sample-options { float: right; height: 100%; } .options-toggle { display: none; } .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-container { width: calc(100% - 280px); height: 100%; float: left; } .sample-spreadsheets { width: 100%; height: calc(100% - 25px); overflow: hidden; } #statusBar { bottom: 0; height: 25px; width: 100%; position: relative; } .options-container { float: right; width: 280px; padding: 12px; box-sizing: border-box; background: #fbfbfb; overflow: auto; font-size: 14px; } .option-row { font-size: 14px; padding: 5px; margin-top: 10px; } label { display: block; margin-bottom: 6px; } input { padding: 4px 6px; box-sizing: border-box; width: 100%; } input[type=button] { margin-top: 6px; display: block; } .summary { background-color: #e6e6fa; padding: 3px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } </style>
<!DOCTYPE html> <html lang="en" style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>SpreadJS VUE</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ja/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/ja/vue3/node_modules/systemjs/dist/system.src.js"></script> <script src="$DEMOROOT$/spread/source/data/customLocalization.js" type="text/javascript"></script> <script src="./systemjs.config.js"></script> <script src="./compiler.js" type="module"></script> <script> var System = SystemJS; System.import("./src/app.js"); System.import('$DEMOROOT$/ja/lib/vue3/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
(function (global) { SystemJS.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, packageConfigPaths: [ './node_modules/*/package.json', "./node_modules/@mescius/*/package.json", "./node_modules/@babel/*/package.json", "./node_modules/@vue/*/package.json" ], map: { 'vue': "npm:vue/dist/vue.esm-browser.js", 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js", '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-ja': 'npm:@mescius/spread-sheets-resources-ja/index.js', '@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js', '@mescius/spread-sheets-resources-zh': 'npm:@mescius/spread-sheets-resources-zh/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js' }, meta: { '*.css': { loader: 'systemjs-plugin-css' }, '*.vue': { loader: "../plugin-vue/index.js" } } }); })(this);