From 583e61b8d040c7d091312c6b6cfe950e2679443d Mon Sep 17 00:00:00 2001 From: mDuo13 Date: Mon, 2 Dec 2024 13:50:03 -0800 Subject: [PATCH 1/3] Fix toml checker. Per Redocly, we can't call useThemeHooks for translation in the TOML validator dependencies the way they're used right now. Since I'm unclear on how to refactor it to work with useThemeHooks right now, I'm removing the calls to useTranslate so that the tool will at least work in English. --- .../toml-checker/ValidateTomlSteps.tsx | 82 +++++++++---------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/resources/dev-tools/toml-checker/ValidateTomlSteps.tsx b/resources/dev-tools/toml-checker/ValidateTomlSteps.tsx index f3cda75b00..867e295c28 100644 --- a/resources/dev-tools/toml-checker/ValidateTomlSteps.tsx +++ b/resources/dev-tools/toml-checker/ValidateTomlSteps.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import { useThemeHooks } from '@redocly/theme/core/hooks'; import axios, { AxiosError } from "axios"; import { parse } from "smol-toml"; import { getListEntries } from "./ListTomlFields"; @@ -25,8 +24,9 @@ async function validateAndDisplayFields( domainToVerify?: string, filterDisplayedFieldsTo?: Function): Promise { - const { useTranslate } = useThemeHooks(); - const { translate } = useTranslate(); + // Note, apparently this is not an appropriate place + // to call useThemeHooks for translation. + // TODO: Find a way to translate the outputs from this tool. // If there's no data, do nothing if(!fields) { @@ -61,7 +61,7 @@ async function validateAndDisplayFields( id: headerText, status: { icon: { - label: translate("WRONG TYPE - SHOULD BE TABLE-ARRAY"), + label: "WRONG TYPE - SHOULD BE TABLE-ARRAY", type: "ERROR", } } @@ -80,12 +80,10 @@ function validateAndDisplayMetadata( setLogEntries: React.Dispatch>, metadata?: MetadataField) { - const { translate } = useTranslate() - if (metadata) { const metadataId = 'metadata-log' const metadataLogEntry = { - message: translate("Metadata section: "), + message: "Metadata section: ", id: metadataId } addNewLogEntry(setLogEntries, metadataLogEntry) @@ -94,14 +92,14 @@ function validateAndDisplayMetadata( if (Array.isArray(metadata)) { updateLogEntry(setLogEntries, {...metadataLogEntry, status: { icon: { - label: translate("WRONG TYPE - SHOULD BE TABLE"), + label: "WRONG TYPE - SHOULD BE TABLE", type: "ERROR", }, }}) } else { updateLogEntry(setLogEntries, {...metadataLogEntry, status: { icon: { - label: translate("FOUND"), + label: "FOUND", type: "SUCCESS", }, }}) @@ -109,7 +107,7 @@ function validateAndDisplayMetadata( if (metadata.modified) { const modifiedLogId = 'modified-date-log' const modifiedLogEntry = { - message: translate("Modified date: "), + message: "Modified date: ", id: modifiedLogId } addNewLogEntry(setLogEntries, modifiedLogEntry) @@ -123,7 +121,7 @@ function validateAndDisplayMetadata( } catch(e) { updateLogEntry(setLogEntries, { ...modifiedLogEntry, status: { icon: { - label: translate("INVALID"), + label: "INVALID", type: "ERROR", }, }}) @@ -148,10 +146,9 @@ async function parseXRPLToml( tomlData, addressToVerify?: string, domain?: string) { - const { translate } = useTranslate() const parsingTomlLogEntry: LogEntryItem = { - message: translate("Parsing TOML data..."), + message: "Parsing TOML data...", id: 'parsing-toml-data-log', } addNewLogEntry(setLogEntries, parsingTomlLogEntry) @@ -161,7 +158,7 @@ async function parseXRPLToml( parsed = parse(tomlData) updateLogEntry(setLogEntries, {...parsingTomlLogEntry, status: { icon: { - label: translate("SUCCESS"), + label: "SUCCESS", type: "SUCCESS", }, }}) @@ -177,7 +174,7 @@ async function parseXRPLToml( validateAndDisplayMetadata(setLogEntries, parsed.METADATA) - const accountHeader = translate("Accounts:") + const accountHeader = "Accounts:" if(addressToVerify) { const filterToSpecificAccount = (entry: AccountFields) => entry.address === addressToVerify const accountFound = await validateAndDisplayFields( @@ -191,11 +188,11 @@ async function parseXRPLToml( if(accountFound) { // Then share whether the domain / account pair as a whole has been validated addNewLogEntry(setLogEntries, { - message: translate('Account has been found in TOML file and validated.'), + message: 'Account has been found in TOML file and validated.', id: statusLogId, status: { icon: { - label: translate("DOMAIN VALIDATED"), + label: "DOMAIN VALIDATED", type: "SUCCESS", check: true, } @@ -204,22 +201,22 @@ async function parseXRPLToml( } else { // We failed to find any entries which match the account we're looking for addNewLogEntry(setLogEntries, { - message: translate("Account:"), + message: "Account:", id: 'toml-account-entry-log', status: { icon: { - label: translate("NOT FOUND"), + label: "NOT FOUND", type: "ERROR" } } }) addNewLogEntry(setLogEntries, { - message: translate("Account not found in TOML file. Domain can not be verified."), + message: "Account not found in TOML file. Domain can not be verified.", id: statusLogId, status: { icon: { - label: translate("VALIDATION FAILED"), + label: "VALIDATION FAILED", type: "ERROR", } } @@ -228,13 +225,13 @@ async function parseXRPLToml( } else { // The final validation message is displayed under the validated account since in this case we're // verifying a wallet address, not the toml file itself. - await validateAndDisplayFields(setLogEntries, translate(accountHeader), parsed.ACCOUNTS, domain) + await validateAndDisplayFields(setLogEntries, accountHeader, parsed.ACCOUNTS, domain) // We then display the rest of the toml as additional information - await validateAndDisplayFields(setLogEntries, translate("Validators:"), parsed.VALIDATORS) - await validateAndDisplayFields(setLogEntries, translate("Principals:"), parsed.PRINCIPALS) - await validateAndDisplayFields(setLogEntries, translate("Servers:"), parsed.SERVERS) - await validateAndDisplayFields(setLogEntries, translate("Currencies:"), parsed.CURRENCIES) + await validateAndDisplayFields(setLogEntries, "Validators:", parsed.VALIDATORS) + await validateAndDisplayFields(setLogEntries, "Principals:", parsed.PRINCIPALS) + await validateAndDisplayFields(setLogEntries, "Servers:", parsed.SERVERS) + await validateAndDisplayFields(setLogEntries, "Currencies:", parsed.CURRENCIES) } } @@ -272,12 +269,10 @@ export async function fetchFile( domain: string, accountToVerify?: string) { - const { translate } = useTranslate() - const url = "https://" + domain + TOML_PATH const checkUrlId = `check-url-log` const logEntry = { - message: translate(`Checking ${url} ...`), + message: `Checking ${url} ...`, id: checkUrlId, } addNewLogEntry(setLogEntries, logEntry) @@ -287,7 +282,7 @@ export async function fetchFile( const data: string = response.data updateLogEntry(setLogEntries, {...logEntry, status: { icon: { - label: translate("FOUND"), + label: "FOUND", type: "SUCCESS", }, }}) @@ -298,13 +293,13 @@ export async function fetchFile( } catch (e) { const errorUpdate: LogEntryItem = {...logEntry, status: { icon: { - label: translate(getHttpErrorCode((e as AxiosError)?.status)), + label: getHttpErrorCode((e as AxiosError)?.status), type: "ERROR", }, followUpMessage: (

- {translate("Check if the file is actually hosted at the URL above, ") - + translate("check your server's HTTPS settings and certificate, and make sure your server provides the required ")} - {translate("CORS header.")} + {"Check if the file is actually hosted at the URL above, " + + "check your server's HTTPS settings and certificate, and make sure your server provides the required "} + CORS header.

) }} updateLogEntry(setLogEntries, errorUpdate) @@ -319,15 +314,13 @@ export async function fetchFile( function displayDecodedWalletLog( setAccountLogEntries: React.Dispatch>,) { - const { translate } = useTranslate() - const logId = 'decoding-domain-hex' addNewLogEntry(setAccountLogEntries, { - message: translate('Decoding domain hex'), + message: 'Decoding domain hex', id: logId, status: { icon: { - label: translate('SUCCESS'), + label: 'SUCCESS', type: 'SUCCESS', }, } @@ -361,13 +354,12 @@ export function fetchWallet( accountToVerify: string, socket?: WebSocket) { - const {translate} = useTranslate() // Reset the logs setAccountLogEntries([]) const walletLogEntry = { - message: translate(`Checking domain of account`), + message: `Checking domain of account`, id: 'check-domain-account', } addNewLogEntry(setAccountLogEntries, walletLogEntry) @@ -387,7 +379,7 @@ export function fetchWallet( // Defaults to error to simplify logic later on let response: LogEntryStatus = { icon: { - label: translate(`ERROR`), + label: `ERROR`, type: `ERROR`, }, }; @@ -398,7 +390,7 @@ export function fetchWallet( try { response = { icon: { - label: translate('SUCCESS'), + label: 'SUCCESS', type: 'SUCCESS', }, } @@ -408,13 +400,13 @@ export function fetchWallet( fetchFile(setAccountLogEntries, decodedDomain, accountToVerify) } catch(e) { console.log(e) - response.followUpMessage =

{translate(`Error decoding domain field: ${data.result.account_data.Domain}`)}

+ response.followUpMessage =

{`Error decoding domain field: ${data.result.account_data.Domain}`}

} } else { - response.followUpMessage =

{translate("Make sure the account has the Domain field set.")}

+ response.followUpMessage =

{"Make sure the account has the Domain field set."}

} } else { - response.followUpMessage =

{translate("Make sure you are entering a valid XRP Ledger address.")}

+ response.followUpMessage =

{"Make sure you are entering a valid XRP Ledger address."}

} updateLogEntry(setAccountLogEntries, { ...walletLogEntry, status: response }) } catch { From 516b86297430899bc3827405a0938705d705d5bc Mon Sep 17 00:00:00 2001 From: mDuo13 Date: Mon, 2 Dec 2024 13:54:26 -0800 Subject: [PATCH 2/3] [JA] remove duplicate use-checks landing --- .../use-checks/use-checks.md | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 @l10n/ja/docs/tutorials/how-tos/use-specialized-payment-types/use-checks/use-checks.md diff --git a/@l10n/ja/docs/tutorials/how-tos/use-specialized-payment-types/use-checks/use-checks.md b/@l10n/ja/docs/tutorials/how-tos/use-specialized-payment-types/use-checks/use-checks.md deleted file mode 100644 index 21599f181f..0000000000 --- a/@l10n/ja/docs/tutorials/how-tos/use-specialized-payment-types/use-checks/use-checks.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -html: use-checks.html -parent: use-specialized-payment-types.html -seo: - description: XRP LedgerのCheckは、紙の小切手と同じように、別のアカウントに資金を振り込ませることができます。 -metadata: - indexPage: true -labels: - - Checks ---- -# Checkの使用 - -XRP LedgerのChecksでは、別のアカウントが後で支払いを請求することが認められていており、個人用の紙の小切手の仕組みと似ています。 - -{% raw-partial file="/docs/_snippets/common-links.md" /%} - - -{% child-pages /%} From ac042e969ddcb5b5f72e4540cc785a7861e0bfd5 Mon Sep 17 00:00:00 2001 From: mDuo13 Date: Mon, 2 Dec 2024 15:27:53 -0800 Subject: [PATCH 3/3] TOML Checker: adjust wording --- resources/dev-tools/toml-checker/ValidateTomlSteps.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/dev-tools/toml-checker/ValidateTomlSteps.tsx b/resources/dev-tools/toml-checker/ValidateTomlSteps.tsx index 867e295c28..6c08e7b97b 100644 --- a/resources/dev-tools/toml-checker/ValidateTomlSteps.tsx +++ b/resources/dev-tools/toml-checker/ValidateTomlSteps.tsx @@ -212,7 +212,7 @@ async function parseXRPLToml( }) addNewLogEntry(setLogEntries, { - message: "Account not found in TOML file. Domain can not be verified.", + message: "Account not found in TOML file. Domain cannot be verified.", id: statusLogId, status: { icon: {