From 9abc98bdffb83c3a6f8ad51a0b32776e5b23795d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=C5=BBegle=C5=84?= Date: Mon, 26 Aug 2019 19:56:15 +0200 Subject: [PATCH] Refactor translations in product type section (#126) --- locale/messages.pot | 334 +++++++++++++++++- .../AssignAttributeDialog.tsx | 28 +- .../ProductTypeAttributeEditDialog.tsx | 17 +- .../ProductTypeAttributeUnassignDialog.tsx | 49 +-- .../ProductTypeAttributes.tsx | 212 ++++++----- ...ProductTypeBulkAttributeUnassignDialog.tsx | 56 +-- .../ProductTypeCreatePage.tsx | 8 +- .../ProductTypeDeleteDialog.tsx | 48 +-- .../ProductTypeDetails/ProductTypeDetails.tsx | 43 ++- .../ProductTypeDetailsPage.tsx | 13 +- .../ProductTypeList/ProductTypeList.tsx | 243 +++++++------ .../ProductTypeListPage.tsx | 45 ++- .../ProductTypeShipping.tsx | 65 ++-- .../ProductTypeTaxes/ProductTypeTaxes.tsx | 59 ++-- src/productTypes/index.tsx | 29 +- src/productTypes/views/ProductTypeCreate.tsx | 21 +- src/productTypes/views/ProductTypeList.tsx | 39 +- .../views/ProductTypeUpdate/index.tsx | 39 +- ...ProductTypeBulkAttributeUnassignDialog.tsx | 2 +- 19 files changed, 921 insertions(+), 429 deletions(-) diff --git a/locale/messages.pot b/locale/messages.pot index 761ed940a..cc19ffe4b 100644 --- a/locale/messages.pot +++ b/locale/messages.pot @@ -1,6 +1,6 @@ msgid "" msgstr "" -"POT-Creation-Date: 2019-08-26T17:50:42.071Z\n" +"POT-Creation-Date: 2019-08-26T17:55:41.507Z\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "MIME-Version: 1.0\n" @@ -223,6 +223,14 @@ msgctxt "button" msgid "Add product" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.json +#. [src.productTypes.components.ProductTypeListPage.889729490] - button +#. defaultMessage is: +#. Add product type +msgctxt "button" +msgid "Add product type" +msgstr "" + #: build/locale/src/orders/components/OrderDraftDetails/OrderDraftDetails.json #. [src.orders.components.OrderDraftDetails.2528459381] - button #. defaultMessage is: @@ -615,6 +623,14 @@ msgctxt "dialog content" msgid "Are you sure you want to delete {counter,plural,one{this page} other{{displayQuantity} pages}}?" msgstr "" +#: build/locale/src/productTypes/views/ProductTypeList.json +#. [src.productTypes.views.2294091098] - dialog content +#. defaultMessage is: +#. Are you sure you want to delete {counter,plural,one{this product type} other{{displayQuantity} product types}}? +msgctxt "dialog content" +msgid "Are you sure you want to delete {counter,plural,one{this product type} other{{displayQuantity} product types}}?" +msgstr "" + #: build/locale/src/products/views/ProductList/ProductList.json #. [src.products.views.ProductList.2742463171] - dialog content #. defaultMessage is: @@ -679,6 +695,14 @@ msgctxt "delete product" msgid "Are you sure you want to delete {name}?" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeDeleteDialog/ProductTypeDeleteDialog.json +#. [src.productTypes.components.ProductTypeDeleteDialog.2297471173] - delete product type +#. defaultMessage is: +#. Are you sure you want to delete {name}? +msgctxt "delete product type" +msgid "Are you sure you want to delete {name}?" +msgstr "" + #: build/locale/src/discounts/views/SaleDetails.json #. [src.discounts.views.1457489953] - dialog content #. defaultMessage is: @@ -759,6 +783,22 @@ msgctxt "description" msgid "Are you sure you want to remove this image?" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeAttributeUnassignDialog/ProductTypeAttributeUnassignDialog.json +#. [src.productTypes.components.ProductTypeAttributeUnassignDialog.722498450] +#. defaultMessage is: +#. Are you sure you want to unassign {attributeName} from {productTypeName}? +msgctxt "description" +msgid "Are you sure you want to unassign {attributeName} from {productTypeName}?" +msgstr "" + +#: build/locale/src/productTypes/components/ProductTypeBulkAttributeUnassignDialog/ProductTypeBulkAttributeUnassignDialog.json +#. [src.productTypes.components.ProductTypeBulkAttributeUnassignDialog.2500510112] - unassign multiple attributes from product type +#. defaultMessage is: +#. Are you sure you want to unassign {counter,plural,one{this attribute} other{{displayQuantity} attributes}} from {productTypeName}? +msgctxt "unassign multiple attributes from product type" +msgid "Are you sure you want to unassign {counter,plural,one{this attribute} other{{displayQuantity} attributes}} from {productTypeName}?" +msgstr "" + #: build/locale/src/discounts/views/SaleDetails.json #. [src.discounts.views.376977560] - dialog content #. defaultMessage is: @@ -835,6 +875,14 @@ msgctxt "description" msgid "Are you sure you want to void this payment?" msgstr "" +#: build/locale/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.json +#. [src.productTypes.components.AssignAttributeDialog.3922579741] - dialog header +#. defaultMessage is: +#. Assign Attribute +msgctxt "dialog header" +msgid "Assign Attribute" +msgstr "" + #: build/locale/src/discounts/components/DiscountCountrySelectDialog/DiscountCountrySelectDialog.json #. [src.discounts.components.DiscountCountrySelectDialog.1585396479] - dialog header #. defaultMessage is: @@ -843,6 +891,22 @@ msgctxt "dialog header" msgid "Assign Countries" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.json +#. [src.productTypes.components.ProductTypeAttributes.1656462109] - button +#. defaultMessage is: +#. Assign attribute +msgctxt "button" +msgid "Assign attribute" +msgstr "" + +#: build/locale/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.json +#. [src.productTypes.components.AssignAttributeDialog.2173976534] - button +#. defaultMessage is: +#. Assign attributes +msgctxt "button" +msgid "Assign attributes" +msgstr "" + #: build/locale/src/discounts/components/DiscountCategories/DiscountCategories.json #. [src.discounts.components.DiscountCategories.3973677075] - button #. defaultMessage is: @@ -915,6 +979,26 @@ msgctxt "description" msgid "Attribute deleted" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeAttributeEditDialog/ProductTypeAttributeEditDialog.json +#. [src.productTypes.components.ProductTypeAttributeEditDialog.1228425832] +#. defaultMessage is: +#. Attribute name +#: build/locale/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.json +#. [src.productTypes.components.ProductTypeAttributes.1228425832] +#. defaultMessage is: +#. Attribute name +msgctxt "description" +msgid "Attribute name" +msgstr "" + +#: build/locale/src/productTypes/components/ProductTypeAttributeEditDialog/ProductTypeAttributeEditDialog.json +#. [src.productTypes.components.ProductTypeAttributeEditDialog.335542212] +#. defaultMessage is: +#. Attribute values +msgctxt "description" +msgid "Attribute values" +msgstr "" + #: build/locale/src/intl.json #. [src.attributes] - attributes section name #. defaultMessage is: @@ -1279,6 +1363,14 @@ msgctxt "product is configurable" msgid "Configurable" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeList/ProductTypeList.json +#. [src.productTypes.components.ProductTypeList.2754779425] - product type +#. defaultMessage is: +#. Configurable +msgctxt "product type" +msgid "Configurable" +msgstr "" + #: build/locale/src/intl.json #. [src.configuration] - configuration section name #. defaultMessage is: @@ -1439,6 +1531,22 @@ msgctxt "window title" msgid "Create Product" msgstr "" +#: build/locale/src/productTypes/views/ProductTypeCreate.json +#. [productTypeCreateHeader] - window title +#. defaultMessage is: +#. Create Product Type +msgctxt "window title" +msgid "Create Product Type" +msgstr "" + +#: build/locale/src/productTypes/views/ProductTypeCreate.json +#. [productTypeCreatePageHeader] - header +#. defaultMessage is: +#. Create Product Type +msgctxt "header" +msgid "Create Product Type" +msgstr "" + #: build/locale/src/discounts/components/SaleCreatePage/SaleCreatePage.json #. [src.discounts.components.SaleCreatePage.3866518732] - page header #. defaultMessage is: @@ -1779,6 +1887,22 @@ msgctxt "dialog header" msgid "Delete Product" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeDeleteDialog/ProductTypeDeleteDialog.json +#. [src.productTypes.components.ProductTypeDeleteDialog.924066985] - dialog header +#. defaultMessage is: +#. Delete Product Type +msgctxt "dialog header" +msgid "Delete Product Type" +msgstr "" + +#: build/locale/src/productTypes/views/ProductTypeList.json +#. [src.productTypes.views.4080551769] - dialog header +#. defaultMessage is: +#. Delete Product Types +msgctxt "dialog header" +msgid "Delete Product Types" +msgstr "" + #: build/locale/src/products/views/ProductUpdate/ProductUpdate.json #. [src.products.views.ProductUpdate.1454532689] - dialog header #. defaultMessage is: @@ -2007,6 +2131,14 @@ msgctxt "description" msgid "Determine attributes used to create product types" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeList/ProductTypeList.json +#. [src.productTypes.components.ProductTypeList.881286562] - product type +#. defaultMessage is: +#. Digital +msgctxt "product type" +msgid "Digital" +msgstr "" + #: build/locale/src/home/components/HomeScreen.json #. [homeScreenDisclaimer] - header #. defaultMessage is: @@ -2503,6 +2635,14 @@ msgctxt "product variant stock" msgid "Inventory" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeShipping/ProductTypeShipping.json +#. [src.productTypes.components.ProductTypeShipping.2143413921] - switch button +#. defaultMessage is: +#. Is this product shippable? +msgctxt "switch button" +msgid "Is this product shippable?" +msgstr "" + #: build/locale/src/navigation/components/MenuList/MenuList.json #. [menuListItems] - number of menu items #. defaultMessage is: @@ -2867,6 +3007,10 @@ msgstr "" #. [src.attributes.components.AttributeList.1192828581] #. defaultMessage is: #. No attributes found +#: build/locale/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.json +#. [src.productTypes.components.ProductTypeAttributes.1192828581] +#. defaultMessage is: +#. No attributes found msgctxt "description" msgid "No attributes found" msgstr "" @@ -2971,6 +3115,14 @@ msgctxt "description" msgid "No payments waiting for capture" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeList/ProductTypeList.json +#. [src.productTypes.components.ProductTypeList.1126553969] +#. defaultMessage is: +#. No product types found +msgctxt "description" +msgid "No product types found" +msgstr "" + #: build/locale/src/categories/components/CategoryProducts/CategoryProducts.json #. [src.categories.components.CategoryProducts.1657559629] #. defaultMessage is: @@ -3007,6 +3159,14 @@ msgctxt "description" msgid "No products out of stock" msgstr "" +#: build/locale/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.json +#. [src.productTypes.components.AssignAttributeDialog.4205644805] +#. defaultMessage is: +#. No results found +msgctxt "description" +msgid "No results found" +msgstr "" + #: build/locale/src/discounts/components/SaleList/SaleList.json #. [src.discounts.components.SaleList.4101565527] #. defaultMessage is: @@ -3543,6 +3703,14 @@ msgctxt "section header" msgid "Photo View" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeList/ProductTypeList.json +#. [src.productTypes.components.ProductTypeList.966610541] - product type +#. defaultMessage is: +#. Physical +msgctxt "product type" +msgid "Physical" +msgstr "" + #: build/locale/src/attributes/components/AttributeProperties/AttributeProperties.json #. [src.attributes.components.AttributeProperties.3590282519] - attribute position in storefront filters #. defaultMessage is: @@ -3659,6 +3827,14 @@ msgctxt "product name" msgid "Product" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.json +#. [src.productTypes.components.ProductTypeAttributes.3559259966] - section header +#. defaultMessage is: +#. Product Attributes +msgctxt "section header" +msgid "Product Attributes" +msgstr "" + #: build/locale/src/discounts/components/DiscountProducts/DiscountProducts.json #. [src.discounts.components.DiscountProducts.2697405188] #. defaultMessage is: @@ -3679,6 +3855,14 @@ msgctxt "description" msgid "Product Type" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeDetails/ProductTypeDetails.json +#. [src.productTypes.components.ProductTypeDetails.1007996279] +#. defaultMessage is: +#. Product Type Name +msgctxt "description" +msgid "Product Type Name" +msgstr "" + #: build/locale/src/intl.json #. [src.productTypes] - product types section name #. defaultMessage is: @@ -3715,6 +3899,14 @@ msgctxt "description" msgid "Product removed" msgstr "" +#: build/locale/src/productTypes/views/ProductTypeUpdate/index.json +#. [src.productTypes.views.ProductTypeUpdate.3512959355] +#. defaultMessage is: +#. Product type deleted +msgctxt "description" +msgid "Product type deleted" +msgstr "" + #: build/locale/src/categories/components/CategoryProducts/CategoryProducts.json #. [src.categories.components.CategoryProducts.2968663655] - section header #. defaultMessage is: @@ -4147,6 +4339,14 @@ msgctxt "description" msgid "Saved changes" msgstr "" +#: build/locale/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.json +#. [src.productTypes.components.AssignAttributeDialog.902296540] +#. defaultMessage is: +#. Search Attributes +msgctxt "description" +msgid "Search Attributes" +msgstr "" + #: build/locale/src/orders/components/OrderCustomer/OrderCustomer.json #. [src.orders.components.OrderCustomer.2433460203] #. defaultMessage is: @@ -4179,6 +4379,14 @@ msgctxt "description" msgid "Search Products..." msgstr "" +#: build/locale/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.json +#. [src.productTypes.components.AssignAttributeDialog.524117994] +#. defaultMessage is: +#. Search by attribute name +msgctxt "description" +msgid "Search by attribute name" +msgstr "" + #: build/locale/src/discounts/components/DiscountCountrySelectDialog/DiscountCountrySelectDialog.json #. [src.discounts.components.DiscountCountrySelectDialog.2110418881] - search box placeholder #. defaultMessage is: @@ -4267,6 +4475,14 @@ msgctxt "order shipping method name" msgid "Shipping" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeShipping/ProductTypeShipping.json +#. [src.productTypes.components.ProductTypeShipping.1325966144] - product type shipping settings, section header +#. defaultMessage is: +#. Shipping +msgctxt "product type shipping settings, section header" +msgid "Shipping" +msgstr "" + #: build/locale/src/orders/components/OrderCustomer/OrderCustomer.json #. [src.orders.components.OrderCustomer.2758581442] #. defaultMessage is: @@ -4339,6 +4555,14 @@ msgctxt "product is not configurable" msgid "Simple" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeList/ProductTypeList.json +#. [src.productTypes.components.ProductTypeList.1211157042] - product type +#. defaultMessage is: +#. Simple product +msgctxt "product type" +msgid "Simple product" +msgstr "" + #: build/locale/src/intl.json #. [src.siteSettings] - site settings section name #. defaultMessage is: @@ -4359,6 +4583,14 @@ msgctxt "page internal name" msgid "Slug" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.json +#. [src.productTypes.components.ProductTypeAttributes.3478065224] - attribute internal name +#. defaultMessage is: +#. Slug +msgctxt "attribute internal name" +msgid "Slug" +msgstr "" + #: build/locale/src/orders/components/OrderDraftFinalizeDialog/OrderDraftFinalizeDialog.json #. [src.orders.components.OrderDraftFinalizeDialog.2968256006] #. defaultMessage is: @@ -4543,6 +4775,14 @@ msgctxt "description" msgid "Successfully created new page" msgstr "" +#: build/locale/src/productTypes/views/ProductTypeCreate.json +#. [src.productTypes.views.3822478981] +#. defaultMessage is: +#. Successfully created product type +msgctxt "description" +msgid "Successfully created product type" +msgstr "" + #: build/locale/src/discounts/views/SaleCreate.json #. [src.discounts.views.3707049729] #. defaultMessage is: @@ -4567,6 +4807,14 @@ msgctxt "description" msgid "Summary" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeList/ProductTypeList.json +#. [src.productTypes.components.ProductTypeList.1240292548] - tax rate for a product type +#. defaultMessage is: +#. Tax +msgctxt "tax rate for a product type" +msgid "Tax" +msgstr "" + #: build/locale/src/intl.json #. [src.taxes] - taxes section name #. defaultMessage is: @@ -4579,10 +4827,22 @@ msgstr "" #. [src.orders.components.OrderPayment.3955023266] #. defaultMessage is: #. Taxes +#: build/locale/src/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.json +#. [productTypeTaxesInputLabel] +#. defaultMessage is: +#. Taxes msgctxt "description" msgid "Taxes" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.json +#. [productTypeTaxesHeader] - section header +#. defaultMessage is: +#. Taxes +msgctxt "section header" +msgid "Taxes" +msgstr "" + #: build/locale/src/orders/components/OrderDraftDetailsSummary/OrderDraftDetailsSummary.json #. [src.orders.components.OrderDraftDetailsSummary.3202709354] #. defaultMessage is: @@ -4663,6 +4923,14 @@ msgctxt "description" msgid "This product has no variants" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.json +#. [src.productTypes.components.ProductTypeDetailsPage.1756957616] - switch button +#. defaultMessage is: +#. This product type has variants +msgctxt "switch button" +msgid "This product type has variants" +msgstr "" + #: build/locale/src/discounts/components/SalePricing/SalePricing.json #. [src.discounts.components.SalePricing.2503204759] - time during which sale is active #. defaultMessage is: @@ -4803,6 +5071,22 @@ msgctxt "product type" msgid "Type" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeList/ProductTypeList.json +#. [src.productTypes.components.ProductTypeList.1952810469] - product type is either simple or configurable +#. defaultMessage is: +#. Type +msgctxt "product type is either simple or configurable" +msgid "Type" +msgstr "" + +#: build/locale/src/productTypes/components/ProductTypeList/ProductTypeList.json +#. [src.productTypes.components.ProductTypeList.2253986440] - product type name +#. defaultMessage is: +#. Type Name +msgctxt "product type name" +msgid "Type Name" +msgstr "" + #: build/locale/src/pages/components/PageSlug/PageSlug.json #. [src.pages.components.PageSlug.1324178587] #. defaultMessage is: @@ -4867,6 +5151,30 @@ msgctxt "unassign product from voucher, button" msgid "Unassign" msgstr "" +#: build/locale/src/productTypes/views/ProductTypeUpdate/index.json +#. [src.productTypes.views.ProductTypeUpdate.870815507] - unassign attribute from product type, button +#. defaultMessage is: +#. Unassign +msgctxt "unassign attribute from product type, button" +msgid "Unassign" +msgstr "" + +#: build/locale/src/productTypes/components/ProductTypeAttributeUnassignDialog/ProductTypeAttributeUnassignDialog.json +#. [src.productTypes.components.ProductTypeAttributeUnassignDialog.404238501] - dialog header +#. defaultMessage is: +#. Unassign Attribute From Product Type +msgctxt "dialog header" +msgid "Unassign Attribute From Product Type" +msgstr "" + +#: build/locale/src/productTypes/components/ProductTypeBulkAttributeUnassignDialog/ProductTypeBulkAttributeUnassignDialog.json +#. [src.productTypes.components.ProductTypeBulkAttributeUnassignDialog.766918870] - dialog header +#. defaultMessage is: +#. Unassign Attribute from Product Type +msgctxt "dialog header" +msgid "Unassign Attribute from Product Type" +msgstr "" + #: build/locale/src/discounts/views/SaleDetails.json #. [src.discounts.views.1827854264] - dialog header #. defaultMessage is: @@ -5067,6 +5375,14 @@ msgctxt "description" msgid "Use variants for products that come in a variety of versions for example different sizes or colors" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeShipping/ProductTypeShipping.json +#. [src.productTypes.components.ProductTypeShipping.2927891783] +#. defaultMessage is: +#. Used to calculate rates for shipping for products of this product type, when specific weight is not given +msgctxt "description" +msgid "Used to calculate rates for shipping for products of this product type, when specific weight is not given" +msgstr "" + #: build/locale/src/customers/components/CustomerDetails/CustomerDetails.json #. [src.customers.components.CustomerDetails.2968565128] - check to mark this account as active #. defaultMessage is: @@ -5155,6 +5471,14 @@ msgctxt "attribute values" msgid "Values" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.json +#. [src.productTypes.components.ProductTypeAttributes.888493112] - section header +#. defaultMessage is: +#. Variant Attributes +msgctxt "section header" +msgid "Variant Attributes" +msgstr "" + #: build/locale/src/products/views/ProductVariant.json #. [src.products.views.2279302139] #. defaultMessage is: @@ -5279,6 +5603,14 @@ msgctxt "vouchers section name" msgid "Vouchers" msgstr "" +#: build/locale/src/productTypes/components/ProductTypeShipping/ProductTypeShipping.json +#. [src.productTypes.components.ProductTypeShipping.746695941] +#. defaultMessage is: +#. Weight +msgctxt "description" +msgid "Weight" +msgstr "" + #: build/locale/src/orders/components/OrderPayment/OrderPayment.json #. [orderPaymentVATDoesNotApply] - vat not included in order price #. defaultMessage is: diff --git a/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.tsx b/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.tsx index add4b20ff..a8ba7c5d2 100644 --- a/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.tsx +++ b/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.tsx @@ -15,6 +15,7 @@ import Typography from "@material-ui/core/Typography"; import makeStyles from "@material-ui/styles/makeStyles"; import React from "react"; import InfiniteScroll from "react-infinite-scroller"; +import { FormattedMessage, useIntl } from "react-intl"; import Checkbox from "@saleor/components/Checkbox"; import ConfirmButton, { @@ -23,7 +24,7 @@ import ConfirmButton, { import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useModalDialogOpen from "@saleor/hooks/useModalDialogOpen"; import useSearchQuery from "@saleor/hooks/useSearchQuery"; -import i18n from "@saleor/i18n"; +import { buttonMessages } from "@saleor/intl"; import { maybe, renderCollection } from "@saleor/misc"; import { FetchMoreProps } from "@saleor/types"; import { SearchAttributes_productType_availableAttributes_edges_node } from "../../containers/SearchAttributes/types/SearchAttributes"; @@ -73,6 +74,7 @@ const AssignAttributeDialog: React.FC = ({ onSubmit, onToggle }: AssignAttributeDialogProps) => { + const intl = useIntl(); const classes = useStyles({}); const [query, onQueryChange, resetQuery] = useSearchQuery(onFetch); const errors = useModalDialogErrors(apiErrors, open); @@ -84,17 +86,22 @@ const AssignAttributeDialog: React.FC = ({ return ( - {i18n.t("Assign Attribute")} + + + = ({ !loading && ( - {i18n.t("No results found")} + ) @@ -173,7 +180,7 @@ const AssignAttributeDialog: React.FC = ({ )} = ({ type="submit" onClick={onSubmit} > - {i18n.t("Assign attributes", { context: "button" })} + diff --git a/src/productTypes/components/ProductTypeAttributeEditDialog/ProductTypeAttributeEditDialog.tsx b/src/productTypes/components/ProductTypeAttributeEditDialog/ProductTypeAttributeEditDialog.tsx index e275ed5c8..00e1b7f63 100644 --- a/src/productTypes/components/ProductTypeAttributeEditDialog/ProductTypeAttributeEditDialog.tsx +++ b/src/productTypes/components/ProductTypeAttributeEditDialog/ProductTypeAttributeEditDialog.tsx @@ -5,11 +5,12 @@ import DialogContent from "@material-ui/core/DialogContent"; import DialogTitle from "@material-ui/core/DialogTitle"; import TextField from "@material-ui/core/TextField"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import Form from "@saleor/components/Form"; import { FormSpacer } from "@saleor/components/FormSpacer"; import ListField from "@saleor/components/ListField"; -import i18n from "../../../i18n"; +import { buttonMessages } from "@saleor/intl"; export interface FormData { name: string; @@ -39,6 +40,8 @@ export interface ProductTypeAttributeEditDialogProps { const ProductTypeAttributeEditDialog: React.StatelessComponent< ProductTypeAttributeEditDialogProps > = ({ disabled, errors, name, opened, title, values, onClose, onConfirm }) => { + const intl = useIntl(); + const initialForm: FormData = { name: name || "", values: values || [] @@ -54,7 +57,9 @@ const ProductTypeAttributeEditDialog: React.StatelessComponent< disabled={disabled} error={!!formErrors.name} fullWidth - label={i18n.t("Attribute name")} + label={intl.formatMessage({ + defaultMessage: "Attribute name" + })} helperText={formErrors.name} name="name" value={data.name} @@ -71,7 +76,9 @@ const ProductTypeAttributeEditDialog: React.StatelessComponent< } fullWidth name="values" - label={i18n.t("Attribute values")} + label={intl.formatMessage({ + defaultMessage: "Attribute values" + })} helperText={ formErrors.values || formErrors.addValues || @@ -83,10 +90,10 @@ const ProductTypeAttributeEditDialog: React.StatelessComponent< diff --git a/src/productTypes/components/ProductTypeAttributeUnassignDialog/ProductTypeAttributeUnassignDialog.tsx b/src/productTypes/components/ProductTypeAttributeUnassignDialog/ProductTypeAttributeUnassignDialog.tsx index e99ce0a0c..5a1f2e077 100644 --- a/src/productTypes/components/ProductTypeAttributeUnassignDialog/ProductTypeAttributeUnassignDialog.tsx +++ b/src/productTypes/components/ProductTypeAttributeUnassignDialog/ProductTypeAttributeUnassignDialog.tsx @@ -1,9 +1,9 @@ import DialogContentText from "@material-ui/core/DialogContentText"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import ActionDialog from "@saleor/components/ActionDialog"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; -import i18n from "@saleor/i18n"; export interface ProductTypeAttributeUnassignDialogProps { attributeName: string; @@ -23,27 +23,32 @@ const ProductTypeAttributeUnassignDialog: React.FC< productTypeName, onClose, onConfirm -}) => ( - - {{ attributeName }} from {{ productTypeName }}?", - { - attributeName, - productTypeName - } - ) - }} - /> - -); +}) => { + const intl = useIntl(); + + return ( + + + {attributeName}, + productTypeName: {productTypeName} + }} + /> + + + ); +}; ProductTypeAttributeUnassignDialog.displayName = "ProductTypeAttributeUnassignDialog"; export default ProductTypeAttributeUnassignDialog; diff --git a/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.tsx b/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.tsx index 99087212c..5dd83dc41 100644 --- a/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.tsx +++ b/src/productTypes/components/ProductTypeAttributes/ProductTypeAttributes.tsx @@ -12,6 +12,7 @@ import TableCell from "@material-ui/core/TableCell"; import TableRow from "@material-ui/core/TableRow"; import DeleteIcon from "@material-ui/icons/Delete"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import Checkbox from "@saleor/components/Checkbox"; @@ -21,7 +22,6 @@ import { SortableTableRow } from "@saleor/components/SortableTable"; import TableHead from "@saleor/components/TableHead"; -import i18n from "@saleor/i18n"; import { maybe, renderCollection, stopPropagation } from "@saleor/misc"; import { ListActions, ReorderAction } from "@saleor/types"; import { AttributeTypeEnum } from "@saleor/types/globalTypes"; @@ -81,105 +81,123 @@ const ProductTypeAttributes = withStyles(styles, { onAttributeClick, onAttributeReorder, onAttributeUnassign - }: ProductTypeAttributesProps & WithStyles) => ( - - onAttributeAssign(AttributeTypeEnum[type])} - > - {i18n.t("Assign attribute", { context: "button" })} - - } - /> - - - - {i18n.t("Attribute name")} - - {i18n.t("Slug")} - - - - {renderCollection( - attributes, - (attribute, attributeIndex) => { - const isSelected = attribute ? isChecked(attribute.id) : false; + }: ProductTypeAttributesProps & WithStyles) => { + const intl = useIntl(); - return ( - onAttributeClick(attribute.id) - : undefined - } - key={maybe(() => attribute.id)} - index={attributeIndex || 0} - > - - toggle(attribute.id)} - /> - - - {maybe(() => attribute.name) ? ( - attribute.name - ) : ( - - )} - - - {maybe(() => attribute.slug) ? ( - attribute.slug - ) : ( - - )} - - - - onAttributeUnassign(attribute.id) + return ( + + onAttributeAssign(AttributeTypeEnum[type])} + > + + + } + /> +
+ + + + + + + + + + + {renderCollection( + attributes, + (attribute, attributeIndex) => { + const isSelected = attribute ? isChecked(attribute.id) : false; + + return ( + onAttributeClick(attribute.id) + : undefined + } + key={maybe(() => attribute.id)} + index={attributeIndex || 0} + > + + toggle(attribute.id)} + /> + + + {maybe(() => attribute.name) ? ( + attribute.name + ) : ( + )} - > - - + + + {maybe(() => attribute.slug) ? ( + attribute.slug + ) : ( + + )} + + + + onAttributeUnassign(attribute.id) + )} + > + + + + + ); + }, + () => ( + + + - - ); - }, - () => ( - - - {i18n.t("No attributes found")} - - - ) - )} - -
-
- ) + + ) + )} + + + + ); + } ); ProductTypeAttributes.displayName = "ProductTypeAttributes"; export default ProductTypeAttributes; diff --git a/src/productTypes/components/ProductTypeBulkAttributeUnassignDialog/ProductTypeBulkAttributeUnassignDialog.tsx b/src/productTypes/components/ProductTypeBulkAttributeUnassignDialog/ProductTypeBulkAttributeUnassignDialog.tsx index 0f73c08c4..7f0de5fd4 100644 --- a/src/productTypes/components/ProductTypeBulkAttributeUnassignDialog/ProductTypeBulkAttributeUnassignDialog.tsx +++ b/src/productTypes/components/ProductTypeBulkAttributeUnassignDialog/ProductTypeBulkAttributeUnassignDialog.tsx @@ -1,12 +1,12 @@ import DialogContentText from "@material-ui/core/DialogContentText"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import ActionDialog from "@saleor/components/ActionDialog"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; -import i18n from "@saleor/i18n"; export interface ProductTypeBulkAttributeUnassignDialogProps { - attributeQuantity: string; + attributeQuantity: number; confirmButtonState: ConfirmButtonTransitionState; open: boolean; productTypeName: string; @@ -23,27 +23,37 @@ const ProductTypeBulkAttributeUnassignDialog: React.FC< productTypeName, onClose, onConfirm -}) => ( - - {{ attributeQuantity }} attributes from {{ productTypeName }}?", - { - attributeQuantity, - productTypeName - } - ) - }} - /> - -); +}) => { + const intl = useIntl(); + + return ( + + + {attributeQuantity}, + counter: attributeQuantity, + productTypeName: {productTypeName} + }} + /> + + + ); +}; ProductTypeBulkAttributeUnassignDialog.displayName = "ProductTypeBulkAttributeUnassignDialog"; export default ProductTypeBulkAttributeUnassignDialog; diff --git a/src/productTypes/components/ProductTypeCreatePage/ProductTypeCreatePage.tsx b/src/productTypes/components/ProductTypeCreatePage/ProductTypeCreatePage.tsx index 10ce39d20..fd639bad6 100644 --- a/src/productTypes/components/ProductTypeCreatePage/ProductTypeCreatePage.tsx +++ b/src/productTypes/components/ProductTypeCreatePage/ProductTypeCreatePage.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { useIntl } from "react-intl"; import AppHeader from "@saleor/components/AppHeader"; import CardSpacer from "@saleor/components/CardSpacer"; @@ -10,7 +11,7 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { ChangeEvent, FormChange } from "@saleor/hooks/useForm"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; -import i18n from "@saleor/i18n"; +import { sectionNames } from "@saleor/intl"; import { ProductTypeDetails_taxTypes } from "@saleor/productTypes/types/ProductTypeDetails"; import { UserError } from "@saleor/types"; import { WeightUnitsEnum } from "@saleor/types/globalTypes"; @@ -67,6 +68,7 @@ const ProductTypeCreatePage: React.StatelessComponent< onBack, onSubmit }: ProductTypeCreatePageProps) => { + const intl = useIntl(); const [taxTypeDisplayName, setTaxTypeDisplayName] = useStateFromProps(""); return ( @@ -78,7 +80,9 @@ const ProductTypeCreatePage: React.StatelessComponent< > {({ change, data, errors: formErrors, hasChanged, submit }) => ( - {i18n.t("Product Types")} + + {intl.formatMessage(sectionNames.productTypes)} +
diff --git a/src/productTypes/components/ProductTypeDeleteDialog/ProductTypeDeleteDialog.tsx b/src/productTypes/components/ProductTypeDeleteDialog/ProductTypeDeleteDialog.tsx index 56d42e316..fa64b7e1f 100644 --- a/src/productTypes/components/ProductTypeDeleteDialog/ProductTypeDeleteDialog.tsx +++ b/src/productTypes/components/ProductTypeDeleteDialog/ProductTypeDeleteDialog.tsx @@ -1,9 +1,9 @@ import DialogContentText from "@material-ui/core/DialogContentText"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import ActionDialog from "@saleor/components/ActionDialog"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; -import i18n from "@saleor/i18n"; export interface ProductTypeDeleteDialogProps { confirmButtonState: ConfirmButtonTransitionState; @@ -19,25 +19,31 @@ const ProductTypeDeleteDialog: React.FC = ({ name, onClose, onConfirm -}) => ( - - {{ name }}?", - { - name - } - ) - }} - /> - -); +}) => { + const intl = useIntl(); + + return ( + + + {name} + }} + /> + + + ); +}; ProductTypeDeleteDialog.displayName = "ProductTypeDeleteDialog"; export default ProductTypeDeleteDialog; diff --git a/src/productTypes/components/ProductTypeDetails/ProductTypeDetails.tsx b/src/productTypes/components/ProductTypeDetails/ProductTypeDetails.tsx index dfe12c937..6a9d6643d 100644 --- a/src/productTypes/components/ProductTypeDetails/ProductTypeDetails.tsx +++ b/src/productTypes/components/ProductTypeDetails/ProductTypeDetails.tsx @@ -3,9 +3,10 @@ import CardContent from "@material-ui/core/CardContent"; import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles"; import TextField from "@material-ui/core/TextField"; import React from "react"; +import { useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; -import i18n from "@saleor/i18n"; +import { commonMessages } from "@saleor/intl"; import { FormErrors } from "@saleor/types"; const styles = createStyles({ @@ -24,23 +25,31 @@ interface ProductTypeDetailsProps extends WithStyles { } const ProductTypeDetails = withStyles(styles, { name: "ProductTypeDetails" })( - ({ classes, data, disabled, errors, onChange }: ProductTypeDetailsProps) => ( - - - - { + const intl = useIntl(); + + return ( + + - - - ) + + + + + ); + } ); ProductTypeDetails.displayName = "ProductTypeDetails"; export default ProductTypeDetails; diff --git a/src/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx b/src/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx index e0193475f..2b4bfb9af 100644 --- a/src/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx +++ b/src/productTypes/components/ProductTypeDetailsPage/ProductTypeDetailsPage.tsx @@ -1,4 +1,5 @@ import React from "react"; +import { useIntl } from "react-intl"; import AppHeader from "@saleor/components/AppHeader"; import CardSpacer from "@saleor/components/CardSpacer"; @@ -11,7 +12,7 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { ChangeEvent, FormChange } from "@saleor/hooks/useForm"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; -import i18n from "@saleor/i18n"; +import { sectionNames } from "@saleor/intl"; import { maybe } from "@saleor/misc"; import { ListActions, ReorderEvent, UserError } from "@saleor/types"; import { AttributeTypeEnum, WeightUnitsEnum } from "@saleor/types/globalTypes"; @@ -90,6 +91,7 @@ const ProductTypeDetailsPage: React.StatelessComponent< onDelete, onSubmit }) => { + const intl = useIntl(); const [taxTypeDisplayName, setTaxTypeDisplayName] = useStateFromProps( maybe(() => productType.taxType.description) ); @@ -129,7 +131,9 @@ const ProductTypeDetailsPage: React.StatelessComponent< > {({ change, data, errors: formErrors, hasChanged, submit }) => ( - {i18n.t("Product Types")} + + {intl.formatMessage(sectionNames.productTypes)} +
@@ -171,7 +175,10 @@ const ProductTypeDetailsPage: React.StatelessComponent< diff --git a/src/productTypes/components/ProductTypeList/ProductTypeList.tsx b/src/productTypes/components/ProductTypeList/ProductTypeList.tsx index 1e2fdfc5a..afb28f5b6 100644 --- a/src/productTypes/components/ProductTypeList/ProductTypeList.tsx +++ b/src/productTypes/components/ProductTypeList/ProductTypeList.tsx @@ -12,12 +12,12 @@ import TableFooter from "@material-ui/core/TableFooter"; import TableRow from "@material-ui/core/TableRow"; import Typography from "@material-ui/core/Typography"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import Checkbox from "@saleor/components/Checkbox"; import Skeleton from "@saleor/components/Skeleton"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; -import i18n from "../../../i18n"; import { maybe, renderCollection } from "../../../misc"; import { ListActions, ListProps } from "../../../types"; import { ProductTypeList_productTypes_edges_node } from "../../types/ProductTypeList"; @@ -64,115 +64,144 @@ const ProductTypeList = withStyles(styles, { name: "ProductTypeList" })( toggle, toggleAll, toolbar - }: ProductTypeListProps) => ( - - - - - {i18n.t("Type Name", { context: "table header" })} - - - {i18n.t("Type", { context: "table header" })} - - - {i18n.t("Tax", { context: "table header" })} - - - - - - - - - {renderCollection( - productTypes, - productType => { - const isSelected = productType - ? isChecked(productType.id) - : false; - return ( - - - toggle(productType.id)} - /> - - - {productType ? ( - <> - {productType.name} - - {maybe(() => productType.hasVariants) - ? i18n.t("Configurable", { - context: "product type" - }) - : i18n.t("Simple product", { - context: "product type" - })} - - - ) : ( - - )} - - - {maybe(() => productType.isShippingRequired) !== - undefined ? ( - productType.isShippingRequired ? ( - <>{i18n.t("Physical", { context: "product type" })} + }: ProductTypeListProps) => { + const intl = useIntl(); + + return ( + +
+ + + + + + + + + + + + + + + + + + {renderCollection( + productTypes, + productType => { + const isSelected = productType + ? isChecked(productType.id) + : false; + return ( + + + toggle(productType.id)} + /> + + + {productType ? ( + <> + {productType.name} + + {maybe(() => productType.hasVariants) + ? intl.formatMessage({ + defaultMessage: "Configurable", + description: "product type" + }) + : intl.formatMessage({ + defaultMessage: "Simple product", + description: "product type" + })} + + ) : ( - <>{i18n.t("Digital", { context: "product type" })} - ) - ) : ( - - )} - - - {maybe(() => productType.taxType) ? ( - productType.taxType.description - ) : ( - - )} + + )} + + + {maybe(() => productType.isShippingRequired) !== + undefined ? ( + productType.isShippingRequired ? ( + <> + + + ) : ( + <> + + + ) + ) : ( + + )} + + + {maybe(() => productType.taxType) ? ( + productType.taxType.description + ) : ( + + )} + + + ); + }, + () => ( + + + - ); - }, - () => ( - - - {i18n.t("No product types found")} - - - ) - )} - -
-
- ) + ) + )} + + + + ); + } ); ProductTypeList.displayName = "ProductTypeList"; export default ProductTypeList; diff --git a/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx b/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx index 67d130f2e..be7a96916 100644 --- a/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx +++ b/src/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx @@ -1,11 +1,12 @@ import Button from "@material-ui/core/Button"; import AddIcon from "@material-ui/icons/Add"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import AppHeader from "@saleor/components/AppHeader"; import Container from "@saleor/components/Container"; import PageHeader from "@saleor/components/PageHeader"; -import i18n from "../../../i18n"; +import { sectionNames } from "@saleor/intl"; import { ListActions, PageListProps } from "../../../types"; import { ProductTypeList_productTypes_edges_node } from "../../types/ProductTypeList"; import ProductTypeList from "../ProductTypeList"; @@ -17,21 +18,31 @@ interface ProductTypeListPageProps extends PageListProps, ListActions { const ProductTypeListPage: React.StatelessComponent< ProductTypeListPageProps -> = ({ disabled, onAdd, onBack, ...listProps }) => ( - - {i18n.t("Configuration")} - - - - - -); +> = ({ disabled, onAdd, onBack, ...listProps }) => { + const intl = useIntl(); + + return ( + + + {intl.formatMessage(sectionNames.configuration)} + + + + + + + ); +}; ProductTypeListPage.displayName = "ProductTypeListPage"; export default ProductTypeListPage; diff --git a/src/productTypes/components/ProductTypeShipping/ProductTypeShipping.tsx b/src/productTypes/components/ProductTypeShipping/ProductTypeShipping.tsx index be0b5daa2..df400dbed 100644 --- a/src/productTypes/components/ProductTypeShipping/ProductTypeShipping.tsx +++ b/src/productTypes/components/ProductTypeShipping/ProductTypeShipping.tsx @@ -2,10 +2,10 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import React from "react"; +import { useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import { ControlledCheckbox } from "@saleor/components/ControlledCheckbox"; -import i18n from "../../../i18n"; import { WeightUnitsEnum } from "../../../types/globalTypes"; interface ProductTypeShippingProps { @@ -20,34 +20,49 @@ interface ProductTypeShippingProps { const ProductTypeShipping: React.StatelessComponent< ProductTypeShippingProps -> = ({ data, defaultWeightUnit, disabled, onChange }) => ( - - - - = ({ data, defaultWeightUnit, disabled, onChange }) => { + const intl = useIntl(); + + return ( + + - {data.isShippingRequired && ( - + - )} - - -); + {data.isShippingRequired && ( + + )} + + + ); +}; ProductTypeShipping.displayName = "ProductTypeShipping"; export default ProductTypeShipping; diff --git a/src/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.tsx b/src/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.tsx index a03edfd79..3b2985c9a 100644 --- a/src/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.tsx +++ b/src/productTypes/components/ProductTypeTaxes/ProductTypeTaxes.tsx @@ -2,11 +2,11 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles"; import React from "react"; +import { useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import SingleAutocompleteSelectField from "@saleor/components/SingleAutocompleteSelectField"; import { ProductTypeDetails_taxTypes } from "@saleor/productTypes/types/ProductTypeDetails"; -import i18n from "../../../i18n"; import { maybe } from "../../../misc"; import { ProductTypeForm } from "../ProductTypeDetailsPage/ProductTypeDetailsPage"; @@ -34,29 +34,42 @@ const ProductTypeTaxes = withStyles(styles, { name: "ProductTypeTaxes" })( taxTypes, taxTypeDisplayName, onChange - }: ProductTypeTaxesProps) => ( - - - - - taxTypes.map(c => ({ label: c.description, value: c.taxCode })), - [] - )} - InputProps={{ - autoComplete: "off" - }} + }: ProductTypeTaxesProps) => { + const intl = useIntl(); + + return ( + + - - - ) + + + taxTypes.map(c => ({ label: c.description, value: c.taxCode })), + [] + )} + InputProps={{ + autoComplete: "off" + }} + /> + + + ); + } ); ProductTypeTaxes.displayName = "ProductTypeTaxes"; export default ProductTypeTaxes; diff --git a/src/productTypes/index.tsx b/src/productTypes/index.tsx index b80cb3dcf..dbde2f8f0 100644 --- a/src/productTypes/index.tsx +++ b/src/productTypes/index.tsx @@ -1,9 +1,10 @@ import { parse as parseQs } from "qs"; import React from "react"; +import { useIntl } from "react-intl"; import { Route, RouteComponentProps, Switch } from "react-router-dom"; +import { sectionNames } from "@saleor/intl"; import { WindowTitle } from "../components/WindowTitle"; -import i18n from "../i18n"; import { productTypeAddPath, productTypeListPath, @@ -40,17 +41,19 @@ const ProductTypeUpdate: React.StatelessComponent< ); }; -export const ProductTypeRouter: React.StatelessComponent< - RouteComponentProps -> = () => ( - <> - - - - - - - -); +export const ProductTypeRouter: React.FC = () => { + const intl = useIntl(); + + return ( + <> + + + + + + + + ); +}; ProductTypeRouter.displayName = "ProductTypeRouter"; export default ProductTypeRouter; diff --git a/src/productTypes/views/ProductTypeCreate.tsx b/src/productTypes/views/ProductTypeCreate.tsx index 2427377f1..0030d5248 100644 --- a/src/productTypes/views/ProductTypeCreate.tsx +++ b/src/productTypes/views/ProductTypeCreate.tsx @@ -1,9 +1,9 @@ import React from "react"; +import { useIntl } from "react-intl"; import { WindowTitle } from "@saleor/components/WindowTitle"; import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; -import i18n from "../../i18n"; import { getMutationState, maybe } from "../../misc"; import ProductTypeCreatePage, { ProductTypeForm @@ -16,11 +16,14 @@ import { productTypeListUrl, productTypeUrl } from "../urls"; export const ProductTypeCreate: React.StatelessComponent = () => { const navigate = useNavigator(); const notify = useNotifier(); + const intl = useIntl(); const handleCreateSuccess = (updateData: ProductTypeCreateMutation) => { if (updateData.productTypeCreate.errors.length === 0) { notify({ - text: i18n.t("Successfully created product type") + text: intl.formatMessage({ + defaultMessage: "Successfully created product type" + }) }); navigate(productTypeUrl(updateData.productTypeCreate.productType.id)); } @@ -48,7 +51,13 @@ export const ProductTypeCreate: React.StatelessComponent = () => { {({ data, loading }) => ( <> - + data.shop.defaultWeightUnit)} disabled={loading} @@ -57,8 +66,10 @@ export const ProductTypeCreate: React.StatelessComponent = () => { ? createProductTypeData.productTypeCreate.errors : undefined } - pageTitle={i18n.t("Create Product Type", { - context: "page title" + pageTitle={intl.formatMessage({ + defaultMessage: "Create Product Type", + description: "header", + id: "productTypeCreatePageHeader" })} saveButtonBarState={formTransitionState} taxTypes={maybe(() => data.taxTypes, [])} diff --git a/src/productTypes/views/ProductTypeList.tsx b/src/productTypes/views/ProductTypeList.tsx index 101b9fc26..ca83ccc45 100644 --- a/src/productTypes/views/ProductTypeList.tsx +++ b/src/productTypes/views/ProductTypeList.tsx @@ -2,6 +2,7 @@ import DialogContentText from "@material-ui/core/DialogContentText"; import IconButton from "@material-ui/core/IconButton"; import DeleteIcon from "@material-ui/icons/Delete"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import ActionDialog from "@saleor/components/ActionDialog"; import useBulkActions from "@saleor/hooks/useBulkActions"; @@ -10,9 +11,9 @@ import useNotifier from "@saleor/hooks/useNotifier"; import usePaginator, { createPaginationState } from "@saleor/hooks/usePaginator"; +import { commonMessages } from "@saleor/intl"; import { PAGINATE_BY } from "../../config"; import { configurationMenuUrl } from "../../configuration"; -import i18n from "../../i18n"; import { getMutationState, maybe } from "../../misc"; import ProductTypeListPage from "../components/ProductTypeListPage"; import { TypedProductTypeBulkDeleteMutation } from "../mutations"; @@ -38,6 +39,7 @@ export const ProductTypeList: React.StatelessComponent< const { isSelected, listElements, reset, toggle, toggleAll } = useBulkActions( params.ids ); + const intl = useIntl(); const closeModal = () => navigate(productTypeListUrl(), true); @@ -54,7 +56,7 @@ export const ProductTypeList: React.StatelessComponent< const handleProductTypeBulkDelete = (data: ProductTypeBulkDelete) => { if (data.productTypeBulkDelete.errors.length === 0) { notify({ - text: i18n.t("Removed product types") + text: intl.formatMessage(commonMessages.savedChanges) }); reset(); refetch(); @@ -126,22 +128,27 @@ export const ProductTypeList: React.StatelessComponent< onClose={closeModal} onConfirm={onProductTypeBulkDelete} open={params.action === "remove"} - title={i18n.t("Remove Product Types")} + title={intl.formatMessage({ + defaultMessage: "Delete Product Types", + description: "dialog header" + })} variant="delete" > - {{ number }} product types?", - { - number: maybe( - () => params.ids.length.toString(), - "..." - ) - } - ) - }} - /> + + params.ids.length), + displayQuantity: ( + {maybe(() => params.ids.length)} + ) + }} + /> + ); diff --git a/src/productTypes/views/ProductTypeUpdate/index.tsx b/src/productTypes/views/ProductTypeUpdate/index.tsx index 1e59ccb7c..67f94a381 100644 --- a/src/productTypes/views/ProductTypeUpdate/index.tsx +++ b/src/productTypes/views/ProductTypeUpdate/index.tsx @@ -1,12 +1,13 @@ import Button from "@material-ui/core/Button"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import { attributeUrl } from "@saleor/attributes/urls"; import { WindowTitle } from "@saleor/components/WindowTitle"; import useBulkActions from "@saleor/hooks/useBulkActions"; import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; -import i18n from "@saleor/i18n"; +import { commonMessages } from "@saleor/intl"; import { getMutationState, maybe } from "@saleor/misc"; import AssignAttributeDialog from "@saleor/productTypes/components/AssignAttributeDialog"; import { ReorderEvent } from "@saleor/types"; @@ -44,6 +45,7 @@ export const ProductTypeUpdate: React.FC = ({ const notify = useNotifier(); const productAttributeListActions = useBulkActions(); const variantAttributeListActions = useBulkActions(); + const intl = useIntl(); return ( @@ -59,9 +61,7 @@ export const ProductTypeUpdate: React.FC = ({ const handleAttributeAssignSuccess = (data: AssignAttribute) => { if (data.attributeAssign.errors.length === 0) { notify({ - text: i18n.t("Attributes assigned", { - context: "notification" - }) + text: intl.formatMessage(commonMessages.savedChanges) }); closeModal(); } else if ( @@ -76,9 +76,7 @@ export const ProductTypeUpdate: React.FC = ({ ) => { if (data.attributeUnassign.errors.length === 0) { notify({ - text: i18n.t("Attribute unassigned", { - context: "notification" - }) + text: intl.formatMessage(commonMessages.savedChanges) }); closeModal(); productAttributeListActions.reset(); @@ -90,8 +88,8 @@ export const ProductTypeUpdate: React.FC = ({ ) => { if (deleteData.productTypeDelete.errors.length === 0) { notify({ - text: i18n.t("Product type deleted", { - context: "notification" + text: intl.formatMessage({ + defaultMessage: "Product type deleted" }) }); navigate(productTypeListUrl(), true); @@ -105,9 +103,7 @@ export const ProductTypeUpdate: React.FC = ({ updateData.productTypeUpdate.errors.length === 0 ) { notify({ - text: i18n.t("Product type updated", { - context: "notification" - }) + text: intl.formatMessage(commonMessages.savedChanges) }); } else if ( updateData.productTypeUpdate.errors !== null && @@ -290,9 +286,10 @@ export const ProductTypeUpdate: React.FC = ({ ) } > - {i18n.t("Unassign", { - context: "unassign attribute from product type" - })} + ) }} @@ -315,9 +312,10 @@ export const ProductTypeUpdate: React.FC = ({ ) } > - {i18n.t("Unassign", { - context: "unassign attribute from product type" - })} + ) }} @@ -433,10 +431,7 @@ export const ProductTypeUpdate: React.FC = ({ onConfirm={handleProductTypeDelete} /> params.ids.length.toString(), - "..." - )} + attributeQuantity={maybe(() => params.ids.length)} confirmButtonState={unassignTransactionState} onClose={closeModal} onConfirm={handleBulkAttributeUnassign} diff --git a/src/storybook/stories/productTypes/ProductTypeBulkAttributeUnassignDialog.tsx b/src/storybook/stories/productTypes/ProductTypeBulkAttributeUnassignDialog.tsx index 1c3941025..97e60fbe7 100644 --- a/src/storybook/stories/productTypes/ProductTypeBulkAttributeUnassignDialog.tsx +++ b/src/storybook/stories/productTypes/ProductTypeBulkAttributeUnassignDialog.tsx @@ -7,7 +7,7 @@ import ProductTypeBulkAttributeUnassignDialog, { import Decorator from "../../Decorator"; const props: ProductTypeBulkAttributeUnassignDialogProps = { - attributeQuantity: "4", + attributeQuantity: 4, confirmButtonState: "default", onClose: () => undefined, onConfirm: () => undefined,