patch en locale messages for terminal

pull/5370/head
drafish 1 year ago committed by Aniket
parent e68966e155
commit 25264e0334
  1. 28
      apps/remix-ide/src/app/tabs/locales/en/terminal.json
  2. 12
      libs/remix-ui/terminal/src/lib/components/RenderCall.tsx
  3. 11
      libs/remix-ui/terminal/src/lib/components/RenderKnownTransactions.tsx
  4. 11
      libs/remix-ui/terminal/src/lib/components/RenderUnknownTransactions.tsx
  5. 32
      libs/remix-ui/terminal/src/lib/components/Table.tsx
  6. 17
      libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

@ -13,5 +13,31 @@
"terminal.welcomeText7": "Select a Javascript file in the file explorer and then run `remix.execute()` or `remix.exeCurrent()` in the command line interface", "terminal.welcomeText7": "Select a Javascript file in the file explorer and then run `remix.execute()` or `remix.exeCurrent()` in the command line interface",
"terminal.welcomeText8": "Right click on a JavaScript file in the file explorer and then click `Run`", "terminal.welcomeText8": "Right click on a JavaScript file in the file explorer and then click `Run`",
"terminal.welcomeText9": "The following libraries are accessible", "terminal.welcomeText9": "The following libraries are accessible",
"terminal.welcomeText10": "Type the library name to see available commands" "terminal.welcomeText10": "Type the library name to see available commands",
"terminal.text1": "This type of command has been deprecated and is not functionning anymore. Please run remix.help() to list available commands.",
"terminal.hideTerminal": "Hide Terminal",
"terminal.showTerminal": "Show Terminal",
"terminal.clearConsole": "Clear console",
"terminal.pendingTransactions": "Pending Transactions",
"terminal.toasterMsg1": "no content to execute",
"terminal.toasterMsg2": "provider for path {fileName} not found",
"terminal.vmMode": "VM mode",
"terminal.vmModeMsg": "Cannot debug this call. Debugging calls is only possible in Remix VM mode.",
"terminal.ok": "Ok",
"terminal.cancel": "Cancel",
"terminal.callWarning": "(Cost only applies when called by a contract)",
"terminal.msg1": "Transaction mined but execution failed",
"terminal.msg2": "Transaction mined and execution succeed",
"terminal.msg3": "Status not available at the moment",
"terminal.status": "status",
"terminal.transactionHash": "transaction hash",
"terminal.blockHash": "block hash",
"terminal.blockNumber": "block number",
"terminal.contractAddress": "contract address",
"terminal.transactionCost": "transaction cost",
"terminal.executionCost": "execution cost",
"terminal.input": "input",
"terminal.decodedInput": "decoded input",
"terminal.decodedOutput": "decoded output",
"terminal.logs": "logs"
} }

