Skip to content

Commit 7251c1e

Browse files
committed
revert language of lowcoder and lowcoder-design
1 parent d4140ae commit 7251c1e

File tree

5 files changed

+27
-56
lines changed

5 files changed

+27
-56
lines changed
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,4 @@
1-
import { getI18nObjects, Translator } from "lowcoder-core";
1+
import { Translator } from "lowcoder-core";
22
import * as localeData from "./locales";
3-
import { ReactNode } from "react";
43

5-
type transType = (key: any, variables?: any) => string;
6-
type transToNodeType = (key: any, variables?: any) => ReactNode;
7-
8-
let trans: transType;
9-
let transToNode: transToNodeType;
10-
let language = 'en';
11-
12-
export const initTranslator = async (lang?: string) => {
13-
let langJson = await (localeData as any)[lang || 'en']();
14-
langJson = {[lang || 'en']: langJson}
15-
const translator = new Translator<typeof langJson>(
16-
langJson,
17-
REACT_APP_LANGUAGES,
18-
[lang || 'en']
19-
);
20-
21-
language = translator.language;
22-
transToNode = (key: any, variables?: any) => translator.transToNode?.(key, variables);
23-
trans = (key: any, variables?: any) => translator.trans?.(key, variables);
24-
}
25-
26-
const langJson = await (localeData as any)[REACT_APP_LANGUAGES || 'en']();
27-
28-
await initTranslator();
29-
30-
export { language, trans, transToNode };
4+
export const { trans } = new Translator<typeof localeData.en>(localeData, REACT_APP_LANGUAGES);
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// file examples: en, enGB, zh, zhHK
22
// fallback example: current locale is zh-HK, fallback order is zhHK => zh => en
3-
export const en = async () : Promise<Object> => await import("./en").then(module => module.en);
4-
export const zh = async () : Promise<Object> => await import("./zh").then(module => module.zh);
5-
export const de = async () : Promise<Object> => await import("./de").then(module => module.de);
6-
export const pt = async () : Promise<Object> => await import("./pt").then(module => module.pt);
3+
export * from "./en";
4+
export * from "./zh";
5+
export * from "./de";
6+
export * from "./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": "es2017",
3+
"target": "es5",
44
"experimentalDecorators": true,
55
"lib": ["dom", "dom.iterable", "esnext"],
66
"allowJs": true,

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,26 @@ let trans: transType;
1111
let transToNode: transToNodeType;
1212
let language = 'en';
1313

14-
export const initTranslator = async (lang?: string) => {
15-
let langJson = await (localeData as any)[lang || 'en']();
16-
langJson = {[lang || 'en']: langJson}
17-
const translator = new Translator<typeof langJson>(
18-
langJson,
19-
REACT_APP_LANGUAGES,
20-
[lang || 'en']
14+
export const initTranslator = (lang?: string) => {
15+
const translator = new Translator<typeof localeData.en>(
16+
localeData,
17+
REACT_APP_LANGUAGES,
18+
[lang || 'en']
2119
);
2220

2321
language = translator.language;
24-
transToNode = (key: any, variables?: any) => translator.transToNode?.(key, variables);
25-
trans = (key: any, variables?: any) => translator.trans?.(key, variables);
22+
transToNode = translator.transToNode;
23+
trans = translator.trans;
2624
}
2725

28-
const langJson = await (localeData as any)[REACT_APP_LANGUAGES || 'en']();
29-
export const i18nObjs = getI18nObjects<I18nObjects>(langJson, REACT_APP_LANGUAGES || 'en');
26+
export const i18nObjs = getI18nObjects<I18nObjects>(localeData, REACT_APP_LANGUAGES);
3027

3128
export const languageList = Object.keys(languagesMetadata).map(code => ({
3229
languageCode: code,
3330
languageName: languagesMetadata[code].languageName,
3431
flag: languagesMetadata[code].flag
3532
}));
3633

37-
await initTranslator();
34+
initTranslator();
3835

3936
export { language, trans, transToNode };
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// file examples: en, enGB, zh, zhHK
22
// fallback example: current locale is zh-HK, fallback order is zhHK => zh => en
3-
export const de = async ():Promise<object> => await import("./de").then(module => (module.de));
4-
export const en = async ():Promise<object> => await import("./en").then(module => (module.en));
5-
export const it = async ():Promise<object> => await import("./it").then(module => (module.it));
6-
export const pt = async ():Promise<object> => await import("./pt").then(module => (module.pt));
7-
export const es = async ():Promise<object> => await import("./es").then(module => (module.es));
8-
export const zh = async ():Promise<object> => await import("./zh").then(module => (module.zh));
9-
export const ru = async ():Promise<object> => await import("./ru").then(module => (module.ru));
3+
export * from "./de";
4+
export * from "./en";
5+
export * from "./it";
6+
export * from "./pt";
7+
export * from "./es";
8+
export * from "./zh";
9+
export * from "./ru";
1010

11-
export const enObj = async ():Promise<object> => await import("./enObj").then(module => (module.enObj));
12-
export const deObj = async ():Promise<object | undefined> => await import("./deObj").then(module => (module.deObj));
13-
export const itObj = async ():Promise<object> => await import("./itObj").then(module => (module.itObj));
14-
export const zhObj = async ():Promise<object | undefined> => await import("./zhObj").then(module => (module.zhObj));
11+
export * from "./enObj";
12+
export * from "./deObj";
13+
export * from "./itObj";
14+
export * from "./zhObj";

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy