diff --git a/src/component/audit/ErrorLogViewer.tsx b/src/component/audit/ErrorLogViewer.tsx index b2af7337f..4b1da63af 100644 --- a/src/component/audit/ErrorLogViewer.tsx +++ b/src/component/audit/ErrorLogViewer.tsx @@ -8,7 +8,7 @@ import { GoTrashcan } from "react-icons/go"; import { useI18n } from "../hook/useI18n"; const ErrorLogViewer: React.FC = () => { - const { i18n, locale } = useI18n(); + const { i18n, formatMessage, locale } = useI18n(); const errors = useSelector((state: TermItState) => state.errors); const dispatch: ThunkDispatch = useDispatch(); const clear = () => { @@ -43,9 +43,15 @@ const ErrorLogViewer: React.FC = () => { {errors.map((item) => { let error = item.error; if (error.messageId) { - error = Object.assign({}, error, { - message: i18n(error.messageId), - }); + if (error.values && Object.keys(error.values).length > 0) { + error = Object.assign({}, error, { + message: formatMessage(error.messageId, error.values), + }); + } else { + error = Object.assign({}, error, { + message: i18n(error.messageId), + }); + } } return ( diff --git a/src/i18n/cs.ts b/src/i18n/cs.ts index 23f36a984..6dae9ecfc 100644 --- a/src/i18n/cs.ts +++ b/src/i18n/cs.ts @@ -796,6 +796,8 @@ const cs = { "Excel obsahuje více pojmů se stejným identifikátorem.", "error.vocabulary.import.excel.duplicateLabel": "Excel obsahuje více pojmů se stejným názvem.", + "error.vocabulary.import.excel.labelWithDifferentIdentifierExists": + 'Slovník již obsahuje pojem s názvem "{label}" s rozdílným identifikátorem než s jakým byl importován. Existující identifikátor: {existingUri}', "history.label": "Historie změn", "history.loading": "Načítám historii...", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 47c2b2d10..aed4b37c3 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -788,6 +788,8 @@ const en = { "The Excel file contains multiple terms with the same identifier.", "error.vocabulary.import.excel.duplicateLabel": "The Excel file contains multiple terms with the same label.", + "error.vocabulary.import.excel.labelWithDifferentIdentifierExists": + 'Vocabulary already contains a term with label "{label}" with a different identifier than the imported one. Existing identifier: {existingUri}', "history.label": "Change history", "history.loading": "Loading history...", diff --git a/src/model/ErrorInfo.ts b/src/model/ErrorInfo.ts index dc23e4236..ea5fe47c8 100644 --- a/src/model/ErrorInfo.ts +++ b/src/model/ErrorInfo.ts @@ -7,18 +7,21 @@ export interface ErrorData { requestUrl?: string; messageId?: string; message?: string; + /// values used for formatting localized message + values?: { [key: string]: string }; status?: number; // Response status } /** * Represents error received from the server API. */ -export default class ErrorInfo { +export default class ErrorInfo implements ErrorData { public readonly origin: string; public readonly requestUrl?: string; public readonly messageId?: string; public readonly message?: string; public readonly status?: number; + public readonly values?: { [key: string]: string }; constructor(origin: string, data: ErrorData) { this.origin = origin;