@ -1,4 +1,5 @@
import React from 'react' // eslint-disable-line import React from 'react' // eslint-disable-line
import {FormattedMessage, useIntl} from 'react-intl'
import {shortenHexData} from '@remix-ui/helper' import {shortenHexData} from '@remix-ui/helper'
import CheckTxStatus from './ChechTxStatus' // eslint-disable-line import CheckTxStatus from './ChechTxStatus' // eslint-disable-line
import showTable from './Table' import showTable from './Table'
@ -7,6 +8,7 @@ import {execution} from '@remix-project/remix-lib'
const typeConversion = execution.typeConversion const typeConversion = execution.typeConversion
const RenderCall = ({tx, resolvedData, logs, index, plugin, showTableHash, txDetails, modal}) => { const RenderCall = ({tx, resolvedData, logs, index, plugin, showTableHash, txDetails, modal}) => {
const intl = useIntl()
const to = resolvedData.contractName + '.' + resolvedData.fn const to = resolvedData.contractName + '.' + resolvedData.fn
const from = tx.from ? tx.from : ' - ' const from = tx.from ? tx.from : ' - '
const input = tx.input ? shortenHexData(tx.input) : '' const input = tx.input ? shortenHexData(tx.input) : ''
@ -16,12 +18,12 @@ const RenderCall = ({tx, resolvedData, logs, index, plugin, showTableHash, txDet
event.stopPropagation() event.stopPropagation()
if (tx.isCall && !tx.envMode.startsWith('vm')) { if (tx.isCall && !tx.envMode.startsWith('vm')) {
modal( modal(
'VM mode', intl.formatMessage({id: 'terminal.vmMode'}),
'Cannot debug this call. Debugging calls is only possible in Remix VM mode.', intl.formatMessage({id: 'terminal.vmModeMsg'}),
'Ok', intl.formatMessage({id: 'terminal.ok'}),
false, false,
() => {}, () => {},
'Cancel', intl.formatMessage({id: 'terminal.cancel'}),
() => {} () => {}
) )
} else { } else {
@ -47,7 +49,7 @@ const RenderCall = ({tx, resolvedData, logs, index, plugin, showTableHash, txDet
</span> </span>
<div className="remix_ui_terminal_buttons"> <div className="remix_ui_terminal_buttons">
<div className="remix_ui_terminal_debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}> <div className="remix_ui_terminal_debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}>
Debug <FormattedMessage id="terminal.debug" />
</div> </div>
</div> </div>
<i className={`remix_ui_terminal_arrow fas ${showTableHash.includes(tx.hash) ? 'fa-angle-up' : 'fa-angle-down'}`}></i> <i className={`remix_ui_terminal_arrow fas ${showTableHash.includes(tx.hash) ? 'fa-angle-up' : 'fa-angle-down'}`}></i>

@ -1,5 +1,5 @@
import React from 'react' // eslint-disable-line import React from 'react' // eslint-disable-line
import {FormattedMessage} from 'react-intl' import {FormattedMessage, useIntl} from 'react-intl'
import CheckTxStatus from './ChechTxStatus' // eslint-disable-line import CheckTxStatus from './ChechTxStatus' // eslint-disable-line
import Context from './Context' // eslint-disable-line import Context from './Context' // eslint-disable-line
import showTable from './Table' import showTable from './Table'
@ -7,16 +7,17 @@ import {execution} from '@remix-project/remix-lib'
const typeConversion = execution.typeConversion const typeConversion = execution.typeConversion
const RenderKnownTransactions = ({tx, receipt, resolvedData, logs, index, plugin, showTableHash, txDetails, modal, provider}) => { const RenderKnownTransactions = ({tx, receipt, resolvedData, logs, index, plugin, showTableHash, txDetails, modal, provider}) => {
const intl = useIntl()
const debug = (event, tx) => { const debug = (event, tx) => {
event.stopPropagation() event.stopPropagation()
if (tx.isCall && !tx.envMode.startsWith('vm')) { if (tx.isCall && !tx.envMode.startsWith('vm')) {
modal( modal(
'VM mode', intl.formatMessage({id: 'terminal.vmMode'}),
'Cannot debug this call. Debugging calls is only possible in Remix VM mode.', intl.formatMessage({id: 'terminal.vmModeMsg'}),
'Ok', intl.formatMessage({id: 'terminal.ok'}),
false, false,
() => {}, () => {},
'Cancel', intl.formatMessage({id: 'terminal.cancel'}),
() => {} () => {}
) )
} else { } else {

@ -1,20 +1,21 @@
import React, {useState} from 'react' // eslint-disable-line import React, {useState} from 'react' // eslint-disable-line
import {FormattedMessage} from 'react-intl' import {FormattedMessage, useIntl} from 'react-intl'
import CheckTxStatus from './ChechTxStatus' // eslint-disable-line import CheckTxStatus from './ChechTxStatus' // eslint-disable-line
import Context from './Context' // eslint-disable-line import Context from './Context' // eslint-disable-line
import showTable from './Table' import showTable from './Table'
const RenderUnKnownTransactions = ({tx, receipt, index, plugin, showTableHash, txDetails, modal, provider}) => { const RenderUnKnownTransactions = ({tx, receipt, index, plugin, showTableHash, txDetails, modal, provider}) => {
const intl = useIntl()
const debug = (event, tx) => { const debug = (event, tx) => {
event.stopPropagation() event.stopPropagation()
if (tx.isCall && !tx.envMode.startsWith('vm')) { if (tx.isCall && !tx.envMode.startsWith('vm')) {
modal( modal(
'VM mode', intl.formatMessage({id: 'terminal.vmMode'}),
'Cannot debug this call. Debugging calls is only possible in Remix VM mode.', intl.formatMessage({id: 'terminal.vmModeMsg'}),
'Ok', intl.formatMessage({id: 'terminal.ok'}),
false, false,
() => {}, () => {},
'Cancel', intl.formatMessage({id: 'terminal.cancel'}),
() => {} () => {}
) )
} else { } else {

@ -1,10 +1,12 @@
import React from 'react' // eslint-disable-line import React from 'react' // eslint-disable-line
import {FormattedMessage, useIntl} from 'react-intl'
import {CopyToClipboard} from '@remix-ui/clipboard' // eslint-disable-line import {CopyToClipboard} from '@remix-ui/clipboard' // eslint-disable-line
import {shortenHexData} from '@remix-ui/helper' import {shortenHexData} from '@remix-ui/helper'
import {execution} from '@remix-project/remix-lib' import {execution} from '@remix-project/remix-lib'
const typeConversion = execution.typeConversion const typeConversion = execution.typeConversion
const showTable = (opts, showTableHash) => { const showTable = (opts, showTableHash) => {
const intl = useIntl()
let msg = '' let msg = ''
let toHash let toHash
const data = opts.data // opts.data = data.tx const data = opts.data // opts.data = data.tx
@ -15,17 +17,17 @@ const showTable = (opts, showTableHash) => {
} }
let callWarning = '' let callWarning = ''
if (opts.isCall) { if (opts.isCall) {
callWarning = '(Cost only applies when called by a contract)' callWarning = intl.formatMessage({id: 'terminal.callWarning'})
} }
if (!opts.isCall) { if (!opts.isCall) {
if (opts.status !== undefined && opts.status !== null) { if (opts.status !== undefined && opts.status !== null) {
if (opts.status === 0 || opts.status === '0x0' || opts.status === false) { if (opts.status === 0 || opts.status === '0x0' || opts.status === false) {
msg = 'Transaction mined but execution failed' msg = intl.formatMessage({id: 'terminal.msg1'})
} else if (opts.status === 1 || opts.status === '0x1' || opts.status === true) { } else if (opts.status === 1 || opts.status === '0x1' || opts.status === true) {
msg = 'Transaction mined and execution succeed' msg = intl.formatMessage({id: 'terminal.msg2'})
} }
} else { } else {
msg = 'Status not available at the moment' msg = intl.formatMessage({id: 'terminal.msg3'})
} }
} }
@ -40,7 +42,7 @@ const showTable = (opts, showTableHash) => {
{opts.status !== undefined ? ( {opts.status !== undefined ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
status <FormattedMessage id="terminal.status" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableStatus${opts.hash}`} data-shared={`pair_${opts.hash}`}>{`${opts.status} ${msg}`}</td> <td className="remix_ui_terminal_td" data-id={`txLoggerTableStatus${opts.hash}`} data-shared={`pair_${opts.hash}`}>{`${opts.status} ${msg}`}</td>
</tr> </tr>
@ -48,7 +50,7 @@ const showTable = (opts, showTableHash) => {
{opts.hash && !opts.isCall ? ( {opts.hash && !opts.isCall ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
transaction hash <FormattedMessage id="terminal.transactionHash" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{opts.hash} {opts.hash}
@ -59,7 +61,7 @@ const showTable = (opts, showTableHash) => {
{opts.blockHash ? ( {opts.blockHash ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
block hash <FormattedMessage id="terminal.blockHash" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableContractAddress${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableContractAddress${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{opts.blockHash} {opts.blockHash}
@ -70,7 +72,7 @@ const showTable = (opts, showTableHash) => {
{opts.blockNumber ? ( {opts.blockNumber ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
block number <FormattedMessage id="terminal.blockNumber" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableContractAddress${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableContractAddress${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{opts.blockNumber} {opts.blockNumber}
@ -81,7 +83,7 @@ const showTable = (opts, showTableHash) => {
{opts.contractAddress ? ( {opts.contractAddress ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
contract address <FormattedMessage id="terminal.contractAddress" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableContractAddress${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableContractAddress${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{opts.contractAddress} {opts.contractAddress}
@ -125,7 +127,7 @@ const showTable = (opts, showTableHash) => {
{opts.transactionCost ? ( {opts.transactionCost ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
transaction cost <FormattedMessage id="terminal.transactionCost" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableTransactionCost${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableTransactionCost${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{opts.transactionCost} gas {callWarning} {opts.transactionCost} gas {callWarning}
@ -136,7 +138,7 @@ const showTable = (opts, showTableHash) => {
{opts.executionCost ? ( {opts.executionCost ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
execution cost <FormattedMessage id="terminal.executionCost" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableExecutionHash${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableExecutionHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{opts.executionCost} gas {callWarning} {opts.executionCost} gas {callWarning}
@ -147,7 +149,7 @@ const showTable = (opts, showTableHash) => {
{opts.input ? ( {opts.input ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
input <FormattedMessage id="terminal.input" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{shortenHexData(opts.input)} {shortenHexData(opts.input)}
@ -158,7 +160,7 @@ const showTable = (opts, showTableHash) => {
{opts['decoded input'] ? ( {opts['decoded input'] ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
decoded input <FormattedMessage id="terminal.decodedInput" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{opts['decoded input'].trim()} {opts['decoded input'].trim()}
@ -169,7 +171,7 @@ const showTable = (opts, showTableHash) => {
{opts['decoded output'] ? ( {opts['decoded output'] ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
decoded output <FormattedMessage id="terminal.decodedOutput" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{opts['decoded output']} {opts['decoded output']}
@ -180,7 +182,7 @@ const showTable = (opts, showTableHash) => {
{opts.logs ? ( {opts.logs ? (
<tr className="remix_ui_terminal_tr"> <tr className="remix_ui_terminal_tr">
<td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}> <td className="remix_ui_terminal_td" data-shared={`key_${opts.hash}`}>
logs <FormattedMessage id="terminal.logs" />
</td> </td>
<td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}> <td className="remix_ui_terminal_td" data-id={`txLoggerTableHash${opts.hash}`} data-shared={`pair_${opts.hash}`}>
{JSON.stringify(stringified, null, '\t')} {JSON.stringify(stringified, null, '\t')}

@ -199,7 +199,7 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
const _shell = async (script, scopedCommands, done) => { const _shell = async (script, scopedCommands, done) => {
// default shell // default shell
if (script.indexOf('remix:') === 0) { if (script.indexOf('remix:') === 0) {
return done(null, 'This type of command has been deprecated and is not functionning anymore. Please run remix.help() to list available commands.') return done(null, intl.formatMessage({id: 'terminal.text1'}))
} }
if (script.indexOf('remix.') === 0) { if (script.indexOf('remix.') === 0) {
// we keep the old feature. This will basically only be called when the command is querying the "remix" object. // we keep the old feature. This will basically only be called when the command is querying the "remix" object.
@ -577,7 +577,12 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
<div style={{ flexGrow: 1 }} className="remix_ui_terminal_panel" ref={panelRef}> <div style={{ flexGrow: 1 }} className="remix_ui_terminal_panel" ref={panelRef}>
<div className="remix_ui_terminal_bar d-flex"> <div className="remix_ui_terminal_bar d-flex">
<div className="remix_ui_terminal_menu d-flex w-100 align-items-center position-relative border-top border-dark bg-light" ref={terminalMenu} data-id="terminalToggleMenu"> <div className="remix_ui_terminal_menu d-flex w-100 align-items-center position-relative border-top border-dark bg-light" ref={terminalMenu} data-id="terminalToggleMenu">
<CustomTooltip placement="top" tooltipId="terminalToggle" tooltipClasses="text-nowrap" tooltipText={isOpen ? 'Hide Terminal' : 'Show Terminal'}> <CustomTooltip
placement="top"
tooltipId="terminalToggle"
tooltipClasses="text-nowrap"
tooltipText={isOpen ? <FormattedMessage id="terminal.hideTerminal" /> : <FormattedMessage id="terminal.showTerminal" />}
>
<i <i
className={`mx-2 remix_ui_terminal_toggleTerminal fas ${isOpen ? 'fa-angle-double-down' : 'fa-angle-double-up'}`} className={`mx-2 remix_ui_terminal_toggleTerminal fas ${isOpen ? 'fa-angle-double-down' : 'fa-angle-double-up'}`}
data-id="terminalToggleIcon" data-id="terminalToggleIcon"
@ -585,11 +590,11 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
></i> ></i>
</CustomTooltip> </CustomTooltip>
<div className="mx-2 remix_ui_terminal_console" id="clearConsole" data-id="terminalClearConsole" onClick={handleClearConsole}> <div className="mx-2 remix_ui_terminal_console" id="clearConsole" data-id="terminalClearConsole" onClick={handleClearConsole}>
<CustomTooltip placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" tooltipText="Clear console"> <CustomTooltip placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="terminal.clearConsole" />}>
<i className="fas fa-ban" aria-hidden="true"></i> <i className="fas fa-ban" aria-hidden="true"></i>
</CustomTooltip> </CustomTooltip>
</div> </div>
<CustomTooltip placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" tooltipText="Pending Transactions"> <CustomTooltip placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="terminal.pendingTransactions" />}>
<div className="mx-2">0</div> <div className="mx-2">0</div>
</CustomTooltip> </CustomTooltip>
<div className="h-80 mx-3 align-items-center remix_ui_terminal_listenOnNetwork custom-control custom-checkbox"> <div className="h-80 mx-3 align-items-center remix_ui_terminal_listenOnNetwork custom-control custom-checkbox">
@ -789,8 +794,8 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
cancelFn={modalState.cancelFn} cancelFn={modalState.cancelFn}
handleHide={handleHideModal} handleHide={handleHideModal}
/> />
{toaster && <Toaster message="no content to execute" />} {toaster && <Toaster message={intl.formatMessage({id: 'terminal.toasterMsg1'})} />}
{toastProvider.show && <Toaster message={`provider for path ${toastProvider.fileName} not found`} />} {toastProvider.show && <Toaster message={intl.formatMessage({id: 'terminal.toasterMsg2'}, {fileName: toastProvider.fileName})} />}
</div> </div>
) )
} }

Loading…
Cancel
Save