Skip to content

Commit 168e19d

Browse files
committed
refactor: 增加lang配置
1 parent 1337cca commit 168e19d

43 files changed

Lines changed: 578 additions & 34 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/components/BootstrapBlazor.UniverSheet/Components/UniverSheet.razor.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function init(id, invoke, options) {
1515
data,
1616
plugins,
1717
theme,
18-
lang: getLang(lang || "")
18+
lang
1919
};
2020

2121
await createUniverSheetAsync(univerSheet);
@@ -24,10 +24,6 @@ export async function init(id, invoke, options) {
2424
invoke.invokeMethodAsync('TriggerReadyAsync');
2525
}
2626

27-
const getLang = lang => {
28-
return lang.replace('-', '');
29-
}
30-
3127
export function execute(id, data) {
3228
const univerSheet = Data.get(id);
3329

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
import { addScript, addLink } from '../BootstrapBlazor/modules/utility.js'
22
import DataService from './data-service.js'
33

4-
const loadAssets = async () => {
5-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/react.production.min.js');
6-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/react-dom.production.min.js');
7-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/rxjs.umd.min.js');
8-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.presets.umd.min.js');
9-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-core.umd.min.js');
10-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-drawing.umd.min.js');
11-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.sheets-zen-editor.umd.min.js');
12-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-data-validation.umd.min.js');
4+
const loadAssets = async lang => {
5+
console.log(lang, 'lang');
6+
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/react.production.min.js');
7+
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/react-dom.production.min.js');
8+
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/rxjs.umd.min.js');
9+
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.presets.umd.min.js');
10+
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-core/index.umd.min.js');
11+
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-drawing/index.umd.min.js');
12+
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.sheets-zen-editor/index.umd.min.js');
13+
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-data-validation/index.umd.min.js');
1314

14-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-core.locales.zh-CN.js');
15-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-drawing.locales.zhCN.js');
16-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.sheets-zen-editor.locales.zh-CN.js');
17-
await addScript('./_content/BootstrapBlazor.UniverSheet/univer/js/univerjs.preset-sheets-data-validation.locales.zh-CN.js');
15+
await addScript(`./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-core/locales/${lang}.js`);
16+
await addScript(`./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-drawing/locales/${lang}.js`);
17+
await addScript(`./_content/BootstrapBlazor.UniverSheet/univer/univerjs.sheets-zen-editor/locales/${lang}.js`);
18+
await addScript(`./_content/BootstrapBlazor.UniverSheet/univer/univerjs.preset-sheets-data-validation/locales/${lang}.js`);
1819

19-
await addLink('./_content/BootstrapBlazor.UniverSheet/univer/css/univer-sheet.bundle.css');
20+
await addLink('./_content/BootstrapBlazor.UniverSheet/univer/univer-sheet.bundle.css');
2021
}
2122

2223
export async function createUniverSheetAsync(sheet) {
23-
await loadAssets();
24-
24+
await loadAssets(sheet.lang);
25+
2526
const { el } = sheet;
2627
const { LocaleType, merge } = UniverCore;
2728
const { createUniver } = UniverPresets;
@@ -30,18 +31,18 @@ export async function createUniverSheetAsync(sheet) {
3031
const { UniverSheetsZenEditorPlugin } = UniverSheetsZenEditor
3132
const { UniverSheetsDataValidationPlugin } = UniverSheetsDataValidation
3233
const { UniverSheetsDataValidationUIPlugin } = UniverSheetsDataValidationUi
33-
const { defaultTheme } = UniverDesign;
34-
34+
const lang = sheet.lang.replace('-', '')
35+
const langStr = lang.charAt(0).toUpperCase() + lang.slice(1)
3536
const options = {
36-
theme: sheet.theme ?? defaultTheme,
37-
locale: sheet.lang ?? LocaleType.ZH_CN,
37+
theme: UniverDesign[sheet.theme] ?? UniverDesign.defaultTheme, //'defaultTheme' | greenTheme
38+
locale: lang,
3839
locales: {
39-
[LocaleType.ZH_CN]: merge(
40+
[lang]: merge(
4041
{},
41-
UniverPresetSheetsCoreZhCN,
42-
UniverPresetSheetsDrawingZhCN,
43-
UniverSheetsZenEditorZhCN,
44-
UniverSheetsDataValidationUiZhCN,
42+
window[`UniverPresetSheetsCore${langStr}`],
43+
window[`UniverPresetSheetsDrawing${langStr}`],
44+
window[`UniverSheetsZenEditor${langStr}`],
45+
window[`UniverSheetsDataValidationUi${langStr}`],
4546
),
4647
},
4748
plugins: [

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/js/react-dom.production.min.js renamed to src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/react-dom.production.min.js

File renamed without changes.

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/js/react.production.min.js renamed to src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/react.production.min.js

File renamed without changes.

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/js/rxjs.umd.min.js renamed to src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/rxjs.umd.min.js

File renamed without changes.

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/css/univer-sheet.bundle.css renamed to src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/univer-sheet.bundle.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
@import 'univerjs.preset-sheets-core.css';
2-
@import 'univerjs.preset-sheets-drawing.css';
3-
@import 'univerjs.sheets-zen-editor.css';
4-
@import 'univerjs.preset-sheets-data-validation.css';
1+
@import 'univerjs.preset-sheets-core/index.css';
2+
@import 'univerjs.preset-sheets-drawing/index.css';
3+
@import 'univerjs.sheets-zen-editor/index.css';
4+
@import 'univerjs.preset-sheets-data-validation/index.css';
55

66
.bb-univer-sheet {
77
width: 100%;

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/css/univerjs.preset-sheets-core.css renamed to src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/univerjs.preset-sheets-core/index.css

File renamed without changes.

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/js/univerjs.preset-sheets-core.umd.min.js renamed to src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/univerjs.preset-sheets-core/index.umd.min.js

File renamed without changes.

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/univerjs.preset-sheets-core/locales/en-US.js

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/BootstrapBlazor.UniverSheet/wwwroot/univer/univerjs.preset-sheets-core/locales/fa-IR.js

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)