add solidity localeMessage

pull/2579/head
drafish 3 years ago
parent 2a2dc07e44
commit 368cd12f85
  1. 35
      apps/remix-ide/src/app/tabs/locales/en-US.js
  2. 37
      apps/remix-ide/src/app/tabs/locales/zh-CN.js
  3. 86
      libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
  4. 11
      libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx

@ -57,9 +57,9 @@ export default {
'terminal.listen': 'listen on all transactions',
'terminal.search': 'Search with transaction hash or address',
'terminal.used': 'used',
'terminal.welcomeText1': 'Welcome to',
'terminal.welcomeText2': 'Your files are stored in',
'terminal.used': 'used',
'terminal.welcomeText3': 'You can use this terminal to',
'terminal.welcomeText4': 'Check transactions details and start debugging',
'terminal.welcomeText5': 'Execute JavaScript scripts',
@ -87,6 +87,39 @@ export default {
'search.filesToExclude': 'Files to exclude',
'solidity.displayName': 'Solidity compiler',
'solidity.compiler': 'Compiler',
'solidity.addACustomCompiler': 'Add a custom compiler',
'solidity.addACustomCompilerWithURL': 'Add a custom compiler with URL',
'solidity.includeNightlyBuilds': 'Include nightly builds',
'solidity.autoCompile': 'Auto compile',
'solidity.hideWarnings': 'Hide warnings',
'solidity.enableHardhat': 'Enable Hardhat Compilation',
'solidity.learnHardhat': 'Learn how to use Hardhat Compilation',
'solidity.enableTruffle': 'Enable Truffle Compilation',
'solidity.learnTruffle': 'Learn how to use Truffle Compilation',
'solidity.advancedConfigurations': 'Advanced Configurations',
'solidity.compilerConfiguration': 'Compiler configuration',
'solidity.compilationDetails': 'Compilation Details',
'solidity.language': 'Language',
'solidity.evmVersion': 'EVM Version',
'solidity.enableOptimization': 'Enable optimization',
'solidity.useConfigurationFile': 'Use configuration file',
'solidity.change': 'Change',
'solidity.compile': 'Compile',
'solidity.compileAndRunScript': 'Compile and Run script',
'solidity.publishOn': 'Publish on',
'solidity.Assembly': 'Assembly opcodes describing the contract including corresponding solidity source code',
'solidity.Opcodes': 'Assembly opcodes describing the contract',
'solidity.name': 'Name of the compiled contract',
'solidity.metadata': 'Contains all informations related to the compilation',
'solidity.bytecode': 'Bytecode being executed during contract creation',
'solidity.abi': 'ABI: describing all the functions (input/output params, scope, ...)',
'solidity.web3Deploy': 'Copy/paste this code to any JavaScript/Web3 console to deploy this contract',
'solidity.metadataHash': 'Hash representing all metadata information',
'solidity.functionHashes': 'List of declared function and their corresponding hash',
'solidity.gasEstimates': 'Gas estimation for each function call',
'solidity.Runtime Bytecode': 'Bytecode storing the state and being executed during normal contract call',
'solidity.swarmLocation': 'Swarm url where all metadata information can be found (contract needs to be published first)',
'pluginManager.displayName': 'Plugin manager',
'pluginManager.activate': 'Activate',

@ -57,9 +57,9 @@ export default {
'terminal.listen': '监听所有交易',
'terminal.search': '按交易哈希或地址搜索',
'terminal.used': '已使用',
'terminal.welcomeText1': '欢迎使用',
'terminal.welcomeText2': '您的文件储存在',
'terminal.used': '已使用',
'terminal.welcomeText3': '您可使用此终端',
'terminal.welcomeText4': '查看交易详情并启动调试',
'terminal.welcomeText5': '执行 JavaScript 脚本',
@ -86,7 +86,40 @@ export default {
'search.filesToInclude': '文件包含',
'search.filesToExclude': '文件排除',
'solidity.displayName': '合约编译',
'solidity.displayName': 'Solidity 编译器',
'solidity.compiler': '编译器',
'solidity.addACustomCompiler': '添加一个自定义编译器',
'solidity.addACustomCompilerWithURL': '通过URL添加一个自定义编译器',
'solidity.includeNightlyBuilds': '包含每日构造版本',
'solidity.autoCompile': '自动编译',
'solidity.hideWarnings': '隐藏警告',
'solidity.enableHardhat': '启用 Hardhat 编译',
'solidity.learnHardhat': '学习怎么使用 Hardhat 编译',
'solidity.enableTruffle': '启用 Truffle 编译',
'solidity.learnTruffle': '学习怎么使用 Truffle 编译',
'solidity.advancedConfigurations': '高级配置',
'solidity.compilerConfiguration': '编译器配置',
'solidity.compilationDetails': '编译详情',
'solidity.language': '语言',
'solidity.evmVersion': 'EVM 版本',
'solidity.enableOptimization': '启用优化',
'solidity.useConfigurationFile': '使用配置文件',
'solidity.change': '修改',
'solidity.compile': '编译',
'solidity.compileAndRunScript': '编译且执行脚本',
'solidity.publishOn': '发布到',
'solidity.Assembly': '合约的汇编操作码,包含对应的solidity源程序',
'solidity.Opcodes': '合约的汇编操作码',
'solidity.name': '已编译合约的名称',
'solidity.metadata': '包含编译相关的全部信息',
'solidity.bytecode': '合约创建时执行的字节码',
'solidity.abi': 'ABI: 全部合约函数的描述 (输入/输出 参数, 作用域, ...)',
'solidity.web3Deploy': '拷贝/粘贴这部分代码到任何 JavaScript/Web3 控制台都可以部署此合约',
'solidity.metadataHash': '元数据的哈希值',
'solidity.functionHashes': '合约定义的函数清单,包含对应的哈希',
'solidity.gasEstimates': '每个函数调用的Gas估算值',
'solidity.Runtime Bytecode': '用于保存状态并在合约调用期执行的字节码',
'solidity.swarmLocation': '可以找到所有元数据信息的Swarm url (首先需要发布合约) ',
'pluginManager.displayName': '插件管理',
'pluginManager.activate': '激活',

@ -1,4 +1,5 @@
import React, { useEffect, useState, useRef, useReducer } from 'react' // eslint-disable-line
import { FormattedMessage, useIntl } from 'react-intl'
import semver from 'semver'
import { CompilerContainerProps } from './types'
import { ConfigurationSettings } from '@remix-project/remix-lib-ts'
@ -66,6 +67,8 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const [truffleCompilation, setTruffleCompilation] = useState(false)
const [compilerContainer, dispatch] = useReducer(compilerReducer, compilerInitialState)
const intl = useIntl()
useEffect(() => {
if (workspaceName) {
api.setAppParameter('configFilePath', defaultPath)
@ -525,7 +528,17 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
const promptCompiler = () => {
// custom url https://solidity-blog.s3.eu-central-1.amazonaws.com/data/08preview/soljson.js
modal('Add a custom compiler', promptMessage('URL'), 'OK', addCustomCompiler, 'Cancel', () => {})
modal(
intl.formatMessage({
id: 'solidity.addACustomCompiler',
defaultMessage: 'Add a custom compiler',
}),
promptMessage('URL'),
'OK',
addCustomCompiler,
'Cancel',
() => {}
)
}
const promptMessage = (message) => {
@ -676,8 +689,15 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<div className='pt-0 remixui_compilerSection'>
<div className="mb-1">
<label className="remixui_compilerLabel form-check-label" htmlFor="versionSelector">
Compiler
<button className="far fa-plus btn-light border-0 p-0 mx-2 btn-sm" onClick={promptCompiler} title="Add a custom compiler with URL"></button>
<FormattedMessage id='solidity.compiler' defaultMessage='Compiler' />
<button
className="far fa-plus btn-light border-0 p-0 mx-2 btn-sm"
onClick={promptCompiler}
title={intl.formatMessage({
id: 'solidity.addACustomCompilerWithURL',
defaultMessage: "Add a custom compiler with URL",
})}>
</button>
</label>
<select value={ state.selectedVersion || state.defaultVersion } onChange={(e) => handleLoadVersion(e.target.value) } className="custom-select" id="versionSelector" disabled={state.allversions.length <= 0}>
{ state.allversions.length <= 0 && <option disabled data-id={state.selectedVersion === state.defaultVersion ? 'selected' : ''}>{ state.defaultVersion }</option> }
@ -693,25 +713,35 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
</div>
<div className="mb-2 flex-row-reverse remixui_nightlyBuilds custom-control custom-checkbox">
<input className="mr-2 custom-control-input" id="nightlies" type="checkbox" onChange={handleNightliesChange} checked={state.includeNightlies} />
<label htmlFor="nightlies" data-id="compilerNightliesBuild" className="form-check-label custom-control-label">Include nightly builds</label>
<label htmlFor="nightlies" data-id="compilerNightliesBuild" className="form-check-label custom-control-label">
<FormattedMessage id='solidity.includeNightlyBuilds' defaultMessage='Include nightly builds' />
</label>
</div>
<div className="mt-2 remixui_compilerConfig custom-control custom-checkbox">
<input className="remixui_autocompile custom-control-input" type="checkbox" onChange={handleAutoCompile} data-id="compilerContainerAutoCompile" id="autoCompile" title="Auto compile" checked={state.autoCompile} />
<label className="form-check-label custom-control-label" htmlFor="autoCompile">Auto compile</label>
<label className="form-check-label custom-control-label" htmlFor="autoCompile">
<FormattedMessage id='solidity.autoCompile' defaultMessage='Auto compile' />
</label>
</div>
<div className="mt-1 mb-2 remixui_compilerConfig custom-control custom-checkbox">
<input className="remixui_autocompile custom-control-input" onChange={handleHideWarningsChange} id="hideWarningsBox" type="checkbox" title="Hide warnings" checked={state.hideWarnings} />
<label className="form-check-label custom-control-label" htmlFor="hideWarningsBox">Hide warnings</label>
<label className="form-check-label custom-control-label" htmlFor="hideWarningsBox">
<FormattedMessage id='solidity.hideWarnings' defaultMessage='Hide warnings' />
</label>
</div>
{
isHardhatProject &&
<div className="mt-3 remixui_compilerConfig custom-control custom-checkbox">
<input className="remixui_autocompile custom-control-input" onChange={updatehhCompilation} id="enableHardhat" type="checkbox" title="Enable Hardhat Compilation" checked={hhCompilation} />
<label className="form-check-label custom-control-label" htmlFor="enableHardhat">Enable Hardhat Compilation</label>
<label className="form-check-label custom-control-label" htmlFor="enableHardhat">
<FormattedMessage id='solidity.enableHardhat' defaultMessage='Enable Hardhat Compilation' />
</label>
<a className="mt-1 text-nowrap" href='https://remix-ide.readthedocs.io/en/latest/hardhat.html#enable-hardhat-compilation' target={'_blank'}>
<OverlayTrigger placement={'right'} overlay={
<Tooltip className="text-nowrap" id="overlay-tooltip-hardhat">
<span className="p-1 pr-3" style={{ backgroundColor: 'black', minWidth: '230px' }}>Learn how to use Hardhat Compilation</span>
<span className="p-1 pr-3" style={{ backgroundColor: 'black', minWidth: '230px' }}>
<FormattedMessage id='solidity.learnHardhat' defaultMessage='Learn how to use Hardhat Compilation' />
</span>
</Tooltip>
}>
<i style={{ fontSize: 'medium' }} className={'ml-2 fal fa-info-circle'} aria-hidden="true"></i>
@ -723,11 +753,15 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
isTruffleProject &&
<div className="mt-3 remixui_compilerConfig custom-control custom-checkbox">
<input className="remixui_autocompile custom-control-input" onChange={updateTruffleCompilation} id="enableTruffle" type="checkbox" title="Enable Truffle Compilation" checked={truffleCompilation} />
<label className="form-check-label custom-control-label" htmlFor="enableTruffle">Enable Truffle Compilation</label>
<label className="form-check-label custom-control-label" htmlFor="enableTruffle">
<FormattedMessage id='solidity.enableTruffle' defaultMessage='Enable Truffle Compilation' />
</label>
<a className="mt-1 text-nowrap" href='https://remix-ide.readthedocs.io/en/latest/truffle.html#enable-truffle-compilation' target={'_blank'}>
<OverlayTrigger placement={'right'} overlay={
<Tooltip className="text-nowrap" id="overlay-tooltip-truffle">
<span className="p-1 pr-3" style={{ backgroundColor: 'black', minWidth: '230px' }}>Learn how to use Truffle Compilation</span>
<span className="p-1 pr-3" style={{ backgroundColor: 'black', minWidth: '230px' }}>
<FormattedMessage id='solidity.learnTruffle' defaultMessage='Learn how to use Truffle Compilation' />
</span>
</Tooltip>
}>
<i style={{ fontSize: 'medium' }} className={'ml-2 fal fa-info-circle'} aria-hidden="true"></i>
@ -738,7 +772,9 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
</div>
<div className="d-flex px-4 remixui_compilerConfigSection justify-content-between" onClick={toggleConfigurations}>
<div className="d-flex">
<label className="mt-1 remixui_compilerConfigSection">Advanced Configurations</label>
<label className="mt-1 remixui_compilerConfigSection">
<FormattedMessage id='solidity.advancedConfigurations' defaultMessage='Advanced Configurations' />
</label>
</div>
<div>
<span data-id='scConfigExpander' onClick={toggleConfigurations}>
@ -749,18 +785,24 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<div className={`px-4 pb-4 border-bottom flex-column ${toggleExpander ? "d-flex" : "d-none"}`}>
<div className="d-flex pb-1 remixui_compilerConfig custom-control custom-radio">
<input className="custom-control-input" type="radio" name="configradio" value="manual" onChange={toggleConfigType} checked={!state.useFileConfiguration} id="scManualConfig" />
<label className="form-check-label custom-control-label" htmlFor="scManualConfig">Compiler configuration</label>
<label className="form-check-label custom-control-label" htmlFor="scManualConfig">
<FormattedMessage id='solidity.compilerConfiguration' defaultMessage='Compiler configuration' />
</label>
</div>
<div className={`flex-column 'd-flex'}`}>
<div className="mb-2 ml-4">
<label className="remixui_compilerLabel form-check-label" htmlFor="compilierLanguageSelector">Language</label>
<label className="remixui_compilerLabel form-check-label" htmlFor="compilierLanguageSelector">
<FormattedMessage id='solidity.language' defaultMessage='Language' />
</label>
<select onChange={(e) => handleLanguageChange(e.target.value)} disabled={state.useFileConfiguration} value={state.language} className="custom-select" id="compilierLanguageSelector" title="Available since v0.5.7">
<option data-id={state.language === 'Solidity' ? 'selected' : ''} value='Solidity'>Solidity</option>
<option data-id={state.language === 'Yul' ? 'selected' : ''} value='Yul'>Yul</option>
</select>
</div>
<div className="mb-2 ml-4">
<label className="remixui_compilerLabel form-check-label" htmlFor="evmVersionSelector">EVM Version</label>
<label className="remixui_compilerLabel form-check-label" htmlFor="evmVersionSelector">
<FormattedMessage id='solidity.evmVersion' defaultMessage='EVM Version' />
</label>
<select value={state.evmVersion} onChange={(e) => handleEvmVersionChange(e.target.value)} disabled={state.useFileConfiguration} className="custom-select" id="evmVersionSelector">
{compileTabLogic.evmVersions.map((version, index) => (<option key={index} data-id={state.evmVersion === version ? 'selected' : ''} value={version}>{version}</option>))}
</select>
@ -768,7 +810,9 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
<div className="mt-1 mt-3 border-dark pb-3 ml-4 remixui_compilerConfig custom-control custom-checkbox">
<div className="justify-content-between align-items-center d-flex">
<input onChange={(e) => { handleOptimizeChange(e.target.checked) }} disabled={state.useFileConfiguration} className="custom-control-input" id="optimize" type="checkbox" checked={state.optimize} />
<label className="form-check-label custom-control-label" htmlFor="optimize">Enable optimization</label>
<label className="form-check-label custom-control-label" htmlFor="optimize">
<FormattedMessage id='solidity.enableOptimization' defaultMessage='Enable optimization' />
</label>
<input
min="1"
className="custom-select ml-2 remixui_runs"
@ -785,7 +829,9 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
</div>
<div className="d-flex pb-1 remixui_compilerConfig custom-control custom-radio">
<input className="custom-control-input" type="radio" name="configradio" value="file" onChange={toggleConfigType} checked={state.useFileConfiguration} id="scFileConfig" />
<label className="form-check-label custom-control-label" htmlFor="scFileConfig" data-id="scFileConfiguration">Use configuration file</label>
<label className="form-check-label custom-control-label" htmlFor="scFileConfig" data-id="scFileConfiguration">
<FormattedMessage id='solidity.useConfigurationFile' defaultMessage='Use configuration file' />
</label>
</div>
<div className={`pt-2 ml-4 ml-2 align-items-start justify-content-between d-flex`}>
{ (!showFilePathInput && state.useFileConfiguration) && <span
@ -807,7 +853,9 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
}
}}
/>
{ !showFilePathInput && <button disabled={!state.useFileConfiguration} data-id="scConfigChangeFilePath" className="btn-secondary" onClick={() => {setShowFilePathInput(true)}}>Change</button> }
{ !showFilePathInput && <button disabled={!state.useFileConfiguration} data-id="scConfigChangeFilePath" className="btn-secondary" onClick={() => {setShowFilePathInput(true)}}>
<FormattedMessage id='solidity.change' defaultMessage='Change' />
</button> }
</div>
</div>
<div className="px-4">
@ -822,7 +870,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
}>
<span>
{ <i ref={compileIcon} className="fas fa-sync remixui_iconbtn" aria-hidden="true"></i> }
Compile { typeof state.compiledFileName === 'string' ? extractNameFromKey(state.compiledFileName) || '<no file selected>' : '<no file selected>' }
<FormattedMessage id='solidity.compile' defaultMessage='Compile' /> { typeof state.compiledFileName === 'string' ? extractNameFromKey(state.compiledFileName) || '<no file selected>' : '<no file selected>' }
</span>
</OverlayTrigger>
</button>
@ -837,7 +885,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
</Tooltip>
}>
<span>
Compile and Run script
<FormattedMessage id='solidity.compileAndRunScript' defaultMessage='Compile and Run script' />
</span>
</OverlayTrigger>
</button>

@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react' // eslint-disable-line
import { FormattedMessage, useIntl } from 'react-intl'
import { ContractSelectionProps } from './types'
import { PublishToStorage } from '@remix-ui/publish-to-storage' // eslint-disable-line
import { TreeView, TreeViewItem } from '@remix-ui/tree-view' // eslint-disable-line
@ -11,6 +12,8 @@ export const ContractSelection = (props: ContractSelectionProps) => {
const [selectedContract, setSelectedContract] = useState('')
const [storage, setStorage] = useState(null)
const intl = useIntl()
useEffect(() => {
if (contractList.length) setSelectedContract(contractList[0].name)
}, [contractList])
@ -152,7 +155,7 @@ export const ContractSelection = (props: ContractSelectionProps) => {
{
Object.keys(contractProperties).map((propertyName, index) => {
const copyDetails = <span className="remixui_copyDetails"><CopyToClipboard content={contractProperties[propertyName]} direction='top' /></span>
const questionMark = <span className="remixui_questionMark"><i title={ help[propertyName] } className="fas fa-question-circle" aria-hidden="true"></i></span>
const questionMark = <span className="remixui_questionMark"><i title={ intl.formatMessage({id: `solidity.${propertyName}`, defaultMessage: help[propertyName]}) } className="fas fa-question-circle" aria-hidden="true"></i></span>
return (
<div className="remixui_log" key={index}>
@ -190,15 +193,15 @@ export const ContractSelection = (props: ContractSelectionProps) => {
</div>
<article className="mt-2 pb-0">
<button id="publishOnIpfs" className="btn btn-secondary btn-block" title="Publish on Ipfs" onClick={() => { handlePublishToStorage('ipfs') }}>
<span>Publish on Ipfs</span>
<span><FormattedMessage id='solidity.publishOn' defaultMessage='Publish on' /> Ipfs</span>
<img id="ipfsLogo" className="remixui_storageLogo ml-2" src="assets/img/ipfs.webp" />
</button>
<button id="publishOnSwarm" className="btn btn-secondary btn-block" title="Publish on Swarm" onClick={() => { handlePublishToStorage('swarm') }}>
<span>Publish on Swarm</span>
<span><FormattedMessage id='solidity.publishOn' defaultMessage='Publish on' /> Swarm</span>
<img id="swarmLogo" className="remixui_storageLogo ml-2" src="assets/img/swarm.webp" />
</button>
<button data-id="compilation-details" className="btn btn-secondary btn-block" title="Display Contract Details" onClick={() => { details() }}>
Compilation Details
<FormattedMessage id='solidity.compilationDetails' defaultMessage='Compilation Details' />
</button>
{/* Copy to Clipboard */}
<div className="remixui_contractHelperButtons">

Loading…
Cancel
Save