Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lang en #187

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/components/DeveloperIDE/Projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { FaFileImport } from 'react-icons/fa';
const Projects = observer(() => {
const {
w3s,
base: { confirm }
base: { confirm },
lang: { t }
} = useStore();
const { allProjects, selectedNames } = w3s.project;

Expand Down Expand Up @@ -54,7 +55,7 @@ const Projects = observer(() => {
onClick={async () => {
await allProjects.call();
w3s.projectManager.sync();
toast.success('Reloaded');
toast.success(t("success.reloaded.msg"));
}}
>
Refresh
Expand All @@ -79,7 +80,7 @@ const Projects = observer(() => {
}
w3s.project.resetSelectedNames();
eventBus.emit('project.delete');
toast.success('Deleted successfully');
toast.success(t("success.delete.msg"));
}
});
}}
Expand Down Expand Up @@ -107,15 +108,15 @@ const Projects = observer(() => {
err = error.message;
}
} else {
err = 'Instance not found';
err = t('error.pause.msg');
}
}
if (err) {
toast.error('Instance not found');
toast.error(t('error.pause.msg'));
} else {
w3s.project.resetSelectedNames();
eventBus.emit('instance.handle');
toast.success('Suspended successfully');
toast.success(t('success.pause.msg'));
}
}}
>
Expand Down Expand Up @@ -244,7 +245,7 @@ const Projects = observer(() => {
url: `/api/w3bapp/deploy/${instance.f_instance_id}/HUNGUP`
});
eventBus.emit('instance.handle');
toast.success('Successfully suspended');
toast.success(t("success.suspended.msg"));
} catch (error) { }
}}
/>
Expand All @@ -264,7 +265,7 @@ const Projects = observer(() => {
url: `/api/w3bapp/deploy/${instance.f_instance_id}/START`
});
eventBus.emit('instance.handle');
toast.success('Successfully started');
toast.success(t("success.started.msg"));
} catch (error) { }
}}
/>
Expand Down
12 changes: 10 additions & 2 deletions src/components/DeveloperIDE/ToolBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import toast from 'react-hot-toast';
interface ToolBar extends BoxProps {}

