Skip to content

Commit 12b3d57

Browse files
committed
put correct text to admin, viewer, editor
1 parent 18d8911 commit 12b3d57

File tree

24 files changed

+12801
-29289
lines changed

24 files changed

+12801
-29289
lines changed
Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
1-
import { Translator } from "lowcoder-core";
1+
import { getI18nObjects, Translator } from "lowcoder-core";
22
import * as localeData from "./locales";
3+
// import { I18nObjects } from "./locales/types";
4+
// import { languagesMetadata } from "./languagesMeta";
5+
import { ReactNode } from "react";
6+
// import { getLanguage } from "util/editor"
7+
// import {string} from "sql-formatter/lib/src/lexer/regexFactory";
38

4-
export const { trans } = new Translator<typeof localeData.en>(localeData, REACT_APP_LANGUAGES);
9+
type transType = (key: any, variables?: any) => string;
10+
type transToNodeType = (key: any, variables?: any) => ReactNode;
11+
12+
let trans: transType;
13+
let transToNode: transToNodeType;
14+
let language: string = localStorage.getItem('lowcoder_uiLanguage') || 'en' ;
15+
16+
export const initTranslator = async () => {
17+
const lang = localStorage.getItem('lowcoder_uiLanguage');
18+
let langJson = await (localeData as any)[lang || language]();
19+
langJson = {[lang || language]: langJson}
20+
const translator = new Translator<typeof langJson>(
21+
langJson,
22+
REACT_APP_LANGUAGES,
23+
[lang || language]
24+
);
25+
26+
language = translator.language;
27+
transToNode = (key: any, variables?: any) => translator.transToNode?.(key, variables);
28+
trans = (key: any, variables?: any) => translator.trans?.(key, variables);
29+
}
30+
31+
const langJson = await (localeData as any)[REACT_APP_LANGUAGES || language]();
32+
33+
34+
35+
await initTranslator();
36+
37+
export { language, trans, transToNode };
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// file examples: en, enGB, zh, zhHK
2-
// fallback example: current locale is zh-HK, fallback order is zhHK => zh => en
3-
export * from "./en";
4-
export * from "./zh";
5-
export * from "./de";
6-
export * from "./pt"
1+
2+
export const en = async () : Promise<Object> => await import("./en").then(module => module.en);
3+
export const zh = async () : Promise<Object> => await import("./zh").then(module => module.zh);
4+
export const de = async () : Promise<Object> => await import("./de").then(module => module.de);
5+
export const pt = async () : Promise<Object> => await import("./pt").then(module => module.pt);

client/packages/lowcoder-design/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "esnext",
44
"experimentalDecorators": true,
55
"lib": ["dom", "dom.iterable", "esnext"],
66
"allowJs": true,

client/packages/lowcoder/src/i18n/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type transToNodeType = (key: any, variables?: any) => ReactNode;
1111

1212
let trans: transType;
1313
let transToNode: transToNodeType;
14-
let language: string = localStorage.getItem('lowcoder_uiLanguage') || 'en' ;
14+
let language: string = getLanguage() || 'en' ;
1515

1616
export const initTranslator = async () => {
1717
const lang = getLanguage();

0 commit comments

Comments
 (0)