From 709c492da3e51fb17d76739b644c2ca1faf2234c Mon Sep 17 00:00:00 2001 From: drafish Date: Wed, 14 Dec 2022 21:05:20 +0800 Subject: [PATCH] permissionHandler intl --- .../remix-ide/src/app/tabs/locales/en/index.js | 2 ++ .../app/tabs/locales/en/permissionHandler.json | 10 ++++++++++ .../remix-ide/src/app/tabs/locales/zh/index.js | 2 ++ .../app/tabs/locales/zh/permissionHandler.json | 10 ++++++++++ .../src/lib/permission-dialog.tsx | 18 ++++++++++-------- 5 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 apps/remix-ide/src/app/tabs/locales/en/permissionHandler.json create mode 100644 apps/remix-ide/src/app/tabs/locales/zh/permissionHandler.json diff --git a/apps/remix-ide/src/app/tabs/locales/en/index.js b/apps/remix-ide/src/app/tabs/locales/en/index.js index dfef2c32ad..a5b807a902 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/index.js +++ b/apps/remix-ide/src/app/tabs/locales/en/index.js @@ -9,6 +9,7 @@ import solidityJson from './solidity.json'; import terminalJson from './terminal.json'; import udappJson from './udapp.json'; import solidityUnitTestingJson from './solidityUnitTesting.json'; +import permissionHandlerJson from './permissionHandler.json'; export default { ...debuggerJson, @@ -22,4 +23,5 @@ export default { ...terminalJson, ...udappJson, ...solidityUnitTestingJson, + ...permissionHandlerJson, } diff --git a/apps/remix-ide/src/app/tabs/locales/en/permissionHandler.json b/apps/remix-ide/src/app/tabs/locales/en/permissionHandler.json new file mode 100644 index 0000000000..0d59c8e7d7 --- /dev/null +++ b/apps/remix-ide/src/app/tabs/locales/en/permissionHandler.json @@ -0,0 +1,10 @@ +{ + "permissionHandler.allPermissionsReset": "All permisssions have been reset.", + "permissionHandler.rememberText": "has changed and", + "permissionHandler.permissionHandlerMessage": "\"{from}\" {rememberText} would like to access to \"{method}\" of \"{to}\"`", + "permissionHandler.description": "Description", + "permissionHandler.noDescriptionProvided": "No description Provided", + "permissionHandler.makeSureYouTrustThisPlugin": "Make sure you trust this plugin before processing this call.", + "permissionHandler.rememberThisChoice": "Remember this choice", + "permissionHandler.resetAllPermissions": "Reset all Permissions" +} diff --git a/apps/remix-ide/src/app/tabs/locales/zh/index.js b/apps/remix-ide/src/app/tabs/locales/zh/index.js index 80d7b18c97..6b77c72871 100644 --- a/apps/remix-ide/src/app/tabs/locales/zh/index.js +++ b/apps/remix-ide/src/app/tabs/locales/zh/index.js @@ -9,6 +9,7 @@ import solidityJson from './solidity.json'; import terminalJson from './terminal.json'; import udappJson from './udapp.json'; import solidityUnitTestingJson from './solidityUnitTesting.json'; +import permissionHandlerJson from './permissionHandler.json'; import enJson from '../en'; // There may have some un-translated content. Always fill in the gaps with EN JSON. @@ -25,4 +26,5 @@ export default Object.assign({}, enJson, { ...terminalJson, ...udappJson, ...solidityUnitTestingJson, + ...permissionHandlerJson, }) diff --git a/apps/remix-ide/src/app/tabs/locales/zh/permissionHandler.json b/apps/remix-ide/src/app/tabs/locales/zh/permissionHandler.json new file mode 100644 index 0000000000..382170cb90 --- /dev/null +++ b/apps/remix-ide/src/app/tabs/locales/zh/permissionHandler.json @@ -0,0 +1,10 @@ +{ + "permissionHandler.allPermissionsReset": "已重置所有权限。", + "permissionHandler.rememberText": "已变更且", + "permissionHandler.permissionHandlerMessage": "\"{from}\" {rememberText}要访问 \"{to}\" 的 \"{method}\"", + "permissionHandler.description": "描述", + "permissionHandler.noDescriptionProvided": "没有提供描述", + "permissionHandler.makeSureYouTrustThisPlugin": "在处理此调用之前,请确保您信任此插件。", + "permissionHandler.rememberThisChoice": "记住此选项", + "permissionHandler.resetAllPermissions": "重置所有权限" +} diff --git a/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx b/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx index 793d2ea076..cd8fd03291 100644 --- a/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx +++ b/libs/remix-ui/permission-handler/src/lib/permission-dialog.tsx @@ -1,4 +1,5 @@ import React, { ChangeEventHandler, useContext, useEffect, useRef, useState } from 'react' // eslint-disable-line +import { FormattedMessage, useIntl } from 'react-intl' import { PermissionHandlerProps } from '../interface' import './permission-dialog.css' @@ -6,6 +7,7 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => { const { from, to, remember, method, message, sensitiveCall } = props.value const [feedback, setFeedback] = useState('') const theme = props.theme + const intl = useIntl() const switchMode = (e: any) => { props.plugin.switchMode(from, to, method, e.target.checked) @@ -16,7 +18,7 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => { } const reset = () => { props.plugin.clear() - setFeedback('All permisssions have been reset.') + setFeedback(intl.formatMessage({ id: 'permissionHandler.allPermissionsReset' })) } const imgFrom = () => { return } @@ -32,13 +34,13 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => { } const text = () => { - return <>"{from.displayName}" {(remember ? 'has changed and' : '')} would like to access to "{method}" of "{to.displayName}"` + return } const pluginMessage = () => { return message ?
-
Description
+

{message}

: null } @@ -48,19 +50,19 @@ const PermissionHandlerDialog = (props: PermissionHandlerProps) => {

{text()} :

{from.displayName}
-

{from.description || No description Provided}

+

{from.description || }

{to.displayName} :
-

{to.description || No description Provided}

+

{to.description || }

{pluginMessage()} - { sensitiveCall ?

Make sure you trust this plugin before processing this call.

: '' } + { sensitiveCall ?

: '' }
{ !sensitiveCall &&
{rememberSwitch()} - +
} - +
{feedback}
)