diff --git a/locale/messages.pot b/locale/messages.pot index e8a9ca967..b8b4390f7 100644 --- a/locale/messages.pot +++ b/locale/messages.pot @@ -1,6 +1,6 @@ msgid "" msgstr "" -"POT-Creation-Date: 2019-08-26T14:18:06.591Z\n" +"POT-Creation-Date: 2019-08-26T14:24:42.452Z\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "MIME-Version: 1.0\n" @@ -51,6 +51,30 @@ msgctxt "dialog title" msgid "Add Address" msgstr "" +#: build/locale/src/navigation/components/MenuItemDialog/MenuItemDialog.json +#. [menuItemDialogAddItem] - create new menu item, header +#. defaultMessage is: +#. Add Item +msgctxt "create new menu item, header" +msgid "Add Item" +msgstr "" + +#: build/locale/src/navigation/components/MenuCreateDialog/MenuCreateDialog.json +#. [menuCreateDialogHeader] - dialog header +#. defaultMessage is: +#. Add Menu +msgctxt "dialog header" +msgid "Add Menu" +msgstr "" + +#: build/locale/src/navigation/components/MenuListPage/MenuListPage.json +#. [menuListPageAddMenu] - button +#. defaultMessage is: +#. Add Menu +msgctxt "button" +msgid "Add Menu" +msgstr "" + #: build/locale/src/discounts/components/SaleListPage/SaleListPage.json #. [src.discounts.components.SaleListPage.1742771332] - button #. defaultMessage is: @@ -123,6 +147,22 @@ msgctxt "button" msgid "Add customer" msgstr "" +#: build/locale/src/navigation/components/MenuItems/MenuItems.json +#. [menuItemsAddItem] - add new menu item +#. defaultMessage is: +#. Add new item +msgctxt "add new menu item" +msgid "Add new item" +msgstr "" + +#: build/locale/src/navigation/components/MenuItems/MenuItems.json +#. [menuItemsPlaceholder] +#. defaultMessage is: +#. Add new menu item to begin creating menu +msgctxt "description" +msgid "Add new menu item to begin creating menu" +msgstr "" + #: build/locale/src/categories/components/CategoryProducts/CategoryProducts.json #. [src.categories.components.CategoryProducts.3554578821] - button #. defaultMessage is: @@ -271,6 +311,14 @@ msgctxt "description" msgid "Are you sure you want to delete collection's image?" msgstr "" +#: build/locale/src/navigation/views/MenuDetails/index.json +#. [menuDetailsDeleteMenuContent] +#. defaultMessage is: +#. Are you sure you want to delete menu {menuName}? +msgctxt "description" +msgid "Are you sure you want to delete menu {menuName}?" +msgstr "" + #: build/locale/src/customers/views/CustomerAddresses.json #. [src.customers.views.3689332763] #. defaultMessage is: @@ -355,6 +403,14 @@ msgctxt "description" msgid "Are you sure you want to delete {counter,plural,one{this customer} other{{displayQuantity} customers}}?" msgstr "" +#: build/locale/src/navigation/views/MenuList.json +#. [menuListDeleteMenusContent] +#. defaultMessage is: +#. Are you sure you want to delete {counter,plural,one{this menu} other{{displayQuantity} menus}}? +msgctxt "description" +msgid "Are you sure you want to delete {counter,plural,one{this menu} other{{displayQuantity} menus}}?" +msgstr "" + #: build/locale/src/discounts/views/SaleList.json #. [src.discounts.views.2516361175] - dialog content #. defaultMessage is: @@ -379,6 +435,14 @@ msgctxt "delete customer, dialog content" msgid "Are you sure you want to delete {email}?" msgstr "" +#: build/locale/src/navigation/views/MenuList.json +#. [menuListDeleteMenuContent] +#. defaultMessage is: +#. Are you sure you want to delete {menuName}? +msgctxt "description" +msgid "Are you sure you want to delete {menuName}?" +msgstr "" + #: build/locale/src/discounts/views/SaleDetails.json #. [src.discounts.views.1457489953] - dialog content #. defaultMessage is: @@ -588,7 +652,7 @@ msgid "Billing address" msgstr "" #: build/locale/src/intl.json -#. [src.cancel] - button +#. [cancel] - button #. defaultMessage is: #. Cancel msgctxt "button" @@ -728,7 +792,7 @@ msgid "Configuration" msgstr "" #: build/locale/src/intl.json -#. [src.confirm] - button +#. [confirm] - button #. defaultMessage is: #. Confirm msgctxt "button" @@ -815,6 +879,22 @@ msgctxt "description" msgid "Created collection" msgstr "" +#: build/locale/src/navigation/views/MenuList.json +#. [menuListCreatedMenu] +#. defaultMessage is: +#. Created menu +msgctxt "description" +msgid "Created menu" +msgstr "" + +#: build/locale/src/navigation/components/MenuDetailsPage/MenuDetailsPage.json +#. [menuDetailsPageHelperText] +#. defaultMessage is: +#. Creating the navigation structure is done by dragging and dropping. Simply create a new menu item and then drag it into its destined place. You can move items inside one another to create a tree structure and drag items up and down to create a hierarchy +msgctxt "description" +msgid "Creating the navigation structure is done by dragging and dropping. Simply create a new menu item and then drag it into its destined place. You can move items inside one another to create a tree structure and drag items up and down to create a hierarchy" +msgstr "" + #: build/locale/src/customers/components/CustomerList/CustomerList.json #. [src.customers.components.CustomerList.2339105195] #. defaultMessage is: @@ -1095,6 +1175,26 @@ msgctxt "dialog title" msgid "Delete image" msgstr "" +#: build/locale/src/navigation/views/MenuDetails/index.json +#. [menuDetailsDeleteMenuHeader] - dialog header +#. defaultMessage is: +#. Delete menu +#: build/locale/src/navigation/views/MenuList.json +#. [menuListDeleteMenuHeader] - dialog header +#. defaultMessage is: +#. Delete menu +msgctxt "dialog header" +msgid "Delete menu" +msgstr "" + +#: build/locale/src/navigation/views/MenuList.json +#. [menuListDeleteMenusHeader] - dialog header +#. defaultMessage is: +#. Delete menus +msgctxt "dialog header" +msgid "Delete menus" +msgstr "" + #: build/locale/src/categories/views/CategoryDetails.json #. [src.categories.views.2507763081] - dialog title #. defaultMessage is: @@ -1111,6 +1211,14 @@ msgctxt "description" msgid "Deleted collection" msgstr "" +#: build/locale/src/navigation/views/MenuList.json +#. [menuListDeletedMenu] +#. defaultMessage is: +#. Deleted menu +msgctxt "description" +msgid "Deleted menu" +msgstr "" + #: build/locale/src/collections/views/CollectionDetails.json #. [src.collections.views.3482612628] #. defaultMessage is: @@ -1204,7 +1312,7 @@ msgid "E-mail Address" msgstr "" #: build/locale/src/intl.json -#. [src.edit] - button +#. [edit] - button #. defaultMessage is: #. Edit msgctxt "button" @@ -1219,6 +1327,14 @@ msgctxt "dialog title" msgid "Edit Address" msgstr "" +#: build/locale/src/navigation/components/MenuItemDialog/MenuItemDialog.json +#. [menuItemDialogEditItem] - edit menu item, header +#. defaultMessage is: +#. Edit Item +msgctxt "edit menu item, header" +msgid "Edit Item" +msgstr "" + #: build/locale/src/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.json #. [src.attributes.components.AttributeValueEditDialog.1395607402] - edit attribute value #. defaultMessage is: @@ -1383,6 +1499,14 @@ msgctxt "description" msgid "If this option is disabled, discount will be counted for every eligible product" msgstr "" +#: build/locale/src/navigation/components/MenuList/MenuList.json +#. [menuListItems] - number of menu items +#. defaultMessage is: +#. Items +msgctxt "number of menu items" +msgid "Items" +msgstr "" + #: build/locale/src/intl.json #. [src.lastName] #. defaultMessage is: @@ -1431,8 +1555,24 @@ msgctxt "limit voucher" msgid "Limit to one use per customer" msgstr "" +#: build/locale/src/navigation/components/MenuItemDialog/MenuItemDialog.json +#. [menuItemDialogLinkLabel] - label +#. defaultMessage is: +#. Link +msgctxt "label" +msgid "Link" +msgstr "" + +#: build/locale/src/navigation/components/MenuItemDialog/MenuItemDialog.json +#. [menuItemDialogAddLink] - add link to navigation +#. defaultMessage is: +#. Link to: {url} +msgctxt "add link to navigation" +msgid "Link to: {url}" +msgstr "" + #: build/locale/src/intl.json -#. [src.manage] - button +#. [manage] - button #. defaultMessage is: #. Manage msgctxt "button" @@ -1471,6 +1611,30 @@ msgctxt "description" msgid "Manage your employees and their permissions" msgstr "" +#: build/locale/src/navigation/components/MenuItems/MenuItems.json +#. [menuItemsHeader] - header +#. defaultMessage is: +#. Menu Items +msgctxt "header" +msgid "Menu Items" +msgstr "" + +#: build/locale/src/navigation/components/MenuCreateDialog/MenuCreateDialog.json +#. [menuCreateDialogMenuTitleLabel] +#. defaultMessage is: +#. Menu Title +#: build/locale/src/navigation/components/MenuList/MenuList.json +#. [menuListMenutitle] +#. defaultMessage is: +#. Menu Title +#: build/locale/src/navigation/components/MenuProperties/MenuProperties.json +#. [menuPropertiesMenuTitle] +#. defaultMessage is: +#. Menu Title +msgctxt "description" +msgid "Menu Title" +msgstr "" + #: build/locale/src/discounts/components/VoucherSummary/VoucherSummary.json #. [src.discounts.components.VoucherSummary.1836123577] - voucher value requirement #. defaultMessage is: @@ -1563,6 +1727,14 @@ msgctxt "sale name" msgid "Name" msgstr "" +#: build/locale/src/navigation/components/MenuItemDialog/MenuItemDialog.json +#. [menuItemDialogNameLabel] - menu item name +#. defaultMessage is: +#. Name +msgctxt "menu item name" +msgid "Name" +msgstr "" + #: build/locale/src/intl.json #. [src.navigation] - navigation section name #. defaultMessage is: @@ -1619,6 +1791,14 @@ msgctxt "description" msgid "No customers found" msgstr "" +#: build/locale/src/navigation/components/MenuList/MenuList.json +#. [menuListNoMenus] +#. defaultMessage is: +#. No menus found +msgctxt "description" +msgid "No menus found" +msgstr "" + #: build/locale/src/customers/components/CustomerOrders/CustomerOrders.json #. [src.customers.components.CustomerOrders.898333473] #. defaultMessage is: @@ -1976,7 +2156,7 @@ msgid "Remember this will also delete all products assigned to this category." msgstr "" #: build/locale/src/intl.json -#. [src.remove] - button +#. [remove] - button #. defaultMessage is: #. Remove msgctxt "button" @@ -2000,7 +2180,7 @@ msgid "Sales" msgstr "" #: build/locale/src/intl.json -#. [src.save] - button +#. [save] - button #. defaultMessage is: #. Save msgctxt "button" @@ -2071,6 +2251,14 @@ msgctxt "subsection header" msgid "Shipping address" msgstr "" +#: build/locale/src/intl.json +#. [show] - button +#. defaultMessage is: +#. Show +msgctxt "button" +msgid "Show" +msgstr "" + #: build/locale/src/intl.json #. [src.siteSettings] - site settings section name #. defaultMessage is: @@ -2103,6 +2291,14 @@ msgctxt "description" msgid "Start Hour" msgstr "" +#: build/locale/src/navigation/components/MenuItemDialog/MenuItemDialog.json +#. [menuItemDialogLinkPlaceholder] +#. defaultMessage is: +#. Start typing to begin search... +msgctxt "description" +msgid "Start typing to begin search..." +msgstr "" + #: build/locale/src/discounts/components/SaleList/SaleList.json #. [src.discounts.components.SaleList.47059407] - sale start date #. defaultMessage is: @@ -2403,6 +2599,14 @@ msgctxt "dialog title" msgid "Unassign products from collection" msgstr "" +#: build/locale/src/intl.json +#. [undo] - button +#. defaultMessage is: +#. Undo +msgctxt "button" +msgid "Undo" +msgstr "" + #: build/locale/src/collections/views/CollectionList.json #. [src.collections.views.2237014112] - unpublish collections #. defaultMessage is: diff --git a/src/intl.ts b/src/intl.ts index 2643f8bb0..929513423 100644 --- a/src/intl.ts +++ b/src/intl.ts @@ -52,27 +52,43 @@ export const commonMessages = defineMessages({ export const buttonMessages = defineMessages({ cancel: { defaultMessage: "Cancel", - description: "button" + description: "button", + id: "cancel" }, confirm: { defaultMessage: "Confirm", - description: "button" + description: "button", + id: "confirm" }, edit: { defaultMessage: "Edit", - description: "button" + description: "button", + id: "edit" }, manage: { defaultMessage: "Manage", - description: "button" + description: "button", + id: "manage" }, remove: { defaultMessage: "Remove", - description: "button" + description: "button", + id: "remove" }, save: { defaultMessage: "Save", - description: "button" + description: "button", + id: "save" + }, + show: { + defaultMessage: "Show", + description: "button", + id: "show" + }, + undo: { + defaultMessage: "Undo", + description: "button", + id: "undo" } }); diff --git a/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx b/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx index fd06ad788..c244c10ab 100644 --- a/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx +++ b/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx @@ -5,12 +5,13 @@ 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 ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; -import i18n from "../../../i18n"; +import { buttonMessages } from "@saleor/intl"; export interface MenuCreateDialogFormData { name: string; @@ -34,46 +35,55 @@ const MenuCreateDialog: React.FC = ({ onClose, onConfirm, open -}) => ( - - - {i18n.t("Add Menu", { - context: "create menu modal window title" - })} - -
- {({ change, data, errors: formErrors, submit }) => ( - <> - - - - - - - {i18n.t("Create")} - - - - )} -
-
-); +}) => { + const intl = useIntl(); + + return ( + + + + +
+ {({ change, data, errors: formErrors, submit }) => ( + <> + + + + + + + + + + + )} +
+
+ ); +}; MenuCreateDialog.displayName = "MenuCreateDialog"; export default MenuCreateDialog; diff --git a/src/navigation/components/MenuDetailsPage/MenuDetailsPage.tsx b/src/navigation/components/MenuDetailsPage/MenuDetailsPage.tsx index 6c22f0d0d..e9175ffa0 100644 --- a/src/navigation/components/MenuDetailsPage/MenuDetailsPage.tsx +++ b/src/navigation/components/MenuDetailsPage/MenuDetailsPage.tsx @@ -1,5 +1,6 @@ import Typography from "@material-ui/core/Typography"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import AppHeader from "@saleor/components/AppHeader"; import CardSpacer from "@saleor/components/CardSpacer"; @@ -8,7 +9,7 @@ import Container from "@saleor/components/Container"; import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; -import i18n from "../../../i18n"; +import { sectionNames } from "@saleor/intl"; import { maybe } from "../../../misc"; import { MenuDetails_menu } from "../../types/MenuDetails"; import { MenuItemType } from "../MenuItemDialog"; @@ -47,6 +48,8 @@ const MenuDetailsPage: React.StatelessComponent = ({ onItemEdit, onSubmit }) => { + const intl = useIntl(); + const initialForm: MenuDetailsFormData = { name: maybe(() => menu.name, "") }; @@ -76,14 +79,19 @@ const MenuDetailsPage: React.StatelessComponent = ({
{({ change, data, hasChanged, submit }) => ( - {i18n.t("Navigation")} + + {intl.formatMessage(sectionNames.navigation)} +
- {i18n.t("Navigation")} + + {intl.formatMessage(sectionNames.navigation)} + - {i18n.t( - "Creating the navigation structure is done by dragging and dropping. Simply create a new menu item and then drag it into its destined place. You can move items inside one another to create a tree structure and drag items up and down to create a hierarchy" - )} +
diff --git a/src/navigation/components/MenuItemDialog/MenuItemDialog.tsx b/src/navigation/components/MenuItemDialog/MenuItemDialog.tsx index 87c9a0c56..b3d9de48f 100644 --- a/src/navigation/components/MenuItemDialog/MenuItemDialog.tsx +++ b/src/navigation/components/MenuItemDialog/MenuItemDialog.tsx @@ -7,6 +7,7 @@ import TextField from "@material-ui/core/TextField"; import Typography from "@material-ui/core/Typography"; import isUrl from "is-url"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import AutocompleteSelectMenu from "@saleor/components/AutocompleteSelectMenu"; import ConfirmButton, { @@ -18,7 +19,7 @@ import { SearchCollections_collections_edges_node } from "@saleor/containers/Sea import { SearchPages_pages_edges_node } from "@saleor/containers/SearchPages/types/SearchPages"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; -import i18n from "@saleor/i18n"; +import { buttonMessages, sectionNames } from "@saleor/intl"; import { UserError } from "@saleor/types"; import { getErrors, getFieldError } from "@saleor/utils/errors"; import { getMenuItemByValue, IMenu } from "@saleor/utils/menu"; @@ -86,6 +87,7 @@ const MenuItemDialog: React.StatelessComponent = ({ collections, pages }) => { + const intl = useIntl(); const errors = useModalDialogErrors(apiErrors, open); const [displayValue, setDisplayValue] = React.useState( initialDisplayValue || "" @@ -121,7 +123,7 @@ const MenuItemDialog: React.StatelessComponent = ({ value: "category:" + category.id })), data: {}, - label: i18n.t("Categories") + label: intl.formatMessage(sectionNames.categories) } ]; } @@ -137,7 +139,7 @@ const MenuItemDialog: React.StatelessComponent = ({ value: "collection:" + collection.id })), data: {}, - label: i18n.t("Collections") + label: intl.formatMessage(sectionNames.collections) } ]; } @@ -153,7 +155,7 @@ const MenuItemDialog: React.StatelessComponent = ({ value: "page:" + page.id })), data: {}, - label: i18n.t("Pages") + label: intl.formatMessage(sectionNames.pages) } ]; } @@ -164,12 +166,12 @@ const MenuItemDialog: React.StatelessComponent = ({ children: [], data: {}, label: ( -
{{ url }}", { - context: "add link to navigation", - url - }) + {url} }} /> ), @@ -218,17 +220,25 @@ const MenuItemDialog: React.StatelessComponent = ({ > {!!initial - ? i18n.t("Edit Item", { - context: "edit menu item" + ? intl.formatMessage({ + defaultMessage: "Edit Item", + description: "edit menu item, header", + id: "menuItemDialogEditItem" }) - : i18n.t("Add Item", { - context: "create new menu item" + : intl.formatMessage({ + defaultMessage: "Add Item", + description: "create new menu item, header", + id: "menuItemDialogAddItem" })} @@ -246,13 +256,20 @@ const MenuItemDialog: React.StatelessComponent = ({ disabled={disabled} onChange={handleSelectChange} name="id" - label={i18n.t("Link")} + label={intl.formatMessage({ + defaultMessage: "Link", + description: "label", + id: "menuItemDialogLinkLabel" + })} displayValue={displayValue} loading={loading} options={options} error={!!idError} helperText={idError} - placeholder={i18n.t("Start typing to begin search...")} + placeholder={intl.formatMessage({ + defaultMessage: "Start typing to begin search...", + id: "menuItemDialogLinkPlaceholder" + })} onInputChange={handleQueryChange} /> {mutationErrors.length > 0 && ( @@ -268,7 +285,7 @@ const MenuItemDialog: React.StatelessComponent = ({ = ({ variant="contained" onClick={handleSubmit} > - {i18n.t("Submit", { context: "button" })} + diff --git a/src/navigation/components/MenuItems/MenuItems.tsx b/src/navigation/components/MenuItems/MenuItems.tsx index ef17ab78a..a35ccb852 100644 --- a/src/navigation/components/MenuItems/MenuItems.tsx +++ b/src/navigation/components/MenuItems/MenuItems.tsx @@ -14,12 +14,13 @@ import DeleteIcon from "@material-ui/icons/Delete"; import EditIcon from "@material-ui/icons/Edit"; import classNames from "classnames"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import SortableTree, { NodeRendererProps, TreeItem } from "react-sortable-tree"; import CardTitle from "@saleor/components/CardTitle"; import Skeleton from "@saleor/components/Skeleton"; import useTheme from "@saleor/hooks/useTheme"; -import i18n from "../../../i18n"; +import { buttonMessages } from "@saleor/intl"; import Draggable from "../../../icons/Draggable"; import { MenuDetails_menu_items } from "../../types/MenuDetails"; import { MenuItemType } from "../MenuItemDialog"; @@ -121,7 +122,10 @@ const Placeholder = withStyles(styles, { })(({ classes }: WithStyles) => ( - {i18n.t("Add new menu item to begin creating menu")} + )); @@ -175,7 +179,7 @@ const Node = withStyles(styles, {
@@ -209,15 +213,20 @@ const MenuItems = withStyles(styles, { name: "MenuItems" })( onItemEdit, onUndo }: MenuItemsProps & WithStyles) => { + const intl = useIntl(); const { isDark } = useTheme(); return ( - {i18n.t("Undo")} + } /> @@ -266,9 +275,11 @@ const MenuItems = withStyles(styles, { name: "MenuItems" })(
diff --git a/src/navigation/components/MenuList/MenuList.tsx b/src/navigation/components/MenuList/MenuList.tsx index 75c89ef23..423efcc0f 100644 --- a/src/navigation/components/MenuList/MenuList.tsx +++ b/src/navigation/components/MenuList/MenuList.tsx @@ -12,13 +12,13 @@ import TableFooter from "@material-ui/core/TableFooter"; import TableRow from "@material-ui/core/TableRow"; import DeleteIcon from "@material-ui/icons/Delete"; import React from "react"; +import { FormattedMessage } from "react-intl"; import Checkbox from "@saleor/components/Checkbox"; import IconButtonTableCell from "@saleor/components/IconButtonTableCell"; import Skeleton from "@saleor/components/Skeleton"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; -import i18n from "@saleor/i18n"; import { maybe, renderCollection } from "@saleor/misc"; import { ListActions, ListProps } from "@saleor/types"; import { MenuList_menus_edges_node } from "../../types/MenuList"; @@ -76,10 +76,17 @@ const MenuList = withStyles(styles, { name: "MenuList" })( toolbar={toolbar} > - {i18n.t("Menu Title", { context: "object" })} + - {i18n.t("Items", { context: "number of menu items" })} + @@ -140,7 +147,10 @@ const MenuList = withStyles(styles, { name: "MenuList" })( () => ( - {i18n.t("No menus found")} + ) diff --git a/src/navigation/components/MenuListPage/MenuListPage.tsx b/src/navigation/components/MenuListPage/MenuListPage.tsx index 04f0f5926..12728b73f 100644 --- a/src/navigation/components/MenuListPage/MenuListPage.tsx +++ b/src/navigation/components/MenuListPage/MenuListPage.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 "@saleor/i18n"; +import { sectionNames } from "@saleor/intl"; import { ListActions, PageListProps } from "@saleor/types"; import { MenuList_menus_edges_node } from "../../types/MenuList"; import MenuList from "../MenuList"; @@ -21,21 +22,31 @@ const MenuListPage: React.StatelessComponent = ({ onAdd, onBack, ...listProps -}) => ( - - {i18n.t("Configuration")} - - - - - -); +}) => { + const intl = useIntl(); + return ( + + + {intl.formatMessage(sectionNames.configuration)} + + + + + + + ); +}; MenuListPage.displayName = "MenuListPage"; export default MenuListPage; diff --git a/src/navigation/components/MenuProperties/MenuProperties.tsx b/src/navigation/components/MenuProperties/MenuProperties.tsx index a0379b149..624840f7d 100644 --- a/src/navigation/components/MenuProperties/MenuProperties.tsx +++ b/src/navigation/components/MenuProperties/MenuProperties.tsx @@ -2,9 +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 i18n from "../../../i18n"; +import { commonMessages } from "@saleor/intl"; import { MenuDetailsFormData } from "../MenuDetailsPage"; export interface MenuPropertiesProps { @@ -17,20 +18,29 @@ const MenuProperties: React.StatelessComponent = ({ data, disabled, onChange -}) => ( - - - - { + const intl = useIntl(); + + return ( + + - - -); + + + + + ); +}; MenuProperties.displayName = "MenuProperties"; export default MenuProperties; diff --git a/src/navigation/views/MenuDetails/index.tsx b/src/navigation/views/MenuDetails/index.tsx index 1bc722399..fa6b7f866 100644 --- a/src/navigation/views/MenuDetails/index.tsx +++ b/src/navigation/views/MenuDetails/index.tsx @@ -1,5 +1,6 @@ import DialogContentText from "@material-ui/core/DialogContentText"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import ActionDialog from "@saleor/components/ActionDialog"; import useNavigator from "@saleor/hooks/useNavigator"; @@ -10,7 +11,6 @@ import { DEFAULT_INITIAL_SEARCH_DATA } from "../../../config"; import SearchCategories from "../../../containers/SearchCategories"; import SearchCollections from "../../../containers/SearchCollections"; import SearchPages from "../../../containers/SearchPages"; -import i18n from "../../../i18n"; import { getMutationState, maybe } from "../../../misc"; import { pageUrl } from "../../../pages/urls"; import MenuDetailsPage, { @@ -58,6 +58,7 @@ interface MenuDetailsProps { const MenuDetails: React.FC = ({ id, params }) => { const navigate = useNavigator(); const notify = useNotifier(); + const intl = useIntl(); const closeModal = () => navigate( @@ -236,21 +237,28 @@ const MenuDetails: React.FC = ({ id, params }) => { menuDelete({ variables: { id } }) } variant="delete" - title={i18n.t("Remove menu")} + title={intl.formatMessage({ + defaultMessage: "Delete menu", + description: "dialog header", + id: "menuDetailsDeleteMenuHeader" + })} > - {{ name }}?", - { - name: maybe( - () => data.menu.name, - "..." - ) - } - ) - }} - /> + + + {maybe( + () => data.menu.name, + "..." + )} + + ) + }} + /> + = ({ params }) => { const { updateListSettings, settings } = useListSettings( ListViews.NAVIGATION_LIST ); + const intl = useIntl(); const closeModal = () => navigate( @@ -66,8 +68,9 @@ const MenuList: React.FC = ({ params }) => { const handleCreate = (data: MenuCreate) => { if (data.menuCreate.errors.length === 0) { notify({ - text: i18n.t("Created menu", { - context: "notification" + text: intl.formatMessage({ + defaultMessage: "Created menu", + id: "menuListCreatedMenu" }) }); navigate(menuUrl(data.menuCreate.menu.id)); @@ -77,9 +80,7 @@ const MenuList: React.FC = ({ params }) => { const handleBulkDelete = (data: MenuBulkDelete) => { if (data.menuBulkDelete.errors.length === 0) { notify({ - text: i18n.t("Removed menus", { - context: "notification" - }) + text: intl.formatMessage(commonMessages.savedChanges) }); closeModal(); reset(); @@ -90,8 +91,9 @@ const MenuList: React.FC = ({ params }) => { const handleDelete = (data: MenuDelete) => { if (data.menuDelete.errors.length === 0) { notify({ - text: i18n.t("Removed menu", { - context: "notification" + text: intl.formatMessage({ + defaultMessage: "Deleted menu", + id: "menuListDeletedMenu" }) }); closeModal(); @@ -172,7 +174,7 @@ const MenuList: React.FC = ({ params }) => { ) } > - {i18n.t("Remove")} + } /> @@ -199,27 +201,33 @@ const MenuList: React.FC = ({ params }) => { }) } variant="delete" - title={i18n.t("Remove menu")} + title={intl.formatMessage({ + defaultMessage: "Delete menu", + description: "dialog header", + id: "menuListDeleteMenuHeader" + })} > - {{ name }}?", - { - name: maybe( - () => - data.menus.edges.find( - edge => edge.node.id === params.id - ).node.name, - "..." - ) - } - ) - }} - /> + + + data.menus.edges.find( + edge => edge.node.id === params.id + ).node.name, + "..." + ) + }} + /> + params.ids.length > 0) + } onClose={closeModal} confirmButtonState={bulkDeleteTransitionState} onConfirm={() => @@ -230,21 +238,35 @@ const MenuList: React.FC = ({ params }) => { }) } variant="delete" - title={i18n.t("Remove menus")} + title={intl.formatMessage({ + defaultMessage: "Delete menus", + description: "dialog header", + id: "menuListDeleteMenusHeader" + })} > - {{ number }} menus?", - { - number: maybe( - () => params.ids.length.toString(), - "..." - ) - } - ) - }} - /> + + params.ids.length.toString(), + "..." + ), + displayQuantity: ( + + {maybe( + () => params.ids.length.toString(), + "..." + )} + + ) + }} + /> + );