diff --git a/apps/remix-ide/src/app/tabs/locales/en/editor.json b/apps/remix-ide/src/app/tabs/locales/en/editor.json index df7c99bace..fac7f7a60e 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/editor.json +++ b/apps/remix-ide/src/app/tabs/locales/en/editor.json @@ -21,8 +21,10 @@ "editor.formatCode": "Format Code", "editor.generateDocumentation": "Generate documentation for this function", "editor.generateDocumentation2": "Generate documentation for the function \"{name}\"", + "editor.generateDocumentationByAI": "solidity code: {content}\n Generate the documentation for the function {currentFunction} using the Doxygen style syntax", "editor.explainFunction": "Explain this function", "editor.explainFunction2": "Explain the function \"{name}\"", + "editor.explainFunctionByAI": "solidity code: {content}\n Explain the function {currentFunction}", "editor.executeFreeFunction": "Run a free function", "editor.executeFreeFunction2": "Run the free function \"{name}\"", "editor.toastText1": "This can only execute free function", 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 adddb8dfdd..33304ce3a6 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,6 @@ { "solidity.displayName": "Solidity compiler", + "solidity.openaigptMessage": "solidity code: {content}\n error message: {messageText}\n explain why the error occurred and how to fix it.", "solidity._comment_compiler-container.tsx": "libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx", "solidity.compiler": "Compiler", diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 77447949d7..300d418360 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -719,10 +719,7 @@ export const EditorUI = (props: EditorUIProps) => { run: async () => { const file = await props.plugin.call('fileManager', 'getCurrentFile') const content = await props.plugin.call('fileManager', 'readFile', file) - const message = ` - solidity code: ${content} - Generate the documentation for the function ${currentFunction.current} using the Doxygen style syntax - ` + const message = intl.formatMessage({id: 'editor.generateDocumentationByAI'}, {content, currentFunction: currentFunction.current}) await props.plugin.call('openaigpt', 'message', message) _paq.push(['trackEvent', 'ai', 'openai', 'generateDocumentation']) }, @@ -738,10 +735,7 @@ export const EditorUI = (props: EditorUIProps) => { run: async () => { const file = await props.plugin.call('fileManager', 'getCurrentFile') const content = await props.plugin.call('fileManager', 'readFile', file) - const message = ` - solidity code: ${content} - Explain the function ${currentFunction.current} - ` + const message = intl.formatMessage({id: 'editor.explainFunctionByAI'}, {content, currentFunction: currentFunction.current}) await props.plugin.call('openaigpt', 'message', message) _paq.push(['trackEvent', 'ai', 'openai', 'explainFunction']) }, diff --git a/libs/remix-ui/renderer/src/lib/renderer.tsx b/libs/remix-ui/renderer/src/lib/renderer.tsx index f79cec142f..433c91f7ae 100644 --- a/libs/remix-ui/renderer/src/lib/renderer.tsx +++ b/libs/remix-ui/renderer/src/lib/renderer.tsx @@ -1,4 +1,5 @@ import React, {useEffect, useState} from 'react' //eslint-disable-line +import {useIntl} from 'react-intl' import {CopyToClipboard} from '@remix-ui/clipboard' import {helper} from '@remix-project/remix-solidity' import './renderer.css' @@ -11,6 +12,7 @@ interface RendererProps { } export const Renderer = ({message, opt = {}, plugin}: RendererProps) => { + const intl = useIntl() const [messageText, setMessageText] = useState(null) const [editorOptions, setEditorOptions] = useState({ useSpan: false, @@ -72,11 +74,7 @@ export const Renderer = ({message, opt = {}, plugin}: RendererProps) => { const askGtp = async () => { try { const content = await plugin.call('fileManager', 'readFile', editorOptions.errFile) - const message = ` - solidity code: ${content} - error message: ${messageText} - explain why the error occurred and how to fix it. - ` + const message = intl.formatMessage({id: 'solidity.openaigptMessage'}, {content, messageText}) await plugin.call('openaigpt', 'message', message) _paq.push(['trackEvent', 'ai', 'openai', 'explainSolidityError']) } catch (err) {