Skip to content

Commit 9ab473b

Browse files
committed
Fixed an issue that does not load language files from LocalStorage.
1 parent 6e2f316 commit 9ab473b

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

client/packages/lowcoder/src/pages/ApplicationV2/index.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { RootFolderListView } from "./RootFolderListView";
5252
import { fetchFolderElements, updateFolder } from "../../redux/reduxActions/folderActions";
5353
// import { ModuleView } from "./ModuleView";
5454
// import { useCreateFolder } from "./useCreateFolder";
55-
import { trans } from "../../i18n";
55+
import {initTranslator, trans} from "../../i18n";
5656
import { foldersSelector } from "../../redux/selectors/folderSelector";
5757
import Setting from "pages/setting";
5858
import { Support } from "pages/support";
@@ -67,6 +67,7 @@ import { ReduxActionTypes } from '@lowcoder-ee/constants/reduxActionConstants';
6767
import AppEditor from "../editor/AppEditor";
6868
import { set } from "lodash";
6969
import {MultiIconDisplay} from "@lowcoder-ee/comps/comps/multiIconDisplay";
70+
import {initTranslator as initTranslatorDesign} from "i18n/design";
7071

7172
const TabLabel = styled.div`
7273
font-weight: 500;
@@ -147,7 +148,17 @@ const DivStyled = styled.div`
147148
}
148149
`;
149150

151+
const initialize = async () => {
152+
try {
153+
await initTranslatorDesign();
154+
await initTranslator();
155+
} catch (error) {
156+
console.error('Initialization failed:', error);
157+
}
158+
};
159+
150160
export default function ApplicationHome() {
161+
const [isInitialized, setIsInitialized] = useState(false);
151162
const dispatch = useDispatch();
152163
const [isPreloadCompleted, setIsPreloadCompleted] = useState(false);
153164
const fetchingUser = useSelector(isFetchingUser);
@@ -163,6 +174,10 @@ export default function ApplicationHome() {
163174

164175
const isOrgAdmin = org?.createdBy == user.id ? true : false;
165176

177+
useEffect(() => {
178+
initialize().then(() => setIsInitialized(true));
179+
}, []);
180+
166181
useEffect(() => {
167182
dispatch(fetchHomeData({}));
168183
dispatch(fetchSubscriptionsAction());
@@ -197,7 +212,7 @@ export default function ApplicationHome() {
197212
user.currentOrgId && dispatch(fetchFolderElements({}));
198213
}, [dispatch, allFoldersCount, user.currentOrgId]);
199214

200-
if (fetchingUser || !isPreloadCompleted) {
215+
if (!isInitialized || fetchingUser || !isPreloadCompleted) {
201216
return <ProductLoading />;
202217
}
203218

client/packages/lowcoder/src/pages/editor/AppEditor.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ import Flex from "antd/es/flex";
3434
import React from "react";
3535
import dayjs from "dayjs";
3636
import { currentApplication } from "@lowcoder-ee/redux/selectors/applicationSelector";
37-
import { notificationInstance } from "components/GlobalInstances";
3837
import { AppState } from "@lowcoder-ee/redux/reducers";
38+
import { notificationInstance } from "components/GlobalInstances";
39+
import { initTranslator as initTranslatorDesign } from "i18n/design";
40+
import { initTranslator } from "@lowcoder-ee/i18n";
3941
import { resetIconDictionary } from "@lowcoder-ee/constants/iconConstants";
4042

4143
const AppSnapshot = lazy(() => {
@@ -48,7 +50,17 @@ const AppEditorInternalView = lazy(
4850
.then(moduleExports => ({default: moduleExports.AppEditorInternalView}))
4951
);
5052

53+
const initialize = async () => {
54+
try {
55+
await initTranslatorDesign();
56+
await initTranslator();
57+
} catch (error) {
58+
console.error('Initialization failed:', error);
59+
}
60+
};
61+
5162
const AppEditor = React.memo(() => {
63+
const [isInitialized, setIsInitialized] = useState(false);
5264
const dispatch = useDispatch();
5365
const params = useParams<AppPathParams>();
5466
const isUserViewModeCheck = useUserViewMode();
@@ -204,6 +216,14 @@ const AppEditor = React.memo(() => {
204216
</Flex>
205217
), []);
206218

219+
useEffect(() => {
220+
initialize().then(() => setIsInitialized(true));
221+
}, []);
222+
223+
if (!isInitialized) {
224+
return <EditorSkeletonView />;
225+
}
226+
207227
if (Boolean(appError)) {
208228
return (
209229
<Flex align="center" justify="center" vertical style={{

client/packages/lowcoder/src/pages/editor/right/InsertView.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ const InsertViewHeader = styled.div`
2929
}
3030
`;
3131

32-
const options = [
33-
{
34-
value: "ui",
35-
label: trans("rightPanel.uiComponentTab"),
36-
},
37-
{
38-
value: "extension",
39-
label: trans("rightPanel.extensionTab"),
40-
},
41-
];
42-
4332
interface InsertViewProps {
4433
onCompDrag: (dragCompKey: string) => void;
4534
}
@@ -49,6 +38,17 @@ export default function InsertView(props: InsertViewProps) {
4938
const [searchValue, setSearchValue] = useState("");
5039
const [activeKey, setActiveKey] = useState<OptionValue>("ui");
5140

41+
const options = [
42+
{
43+
value: "ui",
44+
label: trans("rightPanel.uiComponentTab"),
45+
},
46+
{
47+
value: "extension",
48+
label: trans("rightPanel.extensionTab"),
49+
},
50+
];
51+
5252
return (
5353
<Wrapper>
5454
<InsertViewHeader>

0 commit comments

Comments
 (0)