Skip to content

Commit ee59930

Browse files
drafishAniket-Engg
authored andcommitted
i18n for openaigpt
1 parent 66550b5 commit ee59930

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

apps/remix-ide/src/app/tabs/locales/en/editor.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
"editor.formatCode": "Format Code",
2222
"editor.generateDocumentation": "Generate documentation for this function",
2323
"editor.generateDocumentation2": "Generate documentation for the function \"{name}\"",
24+
"editor.generateDocumentationByAI": "solidity code: {content}\n Generate the documentation for the function {currentFunction} using the Doxygen style syntax",
2425
"editor.explainFunction": "Explain this function",
2526
"editor.explainFunction2": "Explain the function \"{name}\"",
27+
"editor.explainFunctionByAI": "solidity code: {content}\n Explain the function {currentFunction}",
2628
"editor.executeFreeFunction": "Run a free function",
2729
"editor.executeFreeFunction2": "Run the free function \"{name}\"",
2830
"editor.toastText1": "This can only execute free function",

apps/remix-ide/src/app/tabs/locales/en/solidity.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"solidity.displayName": "Solidity compiler",
3+
"solidity.openaigptMessage": "solidity code: {content}\n error message: {messageText}\n explain why the error occurred and how to fix it.",
34

45
"solidity._comment_compiler-container.tsx": "libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx",
56
"solidity.compiler": "Compiler",

libs/remix-ui/editor/src/lib/remix-ui-editor.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,7 @@ export const EditorUI = (props: EditorUIProps) => {
719719
run: async () => {
720720
const file = await props.plugin.call('fileManager', 'getCurrentFile')
721721
const content = await props.plugin.call('fileManager', 'readFile', file)
722-
const message = `
723-
solidity code: ${content}
724-
Generate the documentation for the function ${currentFunction.current} using the Doxygen style syntax
725-
`
722+
const message = intl.formatMessage({id: 'editor.generateDocumentationByAI'}, {content, currentFunction: currentFunction.current})
726723
await props.plugin.call('openaigpt', 'message', message)
727724
_paq.push(['trackEvent', 'ai', 'openai', 'generateDocumentation'])
728725
},
@@ -738,10 +735,7 @@ export const EditorUI = (props: EditorUIProps) => {
738735
run: async () => {
739736
const file = await props.plugin.call('fileManager', 'getCurrentFile')
740737
const content = await props.plugin.call('fileManager', 'readFile', file)
741-
const message = `
742-
solidity code: ${content}
743-
Explain the function ${currentFunction.current}
744-
`
738+
const message = intl.formatMessage({id: 'editor.explainFunctionByAI'}, {content, currentFunction: currentFunction.current})
745739
await props.plugin.call('openaigpt', 'message', message)
746740
_paq.push(['trackEvent', 'ai', 'openai', 'explainFunction'])
747741
},

libs/remix-ui/renderer/src/lib/renderer.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {useEffect, useState} from 'react' //eslint-disable-line
2+
import {useIntl} from 'react-intl'
23
import {CopyToClipboard} from '@remix-ui/clipboard'
34
import {helper} from '@remix-project/remix-solidity'
45
import './renderer.css'
@@ -11,6 +12,7 @@ interface RendererProps {
1112
}
1213

1314
export const Renderer = ({message, opt = {}, plugin}: RendererProps) => {
15+
const intl = useIntl()
1416
const [messageText, setMessageText] = useState(null)
1517
const [editorOptions, setEditorOptions] = useState({
1618
useSpan: false,
@@ -72,11 +74,7 @@ export const Renderer = ({message, opt = {}, plugin}: RendererProps) => {
7274
const askGtp = async () => {
7375
try {
7476
const content = await plugin.call('fileManager', 'readFile', editorOptions.errFile)
75-
const message = `
76-
solidity code: ${content}
77-
error message: ${messageText}
78-
explain why the error occurred and how to fix it.
79-
`
77+
const message = intl.formatMessage({id: 'solidity.openaigptMessage'}, {content, messageText})
8078
await plugin.call('openaigpt', 'message', message)
8179
_paq.push(['trackEvent', 'ai', 'openai', 'explainSolidityError'])
8280
} catch (err) {

0 commit comments

Comments
 (0)