From 6a9dea320403b49fde33fc22cd1a72b87533b338 Mon Sep 17 00:00:00 2001 From: Yury Saukou Date: Thu, 10 Nov 2022 00:45:05 +0400 Subject: [PATCH] UIOR-1018 Provide local translations to `ControlledVocab` (#1422) * Add translations for acq methods controlled vocab * Add translations for closing reasons controlled vocab * Add translations for prefixes controlled vocab * UIOR-1018 Add translations for suffixes controlled vocab * UIOR-1018 use common util to get translations * update changelog * Preserve used translation key * bump up stripes-acq-components version --- CHANGELOG.md | 1 + package.json | 2 +- .../AcquisitionMethods/AcquisitionMethods.js | 3 ++- src/settings/ClosingReasons/ClosingReasons.js | 3 ++- src/settings/Prefixes/Prefixes.js | 7 ++++-- src/settings/Suffixes/Suffixes.js | 7 ++++-- translations/ui-orders/en.json | 22 ++++++++++++++++++- 7 files changed, 37 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50f370d82..16f664851 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## (IN PROGRESS) * Use Orders Export History API (mod-orders). Refs UIOR-1034. +* Provide local translations to `ControlledVocab`. Refs UIOR-1018. ## [3.3.0](https://github.com/folio-org/ui-orders/tree/v3.3.0) (2022-10-27) [Full Changelog](https://github.com/folio-org/ui-orders/compare/v3.2.2...v3.3.0) diff --git a/package.json b/package.json index b93cc5b5c..81c5c97fd 100644 --- a/package.json +++ b/package.json @@ -452,7 +452,7 @@ }, "dependencies": { "@folio/plugin-find-po-line": "^3.2.0", - "@folio/stripes-acq-components": "~3.3.0", + "@folio/stripes-acq-components": "~3.4.0", "classnames": "^2.2.5", "final-form": "^4.19.1", "lodash": "^4.17.19", diff --git a/src/settings/AcquisitionMethods/AcquisitionMethods.js b/src/settings/AcquisitionMethods/AcquisitionMethods.js index 9c927ad51..4f7d15c09 100644 --- a/src/settings/AcquisitionMethods/AcquisitionMethods.js +++ b/src/settings/AcquisitionMethods/AcquisitionMethods.js @@ -9,6 +9,7 @@ import { stripesShape } from '@folio/stripes/core'; import { ControlledVocab } from '@folio/stripes/smart-components'; import { ACQUISITION_METHODS_API, + getControlledVocabTranslations, } from '@folio/stripes-acq-components'; import { getTranslatedAcqMethod } from '../../components/Utils/getTranslatedAcqMethod'; @@ -49,7 +50,7 @@ class AcquisitionMethods extends Component { nameKey="value" editable={stripes.hasPerm('ui-orders.settings.all')} label={intl.formatMessage({ id: 'ui-orders.settings.acquisitionMethods' })} - labelSingular={intl.formatMessage({ id: 'ui-orders.settings.acquisitionMethods.singular' })} + translations={getControlledVocabTranslations('ui-orders.settings.acquisitionMethods')} columnMapping={columnMapping} objectLabel={intl.formatMessage({ id: 'ui-orders.settings.acquisitionMethods.singular' })} formatter={formatter} diff --git a/src/settings/ClosingReasons/ClosingReasons.js b/src/settings/ClosingReasons/ClosingReasons.js index 654408822..95f34bad0 100644 --- a/src/settings/ClosingReasons/ClosingReasons.js +++ b/src/settings/ClosingReasons/ClosingReasons.js @@ -7,6 +7,7 @@ import PropTypes from 'prop-types'; import { stripesShape } from '@folio/stripes/core'; import { ControlledVocab } from '@folio/stripes/smart-components'; +import { getControlledVocabTranslations } from '@folio/stripes-acq-components'; import { CLOSING_REASONS_SOURCE, @@ -68,7 +69,7 @@ class ClosingReasons extends Component { hiddenFields={hiddenFields} id="closingReasons" label={intl.formatMessage({ id: 'ui-orders.settings.closingOrderReasons' })} - labelSingular={intl.formatMessage({ id: 'ui-orders.settings.closingReasons.reason' })} + translations={getControlledVocabTranslations('ui-orders.settings.closingReasons')} nameKey="reason" objectLabel={reasonsLabel} readOnlyFields={readOnlyFields} diff --git a/src/settings/Prefixes/Prefixes.js b/src/settings/Prefixes/Prefixes.js index 6c216f8ed..7d1bbb95b 100644 --- a/src/settings/Prefixes/Prefixes.js +++ b/src/settings/Prefixes/Prefixes.js @@ -7,7 +7,10 @@ import PropTypes from 'prop-types'; import { stripesShape } from '@folio/stripes/core'; import { ControlledVocab } from '@folio/stripes/smart-components'; -import { PREFIXES_API } from '@folio/stripes-acq-components'; +import { + getControlledVocabTranslations, + PREFIXES_API, +} from '@folio/stripes-acq-components'; import { validatePrefixSuffixName } from '../utils'; @@ -35,7 +38,7 @@ class Prefixes extends Component { hiddenFields={prefixHiddenFields} id="prefixes" label={intl.formatMessage({ id: 'ui-orders.settings.poNumber.prefixes' })} - labelSingular={intl.formatMessage({ id: 'ui-orders.settings.poNumber.prefix' })} + translations={getControlledVocabTranslations('ui-orders.settings.poNumber.prefix')} nameKey="name" objectLabel={intl.formatMessage({ id: 'ui-orders.settings.poNumber.prefix' })} records="prefixes" diff --git a/src/settings/Suffixes/Suffixes.js b/src/settings/Suffixes/Suffixes.js index 9c7016688..317a851ea 100644 --- a/src/settings/Suffixes/Suffixes.js +++ b/src/settings/Suffixes/Suffixes.js @@ -7,7 +7,10 @@ import PropTypes from 'prop-types'; import { stripesShape } from '@folio/stripes/core'; import { ControlledVocab } from '@folio/stripes/smart-components'; -import { SUFFIXES_API } from '@folio/stripes-acq-components'; +import { + getControlledVocabTranslations, + SUFFIXES_API, +} from '@folio/stripes-acq-components'; import { validatePrefixSuffixName } from '../utils'; @@ -34,7 +37,7 @@ class Suffixes extends Component { editable id="suffixes" label={intl.formatMessage({ id: 'ui-orders.settings.poNumber.suffixes' })} - labelSingular={intl.formatMessage({ id: 'ui-orders.settings.poNumber.suffix' })} + translations={getControlledVocabTranslations('ui-orders.settings.poNumber.suffix')} nameKey="name" objectLabel={intl.formatMessage({ id: 'ui-orders.settings.poNumber.suffix' })} records="suffixes" diff --git a/translations/ui-orders/en.json b/translations/ui-orders/en.json index 609b77165..7352ddd89 100644 --- a/translations/ui-orders/en.json +++ b/translations/ui-orders/en.json @@ -630,6 +630,9 @@ "settings.closingReasons.add": "Add reason", "settings.closingReasons.addBtn": "Add", "settings.closingReasons.cancelBtn": "Cancel", + "settings.closingReasons.cannotDeleteTermHeader": "Cannot delete the closing reason", + "settings.closingReasons.cannotDeleteTermMessage": "This closing reason cannot be deleted, as it is in use by one or more records.", + "settings.closingReasons.deleteEntry": "Delete closing reason", "settings.closingReasons.editBtn": "Edit", "settings.closingReasons.reason": "Reason", "settings.closingReasons.remove.error": "Reason has not been removed", @@ -639,6 +642,8 @@ "settings.closingReasons.save.success": "Reason has been successfully saved", "settings.closingReasons.saveBtn": "Save", "settings.closingReasons.System": "System", + "settings.closingReasons.termDeleted": "The closing reason {term} was successfully deleted", + "settings.closingReasons.termWillBeDeleted": "The closing reason {term} will be deleted.", "settings.closingReasons.User": "User", "settings.closingReasons.source": "Source", "settings.createInventory.eresource": "Electronic default", @@ -716,8 +721,18 @@ "settings.poNumber.modifier.description": "Description", "settings.poNumber.prefixes": "Prefixes", "settings.poNumber.prefix": "Prefix", + "settings.poNumber.prefix.cannotDeleteTermHeader": "Cannot delete the prefix", + "settings.poNumber.prefix.cannotDeleteTermMessage": "This prefix cannot be deleted, as it is in use by one or more records.", + "settings.poNumber.prefix.deleteEntry": "Delete prefix", + "settings.poNumber.prefix.termDeleted": "The prefix {term} was successfully deleted", + "settings.poNumber.prefix.termWillBeDeleted": "The prefix {term} will be deleted.", "settings.poNumber.suffixes": "Suffixes", "settings.poNumber.suffix": "Suffix", + "settings.poNumber.suffix.cannotDeleteTermHeader": "Cannot delete the suffix", + "settings.poNumber.suffix.cannotDeleteTermMessage": "This suffix cannot be deleted, as it is in use by one or more records.", + "settings.poNumber.suffix.deleteEntry": "Delete suffix", + "settings.poNumber.suffix.termDeleted": "The suffix {term} was successfully deleted", + "settings.poNumber.suffix.termWillBeDeleted": "The suffix {term} will be deleted.", "settings.poNumber.nameValidation": "Name is not valid", "settings.poNumber": "Purchase order number", "settings.saveBtn": "Save", @@ -726,8 +741,13 @@ "settings.setPOLInesLimit": "Set purchase order lines limit", "settings.acquisitionMethods": "Acquisition methods", - "settings.acquisitionMethods.singular": "Acquisition method", + "settings.acquisitionMethods.cannotDeleteTermHeader": "Cannot delete the acquisition method", + "settings.acquisitionMethods.cannotDeleteTermMessage": "This acquisition method cannot be deleted, as it is in use by one or more records.", + "settings.acquisitionMethods.deleteEntry": "Delete acquisition method", "settings.acquisitionMethods.name": "Name", + "settings.acquisitionMethods.singular": "Acquisition method", + "settings.acquisitionMethods.termDeleted": "The acquisition method {term} was successfully deleted", + "settings.acquisitionMethods.termWillBeDeleted": "The acquisition method {term} will be deleted.", "shortcut.duplicateRecord": "Duplicate a record", "shortcut.addPOL": "Add POL",