i18n for openaigpt

desktopautoupdate
drafish 11 months ago committed by Aniket
parent 66550b5a2a
commit ee59930b80
  1. 2
      apps/remix-ide/src/app/tabs/locales/en/editor.json
  2. 1
      apps/remix-ide/src/app/tabs/locales/en/solidity.json
  3. 10
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
  4. 8
      libs/remix-ui/renderer/src/lib/renderer.tsx

@ -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",

@ -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",

@ -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'])
},

@ -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) {

Loading…
Cancel
Save