const ToolBar = (props: ToolBar) => {
const { w3s } = useStore();
const { w3s, lang:{t} } = useStore();
const { onOpen, onClose, isOpen } = useDisclosure();

const curProjectInstance = w3s.instances.table.dataSource.find((option) => option.project_name === w3s.project.curProject?.name);
Expand Down Expand Up @@ -58,8 +58,16 @@ const ToolBar = (props: ToolBar) => {
if (instance) {
w3s.project.allProjects.onSelect(index);
w3s.showContent = 'METRICS';
const now = new Date();
now.setMinutes(0);
now.setSeconds(0);
now.setMilliseconds(0);
const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000)
w3s.metrics.activeDevices.call(yesterday, now);
w3s.metrics.dataMessages.call(yesterday, now);
w3s.metrics.blockchainTransaction.call(yesterday, now);
} else {
toast.error('No instance found, please create one first');
toast.error(t('error.change.project.msg'));
}
onClose();
}}
Expand Down
8 changes: 5 additions & 3 deletions src/components/IDE/DBTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import toast from 'react-hot-toast';
const EditTable = observer(() => {
const {
base: { confirm },
lang: {t},
w3s: {
dbTable,
dbTable: { currentColumns }
Expand Down Expand Up @@ -179,7 +180,8 @@ const EditTable = observer(() => {

const ViewData = observer(() => {
const {
w3s: { dbTable }
w3s: { dbTable },
lang: {t}
} = useStore();

if (!dbTable.currentTable.tableName) {
Expand Down Expand Up @@ -210,10 +212,10 @@ const ViewData = observer(() => {
dbTable.table.set({
dataSource: data
});
toast.success('Upload CSV success');
toast.success(t('success.upload.msg'));
}
} else {
toast.error('CSV file is empty');
toast.error(t('error.csvfile.empty.msg'));
}
(document.getElementById('csv-input') as HTMLInputElement).value = '';
}}
Expand Down
4 changes: 2 additions & 2 deletions src/components/IDE/Editor/EditorBottomPanels/ABIPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const FunctionList = observer(({ contract }: { contract: ContractInstance
});

export const FunctiomItem = observer(({ functionItem, contract }: { functionItem: FunctionState; contract: ContractInstance }) => {
const { god } = useStore();
const { god, lang: {t} } = useStore();
const _contract = contract;
const store = useLocalObservable(() => ({
loading: new BooleanState(),
Expand Down Expand Up @@ -222,7 +222,7 @@ export const FunctiomItem = observer(({ functionItem, contract }: { functionItem
const Interface = new ethers.utils.Interface(abi);
const bytecode = Interface.encodeFunctionData(functionItem.name, params);
await navigator.clipboard.writeText(bytecode);
toast.success('Copy Success');
toast.success(t("success.copy.msg"));
} catch (e) {
toast.error(e.message);
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/IDE/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const Editor = observer(() => {
w3s: {
projectManager: { curFilesListSchema },
lab
}
},
lang: {t}
} = useStore();
useEffect(() => {
const handleSave = (event) => {
Expand Down Expand Up @@ -86,10 +87,10 @@ const Editor = observer(() => {
currentFolder.children[curWasmIndex] = wasmFile;
}
curFilesListSchema.setActiveFiles(wasmFile);
toast.success('Compile Success!');
toast.success(t("error.compile.msg"));
} catch (error) {
console.log(error);
toast.error('Compile Error!');
toast.error(t("success.compile.msg"));
}
}
}));
Expand Down
5 changes: 3 additions & 2 deletions src/components/IDE/PublishEventRequestTemplates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const ShowRequestTemplatesButton = observer(({ props = {} }: { props?: Bu
formData: { accountRole }
}
}
}
},
lang: { t }
} = useStore();
return (
<Button
Expand All @@ -28,7 +29,7 @@ export const ShowRequestTemplatesButton = observer(({ props = {} }: { props?: Bu
if (accountRole === 'ADMIN') {
const { projectName } = publisher.publishEventForm.formData;
if (!projectName) {
toast.error('Please select the project first');
toast.error(t('error.api.code.msg'));
return;
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/IDE/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ interface SideBarProps extends FlexProps { }
const SideBar = observer((props: SideBarProps) => {
const {
w3s,
base: { confirm }
base: { confirm },
lang: { t }
} = useStore();
const { allProjects, curProject } = w3s.project;

Expand Down Expand Up @@ -46,7 +47,7 @@ const SideBar = observer((props: SideBarProps) => {
onClick={async () => {
await allProjects.call();
w3s.projectManager.sync();
toast.success('Reloaded');
toast.success(t('success.reloaded.msg'));
}}
>
<Icon as={MdRefresh} color="#946FFF" />
Expand Down Expand Up @@ -115,7 +116,7 @@ const SideBar = observer((props: SideBarProps) => {
url: `/api/w3bapp/project/x/${p.f_name}`
});
eventBus.emit('project.delete');
toast.success('Deleted successfully');
toast.success(t('success.delete.msg'));
}
});
}}
Expand Down
4 changes: 3 additions & 1 deletion src/components/JSONTable/FieldRender.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { InstanceType, PublisherType } from '@/server/routers/w3bstream';
import { useStore } from '@/store/index';
import { CopyIcon } from '@chakra-ui/icons';
import { Badge, Flex, Text } from '@chakra-ui/react';
import copy from 'copy-to-clipboard';
Expand Down Expand Up @@ -64,6 +65,7 @@ export const tokenFormat = (token) => {
};

export const PublisherTokenRender = (item: PublisherType) => {
const { lang: {t} } = useStore()
return (
<Flex alignItems="center">
<Text>{tokenFormat(item.f_token)}</Text>
Expand All @@ -72,7 +74,7 @@ export const PublisherTokenRender = (item: PublisherType) => {
cursor="pointer"
onClick={() => {
copy(item.f_token);
toast.success('Copied');
toast.success(t("success.copy.msg"));
}}
/>
</Flex>
Expand Down
8 changes: 4 additions & 4 deletions src/components/WagmiProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const WagmiProvider = observer(({ children }) => {
});

const Wallet = observer(() => {
const { god, w3s } = useStore();
const { god, w3s, lang: {t} } = useStore();
const { chain } = useNetwork();
const { address, connector, isConnected } = useAccount();
const { connect, connectors, error, isLoading } = useConnect({
Expand Down Expand Up @@ -84,7 +84,7 @@ const Wallet = observer(() => {
id: 'login',
title: 'Login',
loading: false,
message: 'Login successful.',
message: t("success.login.msg"),
color: 'green',
autoClose: 3000
});
Expand All @@ -93,7 +93,7 @@ const Wallet = observer(() => {
id: 'login',
title: 'Login',
loading: false,
message: 'Login failed',
message: t("error.login.msg"),
color: 'red',
autoClose: 1000
});
Expand All @@ -104,7 +104,7 @@ const Wallet = observer(() => {
id: 'login',
title: 'Login',
loading: false,
message: 'Login failed',
message: t("error.login.msg"),
color: 'red',
autoClose: 1000
});
Expand Down
21 changes: 20 additions & 1 deletion src/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,24 @@
"view-on-explorername": "View on {{explorerName}}",
"wallet-connect": "Wallet Connect",
"warning": "warning",
"wrong-network": "Wrong Network"
"wrong-network": "Wrong Network",
"error.pause.msg": "Instance not found",
"success.pause.msg": "Suspended successfully",
"error.change.project.msg": "No instance found, please create one first",
"success.upload.msg": "Upload CSV success",
"error.csvfile.empty.msg": "CSV file is empty",
"error.compile.msg": "Compile Success!",
"success.compile.msg": "Compile Error!",
"success.copy.msg": "Copy Success",
"error.api.code.msg": "Please select the project first",
"error.connect.vscode.msg": "Connect VSCode extension Failed!",
"error.delete.msg": "Delete failed",
"success.delete.msg": "Deleted successfully",
"success.reloaded.msg": "Reloaded",
"success.suspended.msg": "Successfully suspended",
"success.started.msg": "Successfully started",
"error.login.msg": "Login failed",
"success.login.msg": "Login successful.",
"error.flow.deleted.msg": "Flow deleted failed",
"error.flow.duplicated.msg": "Flow duplicated failed"
}
2 changes: 1 addition & 1 deletion src/store/lib/w3bstream/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class ProjectManager {
this.wsPort = e.formData.port;
await this.connectWs();
if (!this.isWSConnect) {
toast.error('Connect VSCode extension Failed!');
toast.error(rootStore.lang.t("error.connect.vscode.msg"));
}
},
value: new JSONValue<SetVscodeSettingFormSchemaType>({
Expand Down
5 changes: 3 additions & 2 deletions src/store/lib/w3bstream/schema/chainHeight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { trpc } from '@/lib/trpc';
import { axios } from '@/lib/axios';
import toast from 'react-hot-toast';
import { defaultOutlineButtonStyle } from '@/lib/theme';
import { rootStore } from '@/store/index';

export const schema = {
definitions: {
Expand Down Expand Up @@ -75,9 +76,9 @@ export default class ChainHeightModule {
url: `/api/w3bapp/monitor/x/${projectName}/chain_height/${item.f_chain_height_id}`
});
eventBus.emit('chainHeight.delete');
toast.success('Deleted successfully');
toast.success(rootStore.lang.t('success.delete.msg'));
} catch (error) {
toast.error('Delete failed');
toast.error(rootStore.lang.t('error.delete.msg'));
}
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/store/lib/w3bstream/schema/chainTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { trpc } from '@/lib/trpc';
import { defaultOutlineButtonStyle } from '@/lib/theme';
import { axios } from '@/lib/axios';
import toast from 'react-hot-toast';
import { rootStore } from '@/store/index';

export const schema = {
definitions: {
Expand Down Expand Up @@ -77,7 +78,7 @@ export default class ChainTxModule {
eventBus.emit('chainTx.delete');
toast.success('Deleted successfully');
} catch (error) {
toast.error('Delete failed');
toast.error(rootStore.lang.t('error.delete.msg'));
}
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/store/lib/w3bstream/schema/contractLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { axios } from '@/lib/axios';
import toast from 'react-hot-toast';
import { defaultOutlineButtonStyle } from '@/lib/theme';
import { ethers } from 'ethers';
import { rootStore } from '@/store/index';

export const schema = {
definitions: {
Expand Down Expand Up @@ -87,7 +88,7 @@ export default class ContractLogModule {
eventBus.emit('contractlog.delete');
toast.success('Deleted successfully');
} catch (error) {
toast.error('Delete failed');
toast.error(rootStore.lang.t('error.delete.msg'));
}
}
});
Expand Down
5 changes: 3 additions & 2 deletions src/store/lib/w3bstream/schema/cronJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { axios } from '@/lib/axios';
import { eventBus } from '@/lib/event';
import toast from 'react-hot-toast';
import { PromiseState } from '@/store/standard/PromiseState';
import { rootStore } from '@/store/index';

export const schema = {
type: 'object',
Expand Down Expand Up @@ -42,9 +43,9 @@ export default class CronJobModule {
url: `/api/w3bapp/cronjob/data/${item.f_cron_job_id}`
});
eventBus.emit('cronJob.delete', item.f_project_id);
toast.success('Deleted successfully');
toast.success(rootStore.lang.t('success.delete.msg'));
} catch (error) {
toast.error('Delete failed');
toast.error(rootStore.lang.t('error.delete.msg'));
}
}
});
Expand Down
Loading