Skip to content

Commit acb72da

Browse files
committed
process exception that language is in lowcoder but is not in lowcoder-design
1 parent 12b3d57 commit acb72da

File tree

5 files changed

+229
-160
lines changed

5 files changed

+229
-160
lines changed

client/packages/lowcoder-design/src/i18n/design/index.ts

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

97
type transType = (key: any, variables?: any) => string;
108
type transToNodeType = (key: any, variables?: any) => ReactNode;
119

1210
let trans: transType;
1311
let transToNode: transToNodeType;
14-
let language: string = localStorage.getItem('lowcoder_uiLanguage') || 'en' ;
12+
const availableLanguages = ['en', 'zh', 'de', 'pt'];
13+
let language: string = getLanguage() || 'en' ;
1514

16-
export const initTranslator = async () => {
17-
const lang = localStorage.getItem('lowcoder_uiLanguage');
18-
let langJson = await (localeData as any)[lang || language]();
15+
export const initTranslator = async (lang?: string) => {
16+
let langJson = await (localeData as any)[lang || availableLanguages.includes(language) ? language : 'en']();
1917
langJson = {[lang || language]: langJson}
2018
const translator = new Translator<typeof langJson>(
2119
langJson,
@@ -28,9 +26,6 @@ export const initTranslator = async () => {
2826
trans = (key: any, variables?: any) => translator.trans?.(key, variables);
2927
}
3028

31-
const langJson = await (localeData as any)[REACT_APP_LANGUAGES || language]();
32-
33-
3429

3530
await initTranslator();
3631

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,81 @@
1-
import { en } from "./en";
21

3-
export const de: typeof en = {...en};
2+
export const de = {
3+
addItem: "Add",
4+
duplicate: "Duplicate",
5+
rename: "Rename",
6+
delete: "Delete",
7+
edit: "Edit",
8+
ok: "OK",
9+
cancel: "Cancel",
10+
previousStep: "Previous",
11+
nextStep: "Next",
12+
finish: "Finish",
13+
country: {
14+
china: "China",
15+
},
16+
notification: {
17+
copySuccess: "Copy success",
18+
copyFail: "Copy failed",
19+
},
20+
prop: {
21+
basic: "Basic",
22+
resources: "Resources",
23+
interaction: "Interaction",
24+
advanced: "Advanced",
25+
validation: "Validation",
26+
layout: "Layout",
27+
animationStyle:"Animation Style",
28+
labelStyle: "Label Style",
29+
style: "Style",
30+
meetings: "Meeting Settings",
31+
data: "Data",
32+
field: 'Field',
33+
inputFieldStyle: 'Input Field Style',
34+
childrenInputFieldStyle: 'Children Input Field Style',
35+
avatarStyle: 'Avatar Style',
36+
captionStyle: 'Caption Style',
37+
startButtonStyle: 'Start Button Style',
38+
resetButtonStyle: 'Reset Button Style',
39+
headerStyle: 'Header Style',
40+
bodyStyle: 'Body Style',
41+
badgeStyle: 'Badge Style',
42+
columnStyle: 'Column Style',
43+
modalStyle: 'Modal Style',
44+
},
45+
passwordInput: {
46+
label: "Password:",
47+
placeholder: "Please enter your password",
48+
inconsistentPassword: "Two passwords are inconsistent",
49+
confirmPasswordLabel: "Confirm password:",
50+
confirmPasswordPlaceholder: "Please enter your password again",
51+
},
52+
verifyCodeInput: {
53+
label: "Verification code:",
54+
errorMsg: "Code should be {digitNum} digits",
55+
placeholder: "Please enter {digitNum} digits code",
56+
sendCode: "Send code",
57+
},
58+
iconSelect: {
59+
title: "Select icon",
60+
searchPlaceholder: "Search icon",
61+
},
62+
shapeSelect: {
63+
title: "Select shape",
64+
searchPlaceholder: "Search shape",
65+
},
66+
eventHandler: {
67+
advanced: "Advanced",
68+
},
69+
comp: {
70+
selectedCompsTitle: "{selectCompNum} components are selected",
71+
selectedCompsDetail: "Click component to view its properties",
72+
batchDelete: "Batch delete",
73+
},
74+
optionsControl: {
75+
optionItemErrorMSg: `Found duplicate option value "{value}". Only the first item will be displayed. Please change to a unique value.`,
76+
emptyList: "No options",
77+
},
78+
container: {
79+
hintPlaceHolder: "Drag components from the right panel",
80+
},
81+
};
Lines changed: 70 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,80 @@
1-
import {en} from "./en";
2-
3-
export const pt: typeof en = {
4-
...en,
5-
addItem: "Adicionar",
6-
duplicate: "Duplicar",
7-
rename: "Renomear",
8-
delete: "Deletar",
9-
edit: "Editar",
10-
ok: "OK",
11-
cancel: "Cancelar",
12-
previousStep: "Anterior",
13-
nextStep: "Próximo",
14-
finish: "Finalizar",
15-
country: {
16-
...en.country,
17-
china: "China",
1+
export const pt = {
2+
"addItem": "Adicionar",
3+
"duplicate": "Duplicar",
4+
"rename": "Renomear",
5+
"delete": "Deletar",
6+
"edit": "Editar",
7+
"ok": "OK",
8+
"cancel": "Cancelar",
9+
"previousStep": "Anterior",
10+
"nextStep": "Próximo",
11+
"finish": "Finalizar",
12+
"country": {
13+
"china": "China"
1814
},
19-
notification: {
20-
...en.notification,
21-
copySuccess: "Sucesso ao Copiar",
22-
copyFail: "Falha ao Copiar",
15+
"notification": {
16+
"copySuccess": "Sucesso ao Copiar",
17+
"copyFail": "Falha ao Copiar"
2318
},
24-
prop: {
25-
...en.prop,
26-
basic: "Básico",
27-
resources: "Recursos",
28-
interaction: "Interação",
29-
advanced: "Avançado",
30-
validation: "Validação",
31-
layout: "Layout",
32-
labelStyle: "Estilo do Rótulo",
33-
style: "Estilo",
34-
meetings: "Configurações da Reunião",
35-
data: "Dados",
36-
field: 'Campo',
37-
inputFieldStyle: 'Estilo do Campo de Entrada',
38-
avatarStyle: 'Estilo do Avatar',
39-
captionStyle: 'Estilo da Legenda',
40-
startButtonStyle: 'Estilo do Botão de Começar',
41-
resetButtonStyle: 'Estilo do Botão de Resetar',
42-
headerStyle: 'Estilo do Cabeçalho',
43-
bodyStyle: 'Estilo do Corpo',
44-
badgeStyle: 'Estilo do Emblema',
19+
"prop": {
20+
"basic": "Básico",
21+
"resources": "Recursos",
22+
"interaction": "Interação",
23+
"advanced": "Avançado",
24+
"validation": "Validação",
25+
"layout": "Layout",
26+
"animationStyle": "Animation Style",
27+
"labelStyle": "Estilo do Rótulo",
28+
"style": "Estilo",
29+
"meetings": "Configurações da Reunião",
30+
"data": "Dados",
31+
"field": "Campo",
32+
"inputFieldStyle": "Estilo do Campo de Entrada",
33+
"childrenInputFieldStyle": "Children Input Field Style",
34+
"avatarStyle": "Estilo do Avatar",
35+
"captionStyle": "Estilo da Legenda",
36+
"startButtonStyle": "Estilo do Botão de Começar",
37+
"resetButtonStyle": "Estilo do Botão de Resetar",
38+
"headerStyle": "Estilo do Cabeçalho",
39+
"bodyStyle": "Estilo do Corpo",
40+
"badgeStyle": "Estilo do Emblema",
41+
"columnStyle": "Column Style",
42+
"modalStyle": "Modal Style"
4543
},
46-
passwordInput: {
47-
...en.passwordInput,
48-
label: "Senha:",
49-
placeholder: "Insira sua senha",
50-
inconsistentPassword: "As duas senhas não são iguais",
51-
confirmPasswordLabel: "Confirme a senha:",
52-
confirmPasswordPlaceholder: "Por favor insira a senha novamente",
44+
"passwordInput": {
45+
"label": "Senha:",
46+
"placeholder": "Insira sua senha",
47+
"inconsistentPassword": "As duas senhas não são iguais",
48+
"confirmPasswordLabel": "Confirme a senha:",
49+
"confirmPasswordPlaceholder": "Por favor insira a senha novamente"
5350
},
54-
verifyCodeInput: {
55-
...en.verifyCodeInput,
56-
label: "Código de verificação:",
57-
errorMsg: "O código deve ter {digitNum} digitos",
58-
placeholder: "Por favor insira {digitNum} digitos",
59-
sendCode: "Enviar Código",
51+
"verifyCodeInput": {
52+
"label": "Código de verificação:",
53+
"errorMsg": "O código deve ter {digitNum} digitos",
54+
"placeholder": "Por favor insira {digitNum} digitos",
55+
"sendCode": "Enviar Código"
6056
},
61-
iconSelect: {
62-
...en.iconSelect,
63-
title: "Selecionar Ícone",
64-
searchPlaceholder: "Pesquisar Ícone",
57+
"iconSelect": {
58+
"title": "Selecionar Ícone",
59+
"searchPlaceholder": "Pesquisar Ícone"
6560
},
66-
shapeSelect: {
67-
...en.shapeSelect,
68-
title: "Selecionar Forma",
69-
searchPlaceholder: "Pesquisar Forma",
61+
"shapeSelect": {
62+
"title": "Selecionar Forma",
63+
"searchPlaceholder": "Pesquisar Forma"
7064
},
71-
eventHandler: {
72-
...en.eventHandler,
73-
advanced: "Avançado",
65+
"eventHandler": {
66+
"advanced": "Avançado"
7467
},
75-
comp: {
76-
...en.comp,
77-
selectedCompsTitle: "{selectCompNum} componentes selecionados",
78-
selectedCompsDetail: "Clique no componente para ver suas propriedades",
79-
batchDelete: "Deletar em massa",
68+
"comp": {
69+
"selectedCompsTitle": "{selectCompNum} componentes selecionados",
70+
"selectedCompsDetail": "Clique no componente para ver suas propriedades",
71+
"batchDelete": "Deletar em massa"
8072
},
81-
optionsControl: {
82-
...en.optionsControl,
83-
optionItemErrorMSg: `Opção de valor encontrada duplicada "{value}". Somente o primeiro item será mostrado. Por favor, troque para um valor único.`,
84-
emptyList: "Sem opções",
73+
"optionsControl": {
74+
"optionItemErrorMSg": "Opção de valor encontrada duplicada \"{value}\". Somente o primeiro item será mostrado. Por favor, troque para um valor único.",
75+
"emptyList": "Sem opções"
8576
},
86-
container: {
87-
...en.container,
88-
hintPlaceHolder: "Arraste componentes do painel da direita",
89-
},
90-
};
77+
"container": {
78+
"hintPlaceHolder": "Arraste componentes do painel da direita"
79+
}
80+
}

0 commit comments

Comments
 (0)