From 42325417cd6531c5a024fb550aca0af44d7bc19b Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 30 Dec 2024 17:46:53 +0100 Subject: [PATCH 01/41] adding i18n to contract verification --- apps/contract-verification/src/app/app.tsx | 27 ++- .../app/components/ContractAddressInput.tsx | 4 +- .../src/app/components/NavMenu.tsx | 14 +- .../src/app/layouts/Default.tsx | 4 +- .../tabs/locales/en/contractverification.json | 6 + .../tabs/locales/es/contractverification.json | 6 + .../tabs/locales/fr/contractverification.json | 6 + .../tabs/locales/it/contractverification.json | 6 + .../tabs/locales/ko/contractverification.json | 6 + .../tabs/locales/ru/contractverification.json | 6 + .../tabs/locales/zh/contractverification.json | 6 + apps/vyper/src/app/app.tsx | 194 +++++++++--------- 12 files changed, 173 insertions(+), 112 deletions(-) create mode 100644 apps/remix-ide/src/app/tabs/locales/en/contractverification.json create mode 100644 apps/remix-ide/src/app/tabs/locales/es/contractverification.json create mode 100644 apps/remix-ide/src/app/tabs/locales/fr/contractverification.json create mode 100644 apps/remix-ide/src/app/tabs/locales/it/contractverification.json create mode 100644 apps/remix-ide/src/app/tabs/locales/ko/contractverification.json create mode 100644 apps/remix-ide/src/app/tabs/locales/ru/contractverification.json create mode 100644 apps/remix-ide/src/app/tabs/locales/zh/contractverification.json diff --git a/apps/contract-verification/src/app/app.tsx b/apps/contract-verification/src/app/app.tsx index 0ea4332543d..85ebbfb19bc 100644 --- a/apps/contract-verification/src/app/app.tsx +++ b/apps/contract-verification/src/app/app.tsx @@ -13,6 +13,7 @@ import { CompilerAbstract } from '@remix-project/remix-solidity' import { useLocalStorage } from './hooks/useLocalStorage' import { getVerifier } from './Verifiers' import { ContractDropdownSelection } from './components/ContractDropdown' +import { IntlProvider } from 'react-intl' const plugin = new ContractVerificationPluginClient() @@ -32,11 +33,25 @@ const App = () => { const [proxyAddressError, setProxyAddressError] = useState('') const [abiEncodedConstructorArgs, setAbiEncodedConstructorArgs] = useState('') const [abiEncodingError, setAbiEncodingError] = useState('') + const [locale, setLocale] = useState<{ code: string; messages: any }>({ + code: 'en', + messages: {} + }) const timer = useRef(null) useEffect(() => { plugin.internalEvents.on('verification_activated', () => { + + // @ts-ignore + plugin.call('locale', 'currentLocale').then((locale: any) => { + setLocale(locale) + }) + + // @ts-ignore + plugin.on('locale', 'localeChanged', (locale: any) => { + setLocale(locale) + }) // Fetch compiler artefacts initially plugin.call('compilerArtefacts' as any, 'getAllCompilerAbstracts').then((obj: any) => { setCompilationOutput(obj) @@ -143,11 +158,13 @@ const App = () => { }, [submittedContracts]) return ( - - - - - + + + + + + + ) } diff --git a/apps/contract-verification/src/app/components/ContractAddressInput.tsx b/apps/contract-verification/src/app/components/ContractAddressInput.tsx index 5eb6e73d1e4..ef0af854b0d 100644 --- a/apps/contract-verification/src/app/components/ContractAddressInput.tsx +++ b/apps/contract-verification/src/app/components/ContractAddressInput.tsx @@ -2,11 +2,11 @@ import React, { useEffect, useState, useContext } from 'react' import { ethers } from 'ethers/' interface ContractAddressInputProps { - label: string + label: string | any id: string contractAddress: string setContractAddress: (address: string) => void - contractAddressError: string + contractAddressError: string | any setContractAddressError: (error: string) => void } diff --git a/apps/contract-verification/src/app/components/NavMenu.tsx b/apps/contract-verification/src/app/components/NavMenu.tsx index d835e1a193e..22e5199f5af 100644 --- a/apps/contract-verification/src/app/components/NavMenu.tsx +++ b/apps/contract-verification/src/app/components/NavMenu.tsx @@ -1,13 +1,15 @@ import React from 'react' import { NavLink } from 'react-router-dom' +import { useIntl, FormattedMessage } from 'react-intl' interface NavItemProps { to: string icon: JSX.Element - title: string + title: string | any } const NavItem: React.FC = ({ to, icon, title }) => { + const intl = useIntl() return ( = ({ to, icon, title }) => { export const NavMenu = () => { return ( -