From 0262533b93525dc59fc078a4acd8c64952eab39c Mon Sep 17 00:00:00 2001 From: drafish Date: Wed, 9 Aug 2023 21:30:18 +0800 Subject: [PATCH] patch en locale messages for compiler-container --- .../src/app/tabs/locales/en/solidity.json | 28 ++++++++ .../src/lib/compiler-container.tsx | 70 ++++++++++++------- 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/apps/remix-ide/src/app/tabs/locales/en/solidity.json b/apps/remix-ide/src/app/tabs/locales/en/solidity.json index 6e7a6e45ac..b91190e5af 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/solidity.json +++ b/apps/remix-ide/src/app/tabs/locales/en/solidity.json @@ -1,5 +1,7 @@ { "solidity.displayName": "Solidity compiler", + + "solidity._comment_path1": "libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx", "solidity.compiler": "Compiler", "solidity.addACustomCompiler": "Add a custom compiler", "solidity.addACustomCompilerWithURL": "Add a custom compiler with URL", @@ -21,6 +23,32 @@ "solidity.compile": "Compile", "solidity.noFileSelected": "no file selected", "solidity.compileAndRunScript": "Compile and Run script", + "solidity.newConfigFileTitle": "New configuration file", + "solidity.newConfigFileMessage": "The file \"{configFilePathInput}\" you entered does not exist. Do you want to create a new one?", + "solidity.create": "Create", + "solidity.ok": "OK", + "solidity.cancel": "Cancel", + "solidity.noFileSelected1": "No file selected.", + "solidity.toCompile": "to compile", + "solidity.noConfigFileSelected": "No config file selected", + "solidity.copyNatSpecTag": "Click to copy the custom NatSpec tag", + "solidity.inputTitle1": "If the file you entered does not exist you will be able to create one in the next step.", + "solidity.inputTitle2": "Estimated number of times each opcode of the deployed code will be executed across the life-time of the contract.", + "solidity.tooltipText1": "Choose the script to execute right after compilation by adding the `dev-run-script` natspec tag, as in:", + "solidity.tooltipText2": "Click the \"i\" icon to learn more", + "solidity.tooltipText3": "for compiling and script execution", + "solidity.tooltipText4": "Click to open the config file", + "solidity.tooltipText5": "Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload. Error: ", + "solidity.tooltipText6": "Language specification available from Compiler >= v0.5.7", + "solidity.toastMessage": "Updating compiler version to match current contract file pragma i.e {version}", + "solidity.compileIconAttribute": "compiler is loading, please wait a few moments.", + "solidity.compilerLicense": "Compiler License", + "solidity.compilerLicenseMsg1": "Compiler is loading. License will be displayed once compiler is loaded", + "solidity.compilerLicenseMsg2": "Could not retreive license for selected compiler version", + "solidity.compilerLicenseMsg3": "License not available", + "solidity.seeCompilerLicense": "See compiler license", + + "solidity._comment_path2": "libs/remix-ui/solidity-compiler/src/lib/contract-selection.tsx", "solidity.publishOn": "Publish on", "solidity.flatten": "Flatten contracts before UML generation.", "solidity.generateUML": "Generate a UML diagram of your contract.", diff --git a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx index 1e5c960d5c..ab2355d8ca 100644 --- a/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx +++ b/libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx @@ -274,12 +274,12 @@ export const CompilerContainer = (props: CompilerContainerProps) => { setShowFilePathInput(false) } else { modal( - 'New configuration file', - `The file "${configFilePathInput.current.value}" you entered does not exist. Do you want to create a new one?`, - 'Create', + intl.formatMessage({id: 'solidity.newConfigFileTitle'}), + intl.formatMessage({id: 'solidity.newConfigFileMessage'}, {configFilePathInput: configFilePathInput.current.value}), + intl.formatMessage({id: 'solidity.create'}), async () => await createNewConfigFile(), false, - 'Cancel', + intl.formatMessage({id: 'solidity.cancel'}), () => { setShowFilePathInput(false) } @@ -337,9 +337,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { allVersionsWasm = wasmRes.data.builds.slice().reverse() } } catch (e) { - tooltip( - 'Cannot load compiler version list. It might have been blocked by an advertisement blocker. Please try deactivating any of them from this page and reload. Error: ' + e - ) + tooltip(intl.formatMessage({id: 'solidity.tooltipText5'}) + e) } // replace in allVersions those compiler builds which exist in allVersionsWasm with new once if (allVersionsWasm && allVersions) { @@ -399,7 +397,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const compilerPath = state.allversions.filter((obj) => !obj.prerelease && obj.version === compilerToLoad)[0].path if (state.selectedVersion !== compilerPath) { // @ts-ignore - api.call('notification', 'toast', `Updating compiler version to match current contract file pragma i.e ${_retrieveVersion(compilerPath)}`) + api.call('notification', 'toast', intl.formatMessage({id: 'solidity.toastMessage'}, {version: _retrieveVersion(compilerPath)})) setState((prevState) => { return {...prevState, selectedVersion: compilerPath} }) @@ -443,12 +441,12 @@ export const CompilerContainer = (props: CompilerContainerProps) => { const loadingCompiler = () => { if (!compileIcon.current) return - compileIcon.current.setAttribute('title', 'compiler is loading, please wait a few moments.') + compileIcon.current.setAttribute('title', intl.formatMessage({id: 'solidity.compileIconAttribute'})) compileIcon.current.classList.add('remixui_spinningIcon') setState((prevState) => { return { ...prevState, - compilerLicense: 'Compiler is loading. License will be displayed once compiler is loaded' + compilerLicense: intl.formatMessage({id: 'solidity.compilerLicenseMsg1'}) } }) _updateLanguageSelector() @@ -462,7 +460,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { setState((prevState) => { return { ...prevState, - compilerLicense: license ? license : 'Could not retreive license for selected compiler version' + compilerLicense: license ? license : intl.formatMessage({id: 'solidity.compilerLicenseMsg2'}) } }) if (state.autoCompile) compile() @@ -592,16 +590,21 @@ export const CompilerContainer = (props: CompilerContainerProps) => { id: 'solidity.addACustomCompiler' }), promptMessage('URL'), - 'OK', + intl.formatMessage({id: 'solidity.ok'}), addCustomCompiler, false, - 'Cancel', + intl.formatMessage({id: 'solidity.cancel'}), () => {} ) } const showCompilerLicense = () => { - modal('Compiler License', state.compilerLicense ? state.compilerLicense : 'License not available', 'OK', () => {}) + modal( + intl.formatMessage({id: 'solidity.compilerLicense'}), + state.compilerLicense ? state.compilerLicense : intl.formatMessage({id: 'solidity.compilerLicenseMsg3'}), + intl.formatMessage({id: 'solidity.ok'}), + () => {} + ) } const promptMessage = (message) => { @@ -766,7 +769,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { > promptCompiler()}> - + }> showCompilerLicense()}> { placeholder="200" value={state.runs} type="number" - title="Estimated number of times each opcode of the deployed code will be executed across the life-time of the contract." + title={intl.formatMessage({id: 'solidity.inputTitle2'})} onChange={(e) => onChangeRuns(e.target.value)} disabled={!state.optimize || state.useFileConfiguration} /> @@ -1014,7 +1021,16 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
{!showFilePathInput && state.useFileConfiguration && ( - Click to open the config file}> + + + + } + > { } className="py-2 remixui_compilerConfigPath" > - {configFilePath === '' ? 'No file selected.' : configFilePath} + {configFilePath === '' ? intl.formatMessage({id: 'solidity.noFileSelected1'}) : configFilePath} )} @@ -1034,7 +1050,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { ref={configFilePathInput} className={`py-0 my-0 form-control ${showFilePathInput ? 'd-flex' : 'd-none'}`} placeholder={'/folder_path/file_name.json'} - title="If the file you entered does not exist you will be able to create one in the next step." + title={intl.formatMessage({id: 'solidity.inputTitle1'})} disabled={!state.useFileConfiguration} data-id="scConfigFilePathInput" onKeyPress={(event) => { @@ -1072,10 +1088,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
{!(configFilePath === '' && state.useFileConfiguration) && (
- Ctrl+S to compile {state.compiledFileName.endsWith('.sol') ? state.compiledFileName : null}{' '} + Ctrl+S {state.compiledFileName.endsWith('.sol') ? state.compiledFileName : null}{' '}
)} - {configFilePath === '' && state.useFileConfiguration &&
No config file selected
} + {configFilePath === '' && state.useFileConfiguration &&
}
} > @@ -1114,10 +1130,10 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
{!(configFilePath === '' && state.useFileConfiguration) && (
- Ctrl+Shift+S for compiling and script execution + Ctrl+Shift+S
)} - {configFilePath === '' && state.useFileConfiguration &&
No config file selected
} + {configFilePath === '' && state.useFileConfiguration &&
}
} > @@ -1131,7 +1147,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => { tooltipId="overlay-tooltip-compile-run-doc" tooltipText={
-
Choose the script to execute right after compilation by adding the `dev-run-script` natspec tag, as in:
+
                     
                       /**
@@ -1148,7 +1164,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
                       
- Click the "i" icon to learn more +
} > @@ -1156,7 +1172,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
- '@custom:dev-run-script file_path'} direction="top"> + '@custom:dev-run-script file_path'} direction="top">