i18n for openaigpt

pull/5370/head
drafish 11 months ago committed by Aniket
parent 37aae8c32c
commit edcb8f2a1d
  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.formatCode": "Format Code",
"editor.generateDocumentation": "Generate documentation for this function", "editor.generateDocumentation": "Generate documentation for this function",
"editor.generateDocumentation2": "Generate documentation for the function \"{name}\"", "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.explainFunction": "Explain this function",
"editor.explainFunction2": "Explain the function \"{name}\"", "editor.explainFunction2": "Explain the function \"{name}\"",
"editor.explainFunctionByAI": "solidity code: {content}\n Explain the function {currentFunction}",
"editor.executeFreeFunction": "Run a free function", "editor.executeFreeFunction": "Run a free function",
"editor.executeFreeFunction2": "Run the free function \"{name}\"", "editor.executeFreeFunction2": "Run the free function \"{name}\"",
"editor.toastText1": "This can only execute free function", "editor.toastText1": "This can only execute free function",

@ -1,5 +1,6 @@
{ {
"solidity.displayName": "Solidity compiler", "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._comment_compiler-container.tsx": "libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx",
"solidity.compiler": "Compiler", "solidity.compiler": "Compiler",

@ -719,10 +719,7 @@ export const EditorUI = (props: EditorUIProps) => {
run: async () => { run: async () => {
const file = await props.plugin.call('fileManager', 'getCurrentFile') const file = await props.plugin.call('fileManager', 'getCurrentFile')
const content = await props.plugin.call('fileManager', 'readFile', file) const content = await props.plugin.call('fileManager', 'readFile', file)
const message = ` const message = intl.formatMessage({id: 'editor.generateDocumentationByAI'}, {content, currentFunction: currentFunction.current})
solidity code: ${content}
Generate the documentation for the function ${currentFunction.current} using the Doxygen style syntax
`
await props.plugin.call('openaigpt', 'message', message) await props.plugin.call('openaigpt', 'message', message)
_paq.push(['trackEvent', 'ai', 'openai', 'generateDocumentation']) _paq.push(['trackEvent', 'ai', 'openai', 'generateDocumentation'])
}, },
@ -738,10 +735,7 @@ export const EditorUI = (props: EditorUIProps) => {
run: async () => { run: async () => {
const file = await props.plugin.call('fileManager', 'getCurrentFile') const file = await props.plugin.call('fileManager', 'getCurrentFile')
const content = await props.plugin.call('fileManager', 'readFile', file) const content = await props.plugin.call('fileManager', 'readFile', file)
const message = ` const message = intl.formatMessage({id: 'editor.explainFunctionByAI'}, {content, currentFunction: currentFunction.current})
solidity code: ${content}
Explain the function ${currentFunction.current}
`
await props.plugin.call('openaigpt', 'message', message) await props.plugin.call('openaigpt', 'message', message)
_paq.push(['trackEvent', 'ai', 'openai', 'explainFunction']) _paq.push(['trackEvent', 'ai', 'openai', 'explainFunction'])
}, },

@ -1,4 +1,5 @@
import React, {useEffect, useState} from 'react' //eslint-disable-line import React, {useEffect, useState} from 'react' //eslint-disable-line
import {useIntl} from 'react-intl'
import {CopyToClipboard} from '@remix-ui/clipboard' import {CopyToClipboard} from '@remix-ui/clipboard'
import {helper} from '@remix-project/remix-solidity' import {helper} from '@remix-project/remix-solidity'
import './renderer.css' import './renderer.css'
@ -11,6 +12,7 @@ interface RendererProps {
} }
export const Renderer = ({message, opt = {}, plugin}: RendererProps) => { export const Renderer = ({message, opt = {}, plugin}: RendererProps) => {
const intl = useIntl()
const [messageText, setMessageText] = useState(null) const [messageText, setMessageText] = useState(null)
const [editorOptions, setEditorOptions] = useState({ const [editorOptions, setEditorOptions] = useState({
useSpan: false, useSpan: false,
@ -72,11 +74,7 @@ export const Renderer = ({message, opt = {}, plugin}: RendererProps) => {
const askGtp = async () => { const askGtp = async () => {
try { try {
const content = await plugin.call('fileManager', 'readFile', editorOptions.errFile) const content = await plugin.call('fileManager', 'readFile', editorOptions.errFile)
const message = ` const message = intl.formatMessage({id: 'solidity.openaigptMessage'}, {content, messageText})
solidity code: ${content}
error message: ${messageText}
explain why the error occurred and how to fix it.
`
await plugin.call('openaigpt', 'message', message) await plugin.call('openaigpt', 'message', message)
_paq.push(['trackEvent', 'ai', 'openai', 'explainSolidityError']) _paq.push(['trackEvent', 'ai', 'openai', 'explainSolidityError'])
} catch (err) { } catch (err) {

Loading…
Cancel
Save