Skip to content

Commit

Permalink
Fixed an issue that does not load language files from LocalStorage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Imiss-U1025 committed Oct 23, 2024
1 parent 98cfbe5 commit a4efae5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 14 deletions.
19 changes: 17 additions & 2 deletions client/packages/lowcoder/src/pages/ApplicationV2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { RootFolderListView } from "./RootFolderListView";
import { fetchFolderElements, updateFolder } from "../../redux/reduxActions/folderActions";
// import { ModuleView } from "./ModuleView";
// import { useCreateFolder } from "./useCreateFolder";
import { trans } from "../../i18n";
import {initTranslator, trans} from "../../i18n";
import { foldersSelector } from "../../redux/selectors/folderSelector";
import Setting from "pages/setting";
import { Support } from "pages/support";
Expand All @@ -67,6 +67,7 @@ import { ReduxActionTypes } from '@lowcoder-ee/constants/reduxActionConstants';
import AppEditor from "../editor/AppEditor";
import { set } from "lodash";
import {MultiIconDisplay} from "@lowcoder-ee/comps/comps/multiIconDisplay";
import {initTranslator as initTranslatorDesign} from "i18n/design";

const TabLabel = styled.div`
font-weight: 500;
Expand Down Expand Up @@ -147,7 +148,17 @@ const DivStyled = styled.div`
}
`;

const initialize = async () => {
try {
await initTranslatorDesign();
await initTranslator();
} catch (error) {
console.error('Initialization failed:', error);
}
};

export default function ApplicationHome() {
const [isInitialized, setIsInitialized] = useState(false);
const dispatch = useDispatch();
const [isPreloadCompleted, setIsPreloadCompleted] = useState(false);
const fetchingUser = useSelector(isFetchingUser);
Expand All @@ -163,6 +174,10 @@ export default function ApplicationHome() {

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

useEffect(() => {
initialize().then(() => setIsInitialized(true));
}, []);

useEffect(() => {
dispatch(fetchHomeData({}));
dispatch(fetchSubscriptionsAction());
Expand Down Expand Up @@ -197,7 +212,7 @@ export default function ApplicationHome() {
user.currentOrgId && dispatch(fetchFolderElements({}));
}, [dispatch, allFoldersCount, user.currentOrgId]);

if (fetchingUser || !isPreloadCompleted) {
if (!isInitialized || fetchingUser || !isPreloadCompleted) {
return <ProductLoading />;
}

Expand Down
22 changes: 21 additions & 1 deletion client/packages/lowcoder/src/pages/editor/AppEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ import Flex from "antd/es/flex";
import React from "react";
import dayjs from "dayjs";
import { currentApplication } from "@lowcoder-ee/redux/selectors/applicationSelector";
import { notificationInstance } from "components/GlobalInstances";
import { AppState } from "@lowcoder-ee/redux/reducers";
import { notificationInstance } from "components/GlobalInstances";
import { initTranslator as initTranslatorDesign } from "i18n/design";
import { initTranslator } from "@lowcoder-ee/i18n";

const AppSnapshot = lazy(() => {
return import("pages/editor/appSnapshot")
Expand All @@ -47,7 +49,17 @@ const AppEditorInternalView = lazy(
.then(moduleExports => ({default: moduleExports.AppEditorInternalView}))
);

const initialize = async () => {
try {
await initTranslatorDesign();
await initTranslator();
} catch (error) {
console.error('Initialization failed:', error);
}
};

const AppEditor = React.memo(() => {
const [isInitialized, setIsInitialized] = useState(false);
const dispatch = useDispatch();
const params = useParams<AppPathParams>();
const isUserViewModeCheck = useUserViewMode();
Expand Down Expand Up @@ -202,6 +214,14 @@ const AppEditor = React.memo(() => {
</Flex>
), []);

useEffect(() => {
initialize().then(() => setIsInitialized(true));
}, []);

if (!isInitialized) {
return <EditorSkeletonView />;
}

if (Boolean(appError)) {
return (
<Flex align="center" justify="center" vertical style={{
Expand Down
22 changes: 11 additions & 11 deletions client/packages/lowcoder/src/pages/editor/right/InsertView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ const InsertViewHeader = styled.div`
}
`;

const options = [
{
value: "ui",
label: trans("rightPanel.uiComponentTab"),
},
{
value: "extension",
label: trans("rightPanel.extensionTab"),
},
];

interface InsertViewProps {
onCompDrag: (dragCompKey: string) => void;
}
Expand All @@ -49,6 +38,17 @@ export default function InsertView(props: InsertViewProps) {
const [searchValue, setSearchValue] = useState("");
const [activeKey, setActiveKey] = useState<OptionValue>("ui");

const options = [
{
value: "ui",
label: trans("rightPanel.uiComponentTab"),
},
{
value: "extension",
label: trans("rightPanel.extensionTab"),
},
];

return (
<Wrapper>
<InsertViewHeader>
Expand Down

0 comments on commit a4efae5

Please sign in to comment.