From afe5594de5db61682b015f6cef753760c418315d Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 9 Oct 2024 14:31:35 +0200 Subject: [PATCH] use locale and common Renderer --- apps/vyper/src/app/app.tsx | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/apps/vyper/src/app/app.tsx b/apps/vyper/src/app/app.tsx index 49faf7b396..77373553b3 100644 --- a/apps/vyper/src/app/app.tsx +++ b/apps/vyper/src/app/app.tsx @@ -1,5 +1,6 @@ import { useState, useEffect, useRef } from 'react' - +import { IntlProvider } from 'react-intl' +import { Renderer } from '@remix-ui/renderer' import { remixClient } from './utils' import { CompilationResult } from '@remixproject/plugin-api' @@ -15,7 +16,7 @@ import { CustomTooltip } from '@remix-ui/helper' import { Form } from 'react-bootstrap' import { CompileErrorCard } from './components/CompileErrorCard' import CustomAccordionToggle from './components/CustomAccordionToggle' -import { VyperCompilationResultWrapper, VyperCompilationErrorsWrapper } from './utils/types' +import { VyperCompilationResultWrapper, VyperCompilationErrorsWrapper, VyperCompilationError } from './utils/types' interface AppState { status: 'idle' | 'inProgress' @@ -25,6 +26,10 @@ interface AppState { } const App = () => { + const [locale, setLocale] = useState<{code: string; messages: any}>({ + code: 'en', + messages: null + }) const [contract, setContract] = useState() const [output, setOutput] = useState(remixClient.compilerOutput) const [state, setState] = useState({ @@ -73,6 +78,15 @@ const App = () => { setOutput(payload) }) + remixClient.call('locale' as any, 'currentLocale').then((currentLocale) => { + setLocale(currentLocale) + }) + + + remixClient.on('locale' as any, 'localeChanged', (locale: any) => { + setLocale(locale) + }) + return () => { remixClient.eventEmitter.off('setOutput', (payload) => { setOutput(payload) @@ -100,6 +114,7 @@ const App = () => { const [cloneCount, setCloneCount] = useState(0) return ( +
@@ -162,13 +177,25 @@ const App = () => { } {output && output.status === 'failed' && - output.errors && output.errors.map((error) => { - return + output.errors && output.errors.map((error: VyperCompilationError, index: number) => { + return }) }
+
) }