From c75526d88e2caafb4b05c4235673bc1a3e6dd1b8 Mon Sep 17 00:00:00 2001 From: drafish Date: Wed, 20 Dec 2023 10:12:43 +0800 Subject: [PATCH] add en locale messages for publish-to-storage --- .../app/tabs/locales/en/publishToStorage.json | 19 ++++++++ .../src/lib/publish-to-storage.tsx | 48 +++++++++++-------- 2 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 apps/remix-ide/src/app/tabs/locales/en/publishToStorage.json diff --git a/apps/remix-ide/src/app/tabs/locales/en/publishToStorage.json b/apps/remix-ide/src/app/tabs/locales/en/publishToStorage.json new file mode 100644 index 0000000000..0ac150479e --- /dev/null +++ b/apps/remix-ide/src/app/tabs/locales/en/publishToStorage.json @@ -0,0 +1,19 @@ +{ + "publishToStorage.title1": "Publish To Storage", + "publishToStorage.title1.message": "This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly.", + "publishToStorage.title2": "Published {name}'s Metadata and Sources", + "publishToStorage.title2.message": "Metadata and sources of \"{name}\" were published successfully.", + "publishToStorage.title3": "Swarm Publish Failed", + "publishToStorage.title4": "IPFS Settings", + "publishToStorage.title4.message1": "You have not set your own custom IPFS settings.", + "publishToStorage.title4.message2": "We won’t be providing a public endpoint anymore for publishing your contracts to IPFS.", + "publishToStorage.title4.message3": "Instead of that, 4 options are now available:", + "publishToStorage.title4.message4": "DEFAULT OPTION: Use the public INFURA node. This will not guarantee your data will persist.", + "publishToStorage.title4.message5": "Use your own INFURA IPFS node. This requires a subscription. Learn more", + "publishToStorage.title4.message6": "Use any external IPFS which doesn’t require any authentification.", + "publishToStorage.title4.message7": "Use your own local ipfs node (which usually runs under http://localhost:5001)", + "publishToStorage.title4.message8": "You can update your IPFS settings in the SETTINGS tab.", + "publishToStorage.title4.message9": "Now the default option will be used.", + "publishToStorage.title5": "IPFS Publish Failed", + "publishToStorage.title5.message": "Failed to publish metadata file and sources to {storage}, please check the {storage} gateways is available." +} diff --git a/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx b/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx index 1d02e6ad93..d84fa0e46c 100644 --- a/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx +++ b/libs/remix-ui/publish-to-storage/src/lib/publish-to-storage.tsx @@ -1,10 +1,12 @@ import React, {useEffect, useState} from 'react' // eslint-disable-line +import {FormattedMessage, useIntl} from 'react-intl' import {ModalDialog} from '@remix-ui/modal-dialog' // eslint-disable-line import {RemixUiPublishToStorageProps} from './types' // eslint-disable-line import {publishToIPFS} from './publishToIPFS' import {publishToSwarm} from './publishOnSwarm' export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { + const intl = useIntl() const {api, storage, contract, resetStorage} = props const [modalShown, setModalShown] = useState(false) const [state, setState] = useState({ @@ -23,41 +25,47 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { const storageService = async () => { if (contract.metadata === undefined || contract.metadata.length === 0) { modal( - 'Publish To Storage', - "This contract may be abstract, it may not implement an abstract parent's methods completely or it may not invoke an inherited contract's constructor correctly." + intl.formatMessage({id: 'publishToStorage.title1'}), + intl.formatMessage({id: 'publishToStorage.message1'}) ) } else { if (storage === 'swarm') { try { const result = await publishToSwarm(contract, api) - modal(`Published ${contract.name}'s Metadata and Sources`, publishMessage(result.uploaded)) + modal(intl.formatMessage({id: 'publishToStorage.title2'}, {name: contract.name}), publishMessage(result.uploaded)) } catch (err) { - modal('Swarm Publish Failed', publishMessageFailed(storage, err.message)) + modal(intl.formatMessage({id: 'publishToStorage.title3'}), publishMessageFailed(storage, err.message)) } } else { if (!api.config.get('settings/ipfs-url') && !modalShown) { modal( - 'IPFS Settings', + intl.formatMessage({id: 'publishToStorage.title4'}),
- You have not set your own custom IPFS settings.

+



- We won’t be providing a public endpoint anymore for publishing your contracts to IPFS.

Instead of that, 4 options are now available:

+





    -
  • DEFAULT OPTION: Use the public INFURA node. This will not guarantee your data will persist.
  • +
  • - Use your own INFURA IPFS node. This requires a subscription.{' '} - - Learn more - + ( + + {chunks} + + ) + }} + />
  • -
  • Use any external IPFS which doesn’t require any authentification.
  • -
  • Use your own local ipfs node (which usually runs under http://localhost:5001)
  • +
  • +
- You can update your IPFS settings in the SETTINGS tab. +

- Now the default option will be used. +
, async () => await ipfs(contract, api) ) @@ -76,9 +84,9 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { const ipfs = async (contract, api) => { try { const result = await publishToIPFS(contract, api) - modal(`Published ${contract.name}'s Metadata and Sources`, publishMessage(result.uploaded)) + modal(intl.formatMessage({id: 'publishToStorage.title2'}, {name: contract.name}), publishMessage(result.uploaded)) } catch (err) { - modal('IPFS Publish Failed', publishMessageFailed(storage, err.message)) + modal(intl.formatMessage({id: 'publishToStorage.title5'}), publishMessageFailed(storage, err.message)) } setModalShown(true) } @@ -86,7 +94,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { const publishMessage = (uploaded) => ( {' '} - Metadata and sources of "{contract.name.toLowerCase()}" were published successfully.
+
         
{uploaded.map((value, index) => ( @@ -101,7 +109,7 @@ export const PublishToStorage = (props: RemixUiPublishToStorageProps) => { const publishMessageFailed = (storage, err) => ( - Failed to publish metadata file and sources to {storage}, please check the {storage} gateways is available.
+
{err}
)