diff --git a/client/packages/lowcoder/src/app.tsx b/client/packages/lowcoder/src/app.tsx index 27c7a2a2e..dfc1c614d 100644 --- a/client/packages/lowcoder/src/app.tsx +++ b/client/packages/lowcoder/src/app.tsx @@ -215,6 +215,9 @@ const AppIndexWithProps = connect(mapStateToProps, mapDispatchToProps)(AppIndex) export function bootstrap() { initApp(); loadComps(); + + const uiLanguage = localStorage.getItem('lowcoder_uiLanguage'); + const container = document.getElementById("root"); const root = createRoot(container!); root.render( diff --git a/client/packages/lowcoder/src/i18n/LanguageProvider.ts b/client/packages/lowcoder/src/i18n/LanguageProvider.ts index c8d2fdfe9..ff97c3d80 100644 --- a/client/packages/lowcoder/src/i18n/LanguageProvider.ts +++ b/client/packages/lowcoder/src/i18n/LanguageProvider.ts @@ -3,4 +3,4 @@ import React, { ReactNode } from 'react'; // Define the props expected by the LanguageProvider component export interface LanguageProviderProps { children: ReactNode; -} +} \ No newline at end of file diff --git a/client/packages/lowcoder/src/i18n/index.tsx b/client/packages/lowcoder/src/i18n/index.tsx index fa56822e5..426c43dbc 100644 --- a/client/packages/lowcoder/src/i18n/index.tsx +++ b/client/packages/lowcoder/src/i18n/index.tsx @@ -2,14 +2,26 @@ import { getI18nObjects, Translator } from "lowcoder-core"; import * as localeData from "./locales"; import { I18nObjects } from "./locales/types"; import { languagesMetadata } from "./languagesMeta"; +import { ReactNode } from "react"; -const uiLanguage = localStorage.getItem('lowcoder_uiLanguage'); +type transType = (key: any, variables?: any) => string; +type transToNodeType = (key: any, variables?: any) => ReactNode; -export const { trans, transToNode, language } = new Translator( - localeData, - REACT_APP_LANGUAGES, - [uiLanguage || 'en'] -); +let trans: transType; +let transToNode: transToNodeType; +let language = 'en'; + +export const initTranslator = (lang?: string) => { + const translator = new Translator( + localeData, + REACT_APP_LANGUAGES, + [lang || 'en'] + ); + + language = translator.language; + transToNode = translator.transToNode; + trans = translator.trans; +} export const i18nObjs = getI18nObjects(localeData, REACT_APP_LANGUAGES); @@ -17,4 +29,8 @@ export const languageList = Object.keys(languagesMetadata).map(code => ({ languageCode: code, languageName: languagesMetadata[code].languageName, flag: languagesMetadata[code].flag -})); \ No newline at end of file +})); + +initTranslator(); + +export { language, trans, transToNode }; diff --git a/client/packages/lowcoder/src/i18n/locales/de.ts b/client/packages/lowcoder/src/i18n/locales/de.ts index 0cb17b4ad..067a0ccc5 100644 --- a/client/packages/lowcoder/src/i18n/locales/de.ts +++ b/client/packages/lowcoder/src/i18n/locales/de.ts @@ -2249,7 +2249,19 @@ export const de: typeof en = { "alreadySetPassword": "Passwort setzen", "setPassPlaceholder": "Du kannst dich mit Passwort anmelden", "setPassAfterBind": "Du kannst das Passwort nach der Kontobindung festlegen", - "socialConnections": "Soziale Bindungen" + "socialConnections": "Soziale Bindungen", + "changeAvatar": "Avatar ändern", + "about": "Um", + "userId": "Benutzer-ID", + "createdAt": "Hergestellt in", + "currentOrg": "aktuelle Organisation", + "settings": "Einstellungen", + "uiLanguage": "UI-Sprache", + "info": "Die Info", + "createdApps": "Erstellte Apps", + "createdModules": "Erstellte Module", + "onMarketplace": "Auf dem Marktplatz", + "howToPublish": "So veröffentlichen Sie auf dem Marktplatz" }, "shortcut": { ...en.shortcut, diff --git a/client/packages/lowcoder/src/i18n/locales/en.ts b/client/packages/lowcoder/src/i18n/locales/en.ts index 35f9d6a90..a787c72ae 100644 --- a/client/packages/lowcoder/src/i18n/locales/en.ts +++ b/client/packages/lowcoder/src/i18n/locales/en.ts @@ -2302,7 +2302,19 @@ export const en = { "alreadySetPassword": "Password Set", "setPassPlaceholder": "You Can Login with Password", "setPassAfterBind": "You Can Set Password After Account Bind", - "socialConnections": "Social Connections" + "socialConnections": "Social Connections", + "changeAvatar": "Change Avatar", + "about": "About", + "userId": "User ID", + "createdAt": "Created At", + "currentOrg": "Current Organization", + "settings": "Settings", + "uiLanguage": "UI Language", + "info": "Info", + "createdApps": "Created Apps", + "createdModules": "Created Modules", + "onMarketplace": "On Marketplace", + "howToPublish": "How to publish on Marketplace" }, "shortcut": { "shortcutList": "Keyboard Shortcuts", diff --git a/client/packages/lowcoder/src/i18n/locales/zh.ts b/client/packages/lowcoder/src/i18n/locales/zh.ts index 088ed7c31..54ba39b0b 100644 --- a/client/packages/lowcoder/src/i18n/locales/zh.ts +++ b/client/packages/lowcoder/src/i18n/locales/zh.ts @@ -2136,6 +2136,18 @@ profile: { setPassPlaceholder: "您可以使用密码登录", setPassAfterBind: "账号绑定后,您可以设置密码", socialConnections: "社交连接", + changeAvatar: "更改头像", + about: "关于", + userId: "用户身份", + createdAt: "创建于", + currentOrg: "当前组织", + settings: "设置", + uiLanguage: "用户界面语言", + info: "信息", + createdApps: "创建的应用程序", + createdModules: "创建的模块", + onMarketplace: "在市场上", + howToPublish: "如何在 Marketplace 上发布", }, shortcut: { shortcutList: "键盘快捷键", @@ -2287,6 +2299,7 @@ history: { history: "历史记录", }, home: { + profile: "你的个人资料", allApplications: "所有应用", allModules: "所有模块", allFolders: "所有文件夹", diff --git a/client/packages/lowcoder/src/pages/ApplicationV2/UserProfileLayout.tsx b/client/packages/lowcoder/src/pages/ApplicationV2/UserProfileLayout.tsx index ec0c02df2..5b1314e3a 100644 --- a/client/packages/lowcoder/src/pages/ApplicationV2/UserProfileLayout.tsx +++ b/client/packages/lowcoder/src/pages/ApplicationV2/UserProfileLayout.tsx @@ -239,7 +239,7 @@ export function UserProfileLayout(props: UserProfileLayoutProps) { - } shape="square" size={120} /> + } shape="square" size={120} /> @@ -265,11 +265,12 @@ export function UserProfileLayout(props: UserProfileLayoutProps) { beforeUpload={beforeImgUpload} withCredentials > - + val.trim() !== "", message: trans("profile.nameCheck"), @@ -285,20 +286,20 @@ export function UserProfileLayout(props: UserProfileLayoutProps) { - About + {trans("profile.about")} - User-ID: {user.id} | - Created At: {dayjs(user.createdTimeMs).format("YYYY-MM-DD HH:mm:ss")} | - Current Organization: {currentOrg?.name} + {trans("profile.userId")}: {user.id} | + {trans("profile.createdAt")}: {dayjs(user.createdTimeMs).format("YYYY-MM-DD HH:mm:ss")} | + {trans("profile.currentOrg")}: {currentOrg?.name} - Settings + {trans("profile.settings")} - UI Language: + {trans("profile.uiLanguage")}: