From 290f6ca3969e30ae14c32e4834ee8e0b1e2ab3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=C5=BBegle=C5=84?= Date: Mon, 26 Aug 2019 16:19:19 +0200 Subject: [PATCH] Refactor home section translations (#115) * Refactor home screen translations * Update pot file * Fix plural forms * Update pot file --- locale/messages.pot | 138 ++++++++++++++- .../HomeActivityCard/HomeActivityCard.tsx | 29 ++- .../HomeAnalyticsCard/HomeAnalyticsCard.tsx | 8 +- src/home/components/HomeHeader/HomeHeader.tsx | 17 +- .../HomeNotificationTable.tsx | 81 ++++++--- .../HomeProductListCard.tsx | 165 ++++++++++-------- src/home/components/HomeScreen.tsx | 65 ++++--- 7 files changed, 366 insertions(+), 137 deletions(-) diff --git a/locale/messages.pot b/locale/messages.pot index c7c7a5d94..e8a9ca967 100644 --- a/locale/messages.pot +++ b/locale/messages.pot @@ -1,6 +1,6 @@ msgid "" msgstr "" -"POT-Creation-Date: 2019-08-26T13:08:05.181Z\n" +"POT-Creation-Date: 2019-08-26T14:18:06.591Z\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "MIME-Version: 1.0\n" @@ -35,6 +35,14 @@ msgctxt "time during voucher is active, header" msgid "Active Dates" msgstr "" +#: build/locale/src/home/components/HomeActivityCard/HomeActivityCard.json +#. [homeActivityCardHeader] - header +#. defaultMessage is: +#. Activity +msgctxt "header" +msgid "Activity" +msgstr "" + #: build/locale/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.json #. [src.customers.components.CustomerAddressDialog.3769321414] - dialog title #. defaultMessage is: @@ -1135,6 +1143,14 @@ msgctxt "description" msgid "Determine attributes used to create product types" msgstr "" +#: build/locale/src/home/components/HomeScreen.json +#. [homeScreenDisclaimer] - header +#. defaultMessage is: +#. Disclaimer +msgctxt "header" +msgid "Disclaimer" +msgstr "" + #: build/locale/src/discounts/components/VoucherInfo/VoucherInfo.json #. [src.discounts.components.VoucherInfo.1262795626] #. defaultMessage is: @@ -1331,6 +1347,26 @@ msgctxt "voucher code, button" msgid "Generate Code" msgstr "" +#: build/locale/src/home/components/HomeHeader/HomeHeader.json +#. [homeHeaderText] - header +#. defaultMessage is: +#. Hello there, {userName} +#: build/locale/src/home/components/HomeScreen.json +#. [homeScreenHeader] - header +#. defaultMessage is: +#. Hello there, {userName} +msgctxt "header" +msgid "Hello there, {userName}" +msgstr "" + +#: build/locale/src/home/components/HomeHeader/HomeHeader.json +#. [homeHeaderTextCaption] - subheader +#. defaultMessage is: +#. Here is some information we gathered about your store +msgctxt "subheader" +msgid "Here is some information we gathered about your store" +msgstr "" + #: build/locale/src/attributes/components/AttributeProperties/AttributeProperties.json #. [src.attributes.components.AttributeProperties.787251583] #. defaultMessage is: @@ -1535,6 +1571,14 @@ msgctxt "navigation section name" msgid "Navigation" msgstr "" +#: build/locale/src/home/components/HomeActivityCard/HomeActivityCard.json +#. [homeActivityCardNoActivities] +#. defaultMessage is: +#. No activities found +msgctxt "description" +msgid "No activities found" +msgstr "" + #: build/locale/src/attributes/components/AttributeList/AttributeList.json #. [src.attributes.components.AttributeList.1192828581] #. defaultMessage is: @@ -1583,6 +1627,22 @@ msgctxt "description" msgid "No orders found" msgstr "" +#: build/locale/src/home/components/HomeNotificationTable/HomeNotificationTable.json +#. [homeNotificationTableNoOrders] +#. defaultMessage is: +#. No orders ready to fulfill +msgctxt "description" +msgid "No orders ready to fulfill" +msgstr "" + +#: build/locale/src/home/components/HomeNotificationTable/HomeNotificationTable.json +#. [homeNotificationsNoPayments] +#. defaultMessage is: +#. No payments waiting for capture +msgctxt "description" +msgid "No payments waiting for capture" +msgstr "" + #: build/locale/src/categories/components/CategoryProducts/CategoryProducts.json #. [src.categories.components.CategoryProducts.1657559629] #. defaultMessage is: @@ -1595,10 +1655,22 @@ msgstr "" #. [src.discounts.components.DiscountProducts.1657559629] #. defaultMessage is: #. No products found +#: build/locale/src/home/components/HomeProductListCard/HomeProductListCard.json +#. [homeProductsListCardNoProducts] +#. defaultMessage is: +#. No products found msgctxt "description" msgid "No products found" msgstr "" +#: build/locale/src/home/components/HomeNotificationTable/HomeNotificationTable.json +#. [homeNotificationsTableNoProducts] +#. defaultMessage is: +#. No products out of stock +msgctxt "description" +msgid "No products out of stock" +msgstr "" + #: build/locale/src/discounts/components/SaleList/SaleList.json #. [src.discounts.components.SaleList.4101565527] #. defaultMessage is: @@ -2119,6 +2191,22 @@ msgctxt "taxes section name" msgid "Taxes" msgstr "" +#: build/locale/src/home/components/HomeScreen.json +#. [homeScreenDisclaimerText2] +#. defaultMessage is: +#. The GraphQL API is beta quality. It is not fully optimized and some mutations or queries may be missing. +msgctxt "description" +msgid "The GraphQL API is beta quality. It is not fully optimized and some mutations or queries may be missing." +msgstr "" + +#: build/locale/src/home/components/HomeScreen.json +#. [homeScreenDisclaimerText1] +#. defaultMessage is: +#. The new dashboard and the GraphQL API are preview-quality software. +msgctxt "description" +msgid "The new dashboard and the GraphQL API are preview-quality software." +msgstr "" + #: build/locale/src/customers/components/CustomerCreateAddress/CustomerCreateAddress.json #. [src.customers.components.CustomerCreateAddress.401345057] #. defaultMessage is: @@ -2167,6 +2255,22 @@ msgctxt "time during which sale is active" msgid "Time Frame" msgstr "" +#: build/locale/src/home/components/HomeAnalyticsCard/HomeAnalyticsCard.json +#. [homeAnalyticsCardHeader] +#. defaultMessage is: +#. Today +msgctxt "description" +msgid "Today" +msgstr "" + +#: build/locale/src/home/components/HomeProductListCard/HomeProductListCard.json +#. [homeProductsListCardHeader] - header +#. defaultMessage is: +#. Top products +msgctxt "header" +msgid "Top products" +msgstr "" + #: build/locale/src/customers/components/CustomerOrders/CustomerOrders.json #. [src.customers.components.CustomerOrders.878013594] - order total amount #. defaultMessage is: @@ -2483,6 +2587,38 @@ msgctxt "vouchers section name" msgid "Vouchers" msgstr "" +#: build/locale/src/home/components/HomeProductListCard/HomeProductListCard.json +#. [homeProductListCardOrders] - number of ordered products +#. defaultMessage is: +#. {amount,plural,one{One ordered} other{{amount} Ordered}} +msgctxt "number of ordered products" +msgid "{amount,plural,one{One ordered} other{{amount} Ordered}}" +msgstr "" + +#: build/locale/src/home/components/HomeNotificationTable/HomeNotificationTable.json +#. [homeNotificationTableOrders] +#. defaultMessage is: +#. {amount,plural,one{One order} other{{amount} Orders}} are ready to fulfill +msgctxt "description" +msgid "{amount,plural,one{One order} other{{amount} Orders}} are ready to fulfill" +msgstr "" + +#: build/locale/src/home/components/HomeNotificationTable/HomeNotificationTable.json +#. [homeNotificationTablePayments] +#. defaultMessage is: +#. {amount,plural,one{One payment} other{{amount} Payments}} to capture +msgctxt "description" +msgid "{amount,plural,one{One payment} other{{amount} Payments}} to capture" +msgstr "" + +#: build/locale/src/home/components/HomeNotificationTable/HomeNotificationTable.json +#. [homeNotificationTableProducts] +#. defaultMessage is: +#. {amount,plural,one{One product} other{{amount} Products}} out of stock +msgctxt "description" +msgid "{amount,plural,one{One product} other{{amount} Products}} out of stock" +msgstr "" + #: build/locale/src/customers/components/CustomerAddressListPage/CustomerAddressListPage.json #. [src.customers.components.CustomerAddressListPage.489918044] - customer details, header #. defaultMessage is: diff --git a/src/home/components/HomeActivityCard/HomeActivityCard.tsx b/src/home/components/HomeActivityCard/HomeActivityCard.tsx index 6062878ed..880106a6f 100644 --- a/src/home/components/HomeActivityCard/HomeActivityCard.tsx +++ b/src/home/components/HomeActivityCard/HomeActivityCard.tsx @@ -5,11 +5,11 @@ import ListItemText from "@material-ui/core/ListItemText"; import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles"; import Typography from "@material-ui/core/Typography"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import { DateTime } from "@saleor/components/Date"; import Skeleton from "@saleor/components/Skeleton"; -import i18n from "../../../i18n"; import { renderCollection } from "../../../misc"; import { Home_activities_edges_node } from "../../types/Home"; import { getActivityMessage } from "./activityMessages"; @@ -25,15 +25,23 @@ const styles = createStyles({ } }); -interface HomeProductListCardProps extends WithStyles { +interface HomeActivityCardProps extends WithStyles { activities: Home_activities_edges_node[]; } -const HomeProductListCard = withStyles(styles, { name: "HomeProductListCard" })( - ({ classes, activities }: HomeProductListCardProps) => { +const HomeActivityCard = withStyles(styles, { name: "HomeActivityCard" })( + ({ classes, activities }: HomeActivityCardProps) => { + const intl = useIntl(); + return ( - + {renderCollection( activities, @@ -59,7 +67,12 @@ const HomeProductListCard = withStyles(styles, { name: "HomeProductListCard" })( {i18n.t("No activities found")} + + + } /> @@ -70,5 +83,5 @@ const HomeProductListCard = withStyles(styles, { name: "HomeProductListCard" })( ); } ); -HomeProductListCard.displayName = "HomeProductListCard"; -export default HomeProductListCard; +HomeActivityCard.displayName = "HomeActivityCard"; +export default HomeActivityCard; diff --git a/src/home/components/HomeAnalyticsCard/HomeAnalyticsCard.tsx b/src/home/components/HomeAnalyticsCard/HomeAnalyticsCard.tsx index 3d509b5a3..9820f87a6 100644 --- a/src/home/components/HomeAnalyticsCard/HomeAnalyticsCard.tsx +++ b/src/home/components/HomeAnalyticsCard/HomeAnalyticsCard.tsx @@ -9,8 +9,7 @@ import { } from "@material-ui/core/styles"; import Typography from "@material-ui/core/Typography"; import React from "react"; - -import i18n from "../../../i18n"; +import { FormattedMessage } from "react-intl"; const styles = (theme: Theme) => createStyles({ @@ -74,7 +73,10 @@ const HomeAnalyticsCard = withStyles(styles, { name: "HomeAnalyticsCard" })( variant="caption" color="textSecondary" > - {i18n.t("Today")} + createStyles({ @@ -32,14 +32,25 @@ const HomeOrdersCard = withStyles(styles, { name: "HomeOrdersCard" })(
{userName ? ( - i18n.t("Hello there, {{userName}}", { userName }) + ) : ( )} {userName ? ( - i18n.t("Here is some information we gathered about your store") + ) : ( )} diff --git a/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx b/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx index cca7c0886..0262142a2 100644 --- a/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx +++ b/src/home/components/HomeNotificationTable/HomeNotificationTable.tsx @@ -12,9 +12,9 @@ import TableRow from "@material-ui/core/TableRow"; import Typography from "@material-ui/core/Typography"; import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import Skeleton from "@saleor/components/Skeleton"; -import i18n from "../../../i18n"; const styles = (theme: Theme) => createStyles({ @@ -47,6 +47,8 @@ const HomeNotificationTable = withStyles(styles, { ordersToFulfill, productsOutOfStock }: HomeNotificationTableProps) => { + const intl = useIntl(); + return ( @@ -57,17 +59,24 @@ const HomeNotificationTable = withStyles(styles, { ) : ordersToFulfill === 0 ? ( - {i18n.t("No orders ready to fulfill")} + ) : ( - {{ amount }} Orders are ready to fulfill", - { amount: ordersToFulfill } - ) - }} - /> + + + )} @@ -80,17 +89,24 @@ const HomeNotificationTable = withStyles(styles, { ) : ordersToCapture === 0 ? ( - {i18n.t("No payments waiting for capture")} + ) : ( - {{ amount }} Payments to capture", - { amount: ordersToCapture } - ) - }} - /> + + + )} @@ -102,16 +118,25 @@ const HomeNotificationTable = withStyles(styles, { {productsOutOfStock === undefined ? ( ) : productsOutOfStock === 0 ? ( - {i18n.t("No products out of stock")} + + + ) : ( - {{ amount }} Products out of stock", - { amount: productsOutOfStock } - ) - }} - /> + + + )} diff --git a/src/home/components/HomeProductListCard/HomeProductListCard.tsx b/src/home/components/HomeProductListCard/HomeProductListCard.tsx index a7aaa297b..21e3ad6c9 100644 --- a/src/home/components/HomeProductListCard/HomeProductListCard.tsx +++ b/src/home/components/HomeProductListCard/HomeProductListCard.tsx @@ -12,12 +12,12 @@ import TableRow from "@material-ui/core/TableRow"; import Typography from "@material-ui/core/Typography"; import classNames from "classnames"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import Money from "@saleor/components/Money"; import Skeleton from "@saleor/components/Skeleton"; import TableCellAvatar from "@saleor/components/TableCellAvatar"; -import i18n from "../../../i18n"; import { maybe, renderCollection } from "../../../misc"; import { Home_productTopToday_edges_node } from "../../types/Home"; @@ -46,80 +46,103 @@ interface HomeProductListProps extends WithStyles { } export const HomeProductList = withStyles(styles, { name: "HomeProductList" })( - ({ classes, topProducts, onRowClick }: HomeProductListProps) => ( - - -
- - {renderCollection( - topProducts, - variant => ( - onRowClick(variant.product.id, variant.id) - : undefined - } - > - variant.product.thumbnail.url)} - avatarProps={classes.avatarProps} - /> + ({ classes, topProducts, onRowClick }: HomeProductListProps) => { + const intl = useIntl(); - - {variant ? ( - <> - - {variant.product.name} - - - {maybe(() => - variant.attributes - .map(attribute => attribute.value.name) - .join(" / ") - )} - - - {i18n.t("{{ordersCount}} Orders", { - ordersCount: variant.quantityOrdered - })} - - - ) : ( - - )} - + return ( + + +
+ + {renderCollection( + topProducts, + variant => ( + onRowClick(variant.product.id, variant.id) + : undefined + } + > + variant.product.thumbnail.url)} + avatarProps={classes.avatarProps} + /> - - - {maybe( - () => ( - - ), + + {variant ? ( + <> + + {variant.product.name} + + + {maybe(() => + variant.attributes + .map(attribute => attribute.value.name) + .join(" / ") + )} + + + + + + ) : ( )} - - - - ), - () => ( - - - {i18n.t("No products found")} - - - ) - )} - -
-
- ) + + + + + {maybe( + () => ( + + ), + + )} + + + + ), + () => ( + + + + + + + + ) + )} + + + + ); + } ); HomeProductList.displayName = "HomeProductList"; diff --git a/src/home/components/HomeScreen.tsx b/src/home/components/HomeScreen.tsx index 06a801b2c..c78e9236a 100644 --- a/src/home/components/HomeScreen.tsx +++ b/src/home/components/HomeScreen.tsx @@ -2,11 +2,11 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import Typography from "@material-ui/core/Typography"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import Container from "@saleor/components/Container"; import PageHeader from "@saleor/components/PageHeader"; -import i18n from "../../i18n"; interface HomeScreenProps { user: { @@ -16,25 +16,44 @@ interface HomeScreenProps { export const HomeScreen: React.StatelessComponent = ({ user -}) => ( - - - - - - - {i18n.t( - "The new dashboard and the GraphQL API are preview-quality software." - )} - - - {i18n.t( - "The GraphQL API is beta quality. It is not fully optimized and some mutations or queries may be missing." - )} - - - - -); +}) => { + const intl = useIntl(); + + return ( + + + + + + + + + + + + + + + ); +};