From 8edd6ee756d8ea25bb9bc600a50e8b54d37ab0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20=C5=BBegle=C5=84?= Date: Mon, 26 Aug 2019 23:46:15 +0200 Subject: [PATCH] Refactor translations in taxes section (#130) --- locale/messages.pot | 102 +++++++++++++++++- .../components/CountryList/CountryList.tsx | 10 +- .../CountryListPage/CountryListPage.tsx | 16 ++- .../CountryTaxesPage/CountryTaxesPage.tsx | 28 +++-- .../TaxConfiguration/TaxConfiguration.tsx | 87 ++++++++------- src/taxes/index.tsx | 33 +++--- 6 files changed, 208 insertions(+), 68 deletions(-) diff --git a/locale/messages.pot b/locale/messages.pot index 7e2a684d4..8f811f1e5 100644 --- a/locale/messages.pot +++ b/locale/messages.pot @@ -1,6 +1,6 @@ msgid "" msgstr "" -"POT-Creation-Date: 2019-08-26T21:41:35.304Z\n" +"POT-Creation-Date: 2019-08-26T21:45:05.243Z\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "MIME-Version: 1.0\n" @@ -523,6 +523,14 @@ msgctxt "section header" msgid "All Subcategories" msgstr "" +#: build/locale/src/taxes/components/TaxConfiguration/TaxConfiguration.json +#. [src.taxes.components.TaxConfiguration.142803418] +#. defaultMessage is: +#. All products prices are entered with tax included +msgctxt "description" +msgid "All products prices are entered with tax included" +msgstr "" + #: build/locale/src/products/components/ProductStock/ProductStock.json #. [src.products.components.ProductStock.1680952454] - allocated product stock #. defaultMessage is: @@ -1419,6 +1427,10 @@ msgstr "" #. [src.products.components.ProductOrganization.1755013298] #. defaultMessage is: #. Category +#: build/locale/src/taxes/components/CountryTaxesPage/CountryTaxesPage.json +#. [src.taxes.components.CountryTaxesPage.1755013298] +#. defaultMessage is: +#. Category msgctxt "description" msgid "Category" msgstr "" @@ -1495,6 +1507,14 @@ msgctxt "description" msgid "Charge taxes for this item" msgstr "" +#: build/locale/src/taxes/components/TaxConfiguration/TaxConfiguration.json +#. [src.taxes.components.TaxConfiguration.2654711891] +#. defaultMessage is: +#. Charge taxes on shipping rates +msgctxt "description" +msgid "Charge taxes on shipping rates" +msgstr "" + #: build/locale/src/shipping/components/ShippingZoneCountriesAssignDialog/ShippingZoneCountriesAssignDialog.json #. [src.shipping.components.ShippingZoneCountriesAssignDialog.2404264158] #. defaultMessage is: @@ -1783,6 +1803,22 @@ msgctxt "description" msgid "Country" msgstr "" +#: build/locale/src/taxes/components/CountryList/CountryList.json +#. [src.taxes.components.CountryList.4039455144] +#. defaultMessage is: +#. Country Code +msgctxt "description" +msgid "Country Code" +msgstr "" + +#: build/locale/src/taxes/components/CountryList/CountryList.json +#. [src.taxes.components.CountryList.577035076] +#. defaultMessage is: +#. Country Name +msgctxt "description" +msgid "Country Name" +msgstr "" + #: build/locale/src/siteSettings/components/SiteSettingsAddress/SiteSettingsAddress.json #. [src.siteSettings.components.SiteSettingsAddress.944851093] #. defaultMessage is: @@ -2771,6 +2807,14 @@ msgctxt "switch button" msgid "Feature on Homepage" msgstr "" +#: build/locale/src/taxes/components/TaxConfiguration/TaxConfiguration.json +#. [src.taxes.components.TaxConfiguration.3375540052] - button +#. defaultMessage is: +#. Fetch taxes +msgctxt "button" +msgid "Fetch taxes" +msgstr "" + #: build/locale/src/discounts/components/DiscountCountrySelectDialog/DiscountCountrySelectDialog.json #. [src.discounts.components.DiscountCountrySelectDialog.2566713432] - search box label #. defaultMessage is: @@ -3551,6 +3595,14 @@ msgctxt "description" msgid "No collections found" msgstr "" +#: build/locale/src/taxes/components/CountryList/CountryList.json +#. [src.taxes.components.CountryList.110033143] +#. defaultMessage is: +#. No countries found +msgctxt "description" +msgid "No countries found" +msgstr "" + #: build/locale/src/customers/components/CustomerList/CustomerList.json #. [src.customers.components.CustomerList.2239722559] #. defaultMessage is: @@ -3671,6 +3723,14 @@ msgctxt "description" msgid "No products out of stock" msgstr "" +#: build/locale/src/taxes/components/CountryTaxesPage/CountryTaxesPage.json +#. [src.taxes.components.CountryTaxesPage.3066312070] +#. defaultMessage is: +#. No reduced tax categories found +msgctxt "description" +msgid "No reduced tax categories found" +msgstr "" + #: build/locale/src/productTypes/components/AssignAttributeDialog/AssignAttributeDialog.json #. [src.productTypes.components.AssignAttributeDialog.4205644805] #. defaultMessage is: @@ -4763,6 +4823,14 @@ msgctxt "section header" msgid "Recent orders" msgstr "" +#: build/locale/src/taxes/components/CountryList/CountryList.json +#. [src.taxes.components.CountryList.3154586635] +#. defaultMessage is: +#. Reduced Tax Rates +msgctxt "description" +msgid "Reduced Tax Rates" +msgstr "" + #: build/locale/src/orders/components/OrderPayment/OrderPayment.json #. [src.orders.components.OrderPayment.2845258362] - button #. defaultMessage is: @@ -5243,6 +5311,14 @@ msgctxt "button" msgid "Show" msgstr "" +#: build/locale/src/taxes/components/TaxConfiguration/TaxConfiguration.json +#. [src.taxes.components.TaxConfiguration.2102582640] +#. defaultMessage is: +#. Show gross prices to customers in the storefront +msgctxt "description" +msgid "Show gross prices to customers in the storefront" +msgstr "" + #: build/locale/src/products/components/ProductOrganization/ProductOrganization.json #. [src.products.components.ProductOrganization.150865454] - product is not configurable #. defaultMessage is: @@ -5543,6 +5619,22 @@ msgctxt "tax rate for a product type" msgid "Tax" msgstr "" +#: build/locale/src/taxes/components/CountryTaxesPage/CountryTaxesPage.json +#. [src.taxes.components.CountryTaxesPage.2022558114] +#. defaultMessage is: +#. Tax Rate +msgctxt "description" +msgid "Tax Rate" +msgstr "" + +#: build/locale/src/taxes/components/CountryTaxesPage/CountryTaxesPage.json +#. [src.taxes.components.CountryTaxesPage.2737618795] - header +#. defaultMessage is: +#. Tax Rates in {countryName} +msgctxt "header" +msgid "Tax Rates in {countryName}" +msgstr "" + #: build/locale/src/intl.json #. [src.taxes] - taxes section name #. defaultMessage is: @@ -5571,6 +5663,14 @@ msgctxt "section header" msgid "Taxes" msgstr "" +#: build/locale/src/taxes/components/CountryListPage/CountryListPage.json +#. [src.taxes.components.CountryListPage.3955023266] - header +#. defaultMessage is: +#. Taxes +msgctxt "header" +msgid "Taxes" +msgstr "" + #: build/locale/src/orders/components/OrderDraftDetailsSummary/OrderDraftDetailsSummary.json #. [src.orders.components.OrderDraftDetailsSummary.3202709354] #. defaultMessage is: diff --git a/src/taxes/components/CountryList/CountryList.tsx b/src/taxes/components/CountryList/CountryList.tsx index 0af6a69eb..bc01c1b85 100644 --- a/src/taxes/components/CountryList/CountryList.tsx +++ b/src/taxes/components/CountryList/CountryList.tsx @@ -7,9 +7,9 @@ import TableHead from "@material-ui/core/TableHead"; import TableRow from "@material-ui/core/TableRow"; import classNames from "classnames"; import React from "react"; +import { FormattedMessage } from "react-intl"; import Skeleton from "@saleor/components/Skeleton"; -import i18n from "../../../i18n"; import { maybe, renderCollection } from "../../../misc"; import { CountryList_shop_countries } from "../../types/CountryList"; @@ -34,13 +34,13 @@ const CountryList = withStyles(styles, { name: "CountryList" })( - {i18n.t("Country Code", { context: "object" })} + - {i18n.t("Country Name", { context: "object" })} + - {i18n.t("Reduced Tax Rates", { context: "object" })} + @@ -73,7 +73,7 @@ const CountryList = withStyles(styles, { name: "CountryList" })( () => ( - {i18n.t("No countries found")} + ) diff --git a/src/taxes/components/CountryListPage/CountryListPage.tsx b/src/taxes/components/CountryListPage/CountryListPage.tsx index a9ca63481..2d6c0af50 100644 --- a/src/taxes/components/CountryListPage/CountryListPage.tsx +++ b/src/taxes/components/CountryListPage/CountryListPage.tsx @@ -1,11 +1,12 @@ import React from "react"; +import { useIntl } from "react-intl"; import AppHeader from "@saleor/components/AppHeader"; import { Container } from "@saleor/components/Container"; import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; -import i18n from "../../../i18n"; +import { sectionNames } from "@saleor/intl"; import { maybe } from "../../../misc"; import { CountryList_shop } from "../../types/CountryList"; import CountryList from "../CountryList"; @@ -33,6 +34,8 @@ const CountryListPage: React.StatelessComponent = ({ onSubmit, onTaxFetch }) => { + const intl = useIntl(); + const initialForm: FormData = { chargeTaxesOnShipping: maybe(() => shop.chargeTaxesOnShipping, false), includeTax: maybe(() => shop.includeTaxesInPrices, false), @@ -42,8 +45,15 @@ const CountryListPage: React.StatelessComponent = ({
{({ change, data, submit }) => ( - {i18n.t("Configuration")} - + + {intl.formatMessage(sectionNames.configuration)} + +
) => { + const intl = useIntl(); + const taxRates = translatedTaxRates(); return ( - {i18n.t("Taxes")} + + {intl.formatMessage(sectionNames.taxes)} + @@ -56,10 +66,10 @@ const CountryTaxesPage = withStyles(styles, { name: "CountryTaxesPage" })( - {i18n.t("Category", { context: "object" })} + - {i18n.t("Tax Rate", { context: "object" })} + @@ -87,7 +97,7 @@ const CountryTaxesPage = withStyles(styles, { name: "CountryTaxesPage" })( () => ( - {i18n.t("No reduced tax categories found")} + ) diff --git a/src/taxes/components/TaxConfiguration/TaxConfiguration.tsx b/src/taxes/components/TaxConfiguration/TaxConfiguration.tsx index 483678efc..a044e71f1 100644 --- a/src/taxes/components/TaxConfiguration/TaxConfiguration.tsx +++ b/src/taxes/components/TaxConfiguration/TaxConfiguration.tsx @@ -4,12 +4,13 @@ import CardActions from "@material-ui/core/CardActions"; import CardContent from "@material-ui/core/CardContent"; import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles"; import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; import CardTitle from "@saleor/components/CardTitle"; import ControlledSwitch from "@saleor/components/ControlledSwitch"; import FormSpacer from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; -import i18n from "../../../i18n"; +import { sectionNames } from "@saleor/intl"; import { FormData } from "../CountryListPage"; interface TaxConfigurationProps { @@ -34,40 +35,54 @@ export const TaxConfiguration = withStyles(styles, { disabled, onChange, onTaxFetch - }: TaxConfigurationProps & WithStyles) => ( - - - - - - - - -
- - - -
- ) + }: TaxConfigurationProps & WithStyles) => { + const intl = useIntl(); + + return ( + + + + + + + + +
+ + + +
+ ); + } ); export default TaxConfiguration; diff --git a/src/taxes/index.tsx b/src/taxes/index.tsx index 3768609d1..ecdeee595 100644 --- a/src/taxes/index.tsx +++ b/src/taxes/index.tsx @@ -1,8 +1,9 @@ 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 { countryListPath, countryTaxRatesPath } from "./urls"; import CountryList from "./views/CountryList"; import CountryTaxesComponent, { @@ -13,18 +14,22 @@ const CountryTaxes: React.StatelessComponent< RouteComponentProps > = ({ match }) => ; -const Component = () => ( - <> - - - - - - -); +const Component = () => { + const intl = useIntl(); + + return ( + <> + + + + + + + ); +}; export default Component;