diff --git a/src/licenses/LicenseDialog.tsx b/src/licenses/LicenseDialog.tsx index f1f3c065..dc81e61a 100644 --- a/src/licenses/LicenseDialog.tsx +++ b/src/licenses/LicenseDialog.tsx @@ -11,6 +11,7 @@ import { Classes, Dialog, NonIdealState, + Spinner, } from '@blueprintjs/core'; import { useI18n } from '@shopify/react-i18n'; import React, { useState } from 'react'; @@ -38,15 +39,19 @@ type LicenseListPanelProps = { const LicenseListPanel: React.VoidFunctionComponent = ({ onItemClick, }) => { + const [i18n] = useI18n({ id: 'license', translations: { en }, fallback: en }); const { data, error } = useFetch('static/oss-licenses.json'); return (
- {error || !data ? ( - // TODO: this should be translated and hooked to - // state indicating if download is in progress - // or there was an actual failure. - Failed to load license data. + {!data ? ( + + {error ? ( + i18n.translate(LicenseStringId.ErrorFetchFailed) + ) : ( + + )} + ) : ( {data.map((info, i) => ( diff --git a/src/licenses/i18n.en.json b/src/licenses/i18n.en.json index 2e742c83..662c21c6 100644 --- a/src/licenses/i18n.en.json +++ b/src/licenses/i18n.en.json @@ -5,6 +5,9 @@ "packageLabel": "Package:", "authorLabel": "Author:", "licenseLabel": "License:", + "error": { + "fetchFailed": "Failed to load license data." + }, "help": { "selectPackage": "Select a package to view the license." } diff --git a/src/licenses/i18n.ts b/src/licenses/i18n.ts index da089f70..460a83cb 100644 --- a/src/licenses/i18n.ts +++ b/src/licenses/i18n.ts @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2021 The Pybricks Authors +// Copyright (c) 2021-2022 The Pybricks Authors // License dialog translation keys. @@ -9,5 +9,6 @@ export enum LicenseStringId { PackageLabel = 'license.packageLabel', AuthorLabel = 'license.authorLabel', LicenseLabel = 'license.licenseLabel', + ErrorFetchFailed = 'license.error.fetchFailed', SelectPackageHelp = 'license.help.selectPackage', }