From 3446f6b49ab6fbf43c73a7148ab4d86160ce6417 Mon Sep 17 00:00:00 2001 From: Christos Date: Wed, 8 Jan 2025 18:50:20 +0200 Subject: [PATCH 1/3] i18n: Remove redundant hasTranslation checks in codebase --- .../display-price/time-frame.tsx | 46 +++-------- .../domain-transfer-intro/intro.tsx | 15 +--- .../steps-repository/error-step/index.tsx | 20 +---- .../components/access-method-picker.tsx | 14 +--- client/lib/domains/resolve-domain-status.tsx | 56 ++++--------- .../magic-login/request-login-email-form.jsx | 40 ++------- .../account/toggle-sites-as-landing-page.tsx | 14 +--- client/me/developer/dev-survey-notice.tsx | 7 +- .../reader-subscriptions/index.jsx | 23 ++---- .../purchases/confirm-cancel-domain/index.jsx | 34 +++----- .../cards/actions/quick-links/index.jsx | 10 +-- .../cards/tasks/domain-upsell/index.jsx | 23 +----- .../list/empty-domains-list-card.jsx | 6 +- .../cards/transferred-domain-details.tsx | 17 +--- .../domain-management/settings/index.tsx | 15 +--- .../patterns/components/get-started/index.tsx | 17 ++-- .../components/pattern-library/index.tsx | 25 ++---- .../components/pattern-preview/index.tsx | 20 +---- .../entrepreneur-plan/entrepreneur-plan.tsx | 40 ++++----- .../wooexpress-plans/index.tsx | 26 ++---- client/my-sites/plans/main.jsx | 23 ++---- .../plugins/plugins-browser/index.jsx | 15 +--- .../newsletter-categories-toggle.tsx | 23 ++---- .../grow-your-audience/grow-your-audience.tsx | 49 +++-------- client/my-sites/subscribers/main.tsx | 24 ++---- client/signup/config/steps-pure.js | 18 ++-- .../steps/design-picker/design-picker.tsx | 6 +- client/signup/steps/site-or-domain/index.jsx | 82 ++++++------------- .../components/sites-site-launch-nag.tsx | 11 +-- .../tools/delete-site/index.jsx | 66 ++++----------- .../components/deployments-survey/index.tsx | 22 +---- .../card-content/staging-sync-card.tsx | 31 +++---- .../calypso-products/src/features-list.tsx | 35 ++------ packages/calypso-products/src/plans-list.tsx | 7 +- .../suggestion-item.tsx | 29 ++----- .../components/help-center-contact-page.tsx | 10 +-- .../help-center-contact-support-option.tsx | 11 +-- .../src/components/help-center-gpt.tsx | 13 +-- .../src/plans-interval-toggle/index.tsx | 24 ++---- .../plans-grid/src/plans-table/plan-item.tsx | 15 ++-- 40 files changed, 234 insertions(+), 748 deletions(-) diff --git a/client/components/jetpack/card/jetpack-product-card/display-price/time-frame.tsx b/client/components/jetpack/card/jetpack-product-card/display-price/time-frame.tsx index 5a2eef155c6c0..794716e04cd1d 100644 --- a/client/components/jetpack/card/jetpack-product-card/display-price/time-frame.tsx +++ b/client/components/jetpack/card/jetpack-product-card/display-price/time-frame.tsx @@ -1,5 +1,5 @@ import { TERM_MONTHLY } from '@automattic/calypso-products'; -import i18n, { TranslateResult, getLocaleSlug, useTranslate } from 'i18n-calypso'; +import { TranslateResult, useTranslate } from 'i18n-calypso'; import { useMemo } from 'react'; import { useLocalizedMoment } from 'calypso/components/localized-moment'; import type { Duration } from 'calypso/my-sites/plans/jetpack-plans/types'; @@ -119,42 +119,18 @@ const PartialDiscountTimeFrame: React.FC< PartialDiscountTimeFrameProps & A11yPr /* eslint-disable wpcalypso/i18n-mismatched-placeholders */ if ( billingTerm === TERM_MONTHLY ) { - if ( - getLocaleSlug() === 'en' || - getLocaleSlug() === 'en-gb' || - i18n.hasTranslation( 'for the first month, then %(original_price)s /month, billed monthly' ) - ) { - text = translate( - 'for the first month, then %(original_price)s /month, billed monthly', - 'for the first %(months)d months, then %(original_price)s /month, billed monthly', - opts - ); - } else { - text = translate( - 'for the first month, billed monthly', - 'for the first %(months)d months, billed monthly', - opts - ); - } + text = translate( + 'for the first month, then %(original_price)s /month, billed monthly', + 'for the first %(months)d months, then %(original_price)s /month, billed monthly', + opts + ); } else { // eslint-disable-next-line no-lonely-if - if ( - getLocaleSlug() === 'en' || - getLocaleSlug() === 'en-gb' || - i18n.hasTranslation( 'for the first month, then %(original_price)s /month, billed yearly' ) - ) { - text = translate( - 'for the first month, then %(original_price)s /month, billed yearly', - 'for the first %(months)d months, then %(original_price)s /month, billed yearly', - opts - ); - } else { - text = translate( - 'for the first month, billed yearly', - 'for the first %(months)d months, billed yearly', - opts - ); - } + text = translate( + 'for the first month, then %(original_price)s /month, billed yearly', + 'for the first %(months)d months, then %(original_price)s /month, billed yearly', + opts + ); } if ( forScreenReader ) { diff --git a/client/landing/stepper/declarative-flow/internals/steps-repository/domain-transfer-intro/intro.tsx b/client/landing/stepper/declarative-flow/internals/steps-repository/domain-transfer-intro/intro.tsx index c9b94d34aae8f..fb87f30c8800a 100644 --- a/client/landing/stepper/declarative-flow/internals/steps-repository/domain-transfer-intro/intro.tsx +++ b/client/landing/stepper/declarative-flow/internals/steps-repository/domain-transfer-intro/intro.tsx @@ -1,4 +1,3 @@ -import { useIsEnglishLocale } from '@automattic/i18n-utils'; import { IntentScreen, GOOGLE_TRANSFER } from '@automattic/onboarding'; import { Button } from '@wordpress/components'; import { Icon, unlock, plus, payment } from '@wordpress/icons'; @@ -12,8 +11,7 @@ interface Props { } const Intro: React.FC< Props > = ( { onSubmit, variantSlug } ) => { - const { __, hasTranslation } = useI18n(); - const isEnglishLocale = useIsEnglishLocale(); + const { __ } = useI18n(); const isGoogleDomainsTransferFlow = GOOGLE_TRANSFER === variantSlug; return ( @@ -63,16 +61,9 @@ const Intro: React.FC< Props > = ( { onSubmit, variantSlug } ) => { : __( 'We pay the first year for Google domains' ), description: (

- { isEnglishLocale || - hasTranslation( + { __( "Review your payment and contact details. If you're transferring a domain from Squarespace, we'll pay for an additional year of registration if your domain was registered before July 1, 2023." - ) - ? __( - "Review your payment and contact details. If you're transferring a domain from Squarespace, we'll pay for an additional year of registration if your domain was registered before July 1, 2023." - ) - : __( - "Review your payment and contact details. If you're transferring a domain from Google, we'll pay for an additional year of registration." - ) } + ) }

), icon: , diff --git a/client/landing/stepper/declarative-flow/internals/steps-repository/error-step/index.tsx b/client/landing/stepper/declarative-flow/internals/steps-repository/error-step/index.tsx index f3aed6d3fe475..e825d4df400e9 100644 --- a/client/landing/stepper/declarative-flow/internals/steps-repository/error-step/index.tsx +++ b/client/landing/stepper/declarative-flow/internals/steps-repository/error-step/index.tsx @@ -1,8 +1,6 @@ -import { englishLocales } from '@automattic/i18n-utils'; import { StepContainer } from '@automattic/onboarding'; import styled from '@emotion/styled'; import { useI18n } from '@wordpress/react-i18n'; -import { useTranslate } from 'i18n-calypso'; import FormattedHeader from 'calypso/components/formatted-header'; import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; import { useSiteDomains } from '../../../../hooks/use-site-domains'; @@ -17,8 +15,7 @@ const WarningsOrHoldsSection = styled.div` const ErrorStep: Step = function ErrorStep( { navigation } ) { const { goBack, goNext } = navigation; - const translate = useTranslate(); - const { __, hasTranslation } = useI18n(); + const { __ } = useI18n(); const siteDomains = useSiteDomains(); const siteSetupError = useSiteSetupError(); @@ -29,21 +26,8 @@ const ErrorStep: Step = function ErrorStep( { navigation } ) { } const messageCopy = () => { - // New copy waiting on translation. - if ( - englishLocales.includes( translate?.localeSlug || '' ) || - hasTranslation( - 'It looks like something went wrong while setting up your site. Please contact support so that we can help you out.' - ) - ) { - return __( - 'It looks like something went wrong while setting up your site. Please contact support so that we can help you out.' - ); - } - - // Original copy return __( - 'It looks like something went wrong while setting up your store. Please contact support so that we can help you out.' + 'It looks like something went wrong while setting up your site. Please contact support so that we can help you out.' ); }; diff --git a/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-credentials/components/access-method-picker.tsx b/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-credentials/components/access-method-picker.tsx index b64f3f5df2e23..6ea0a32a6d74a 100644 --- a/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-credentials/components/access-method-picker.tsx +++ b/client/landing/stepper/declarative-flow/internals/steps-repository/site-migration-credentials/components/access-method-picker.tsx @@ -1,7 +1,5 @@ import { isEnabled } from '@automattic/calypso-config'; import { FormLabel } from '@automattic/components'; -import { useLocale } from '@automattic/i18n-utils'; -import { hasTranslation } from '@wordpress/i18n'; import { useTranslate } from 'i18n-calypso'; import { FC } from 'react'; import { Controller } from 'react-hook-form'; @@ -10,16 +8,10 @@ import { CredentialsFormFieldProps } from '../types'; export const AccessMethodPicker: FC< CredentialsFormFieldProps > = ( { control } ) => { const translate = useTranslate(); - const locale = useLocale(); - const applicationPasswordEnabled = isEnabled( 'automated-migration/application-password' ); - const hasLabelTranslation = - locale.startsWith( 'en' ) || hasTranslation( 'WordPress site credentials' ); - - const credentialsLabel = - applicationPasswordEnabled && hasLabelTranslation - ? translate( 'WordPress site credentials' ) - : translate( 'WordPress credentials' ); + const credentialsLabel = applicationPasswordEnabled + ? translate( 'WordPress site credentials' ) + : translate( 'WordPress credentials' ); return (
diff --git a/client/lib/domains/resolve-domain-status.tsx b/client/lib/domains/resolve-domain-status.tsx index 4f4a92e01a5ce..231d6008588e6 100644 --- a/client/lib/domains/resolve-domain-status.tsx +++ b/client/lib/domains/resolve-domain-status.tsx @@ -1,12 +1,11 @@ import { Button } from '@automattic/components'; -import { localizeUrl, englishLocales } from '@automattic/i18n-utils'; +import { localizeUrl } from '@automattic/i18n-utils'; import { SETTING_PRIMARY_DOMAIN, INCOMING_DOMAIN_TRANSFER_STATUSES_IN_PROGRESS, GDPR_POLICIES, DOMAIN_EXPIRATION_AUCTION, } from '@automattic/urls'; -import i18n, { getLocaleSlug } from 'i18n-calypso'; import moment from 'moment'; import { useMyDomainInputMode } from 'calypso/components/domains/connect-domain-step/constants'; import { isExpiringSoon } from 'calypso/lib/domains/utils/is-expiring-soon'; @@ -508,49 +507,26 @@ export function resolveDomainStatus( domain.transferStatus === transferStatus.COMPLETED && ! domain.pointsToWpcom ) { - const hasTranslation = - englishLocales.includes( String( getLocaleSlug() ) ) || - i18n.hasTranslation( - '{{strong}}Transfer successful!{{/strong}} To make this domain work with your WordPress.com site you need to {{a}}point it to WordPress.com.{{/a}}' - ); - - const oldCopy = translate( - '{{strong}}Transfer successful!{{/strong}} To make this domain work with your WordPress.com site you need to {{a}}point it to WordPress.com name servers.{{/a}}', - { - components: { - strong: , - a: ( - - ), - }, - } - ); - - const newCopy = translate( - '{{strong}}Transfer successful!{{/strong}} To make this domain work with your WordPress.com site you need to {{a}}point it to WordPress.com.{{/a}}', - { - components: { - strong: , - a: ( - - ), - }, - } - ); return { statusText: translate( 'Action required' ), statusClass: 'status-success', status: translate( 'Active' ), icon: 'info', - noticeText: hasTranslation ? newCopy : oldCopy, + noticeText: translate( + '{{strong}}Transfer successful!{{/strong}} To make this domain work with your WordPress.com site you need to {{a}}point it to WordPress.com.{{/a}}', + { + components: { + strong: , + a: ( + + ), + }, + } + ), listStatusWeight: 600, isDismissable: true, }; diff --git a/client/login/magic-login/request-login-email-form.jsx b/client/login/magic-login/request-login-email-form.jsx index a079c558416bc..fad2bf9b455c4 100644 --- a/client/login/magic-login/request-login-email-form.jsx +++ b/client/login/magic-login/request-login-email-form.jsx @@ -1,6 +1,4 @@ import { FormLabel } from '@automattic/components'; -import { englishLocales } from '@automattic/i18n-utils'; -import { hasTranslation } from '@wordpress/i18n'; import { localize } from 'i18n-calypso'; import PropTypes from 'prop-types'; import { createRef, Component } from 'react'; @@ -132,21 +130,14 @@ class RequestLoginEmailForm extends Component { } getSubHeaderText() { - const { translate, locale, subHeaderText } = this.props; + const { translate, subHeaderText } = this.props; const siteName = this.state.site?.name; if ( subHeaderText ) { return subHeaderText; } - // If we have a siteName and new translation is available - if ( - siteName && - ( englishLocales.includes( locale ) || - hasTranslation( - 'We’ll send you an email with a login link that will log you in right away to {site name}.' - ) ) - ) { + if ( siteName ) { return translate( 'We’ll send you an email with a login link that will log you in right away to %(siteName)s.', { @@ -157,19 +148,8 @@ class RequestLoginEmailForm extends Component { ); } - // If no siteName but new translation is available - if ( - englishLocales.includes( locale ) || - hasTranslation( 'We’ll send you an email with a login link that will log you in right away.' ) - ) { - return translate( - 'We’ll send you an email with a login link that will log you in right away.' - ); - } - - // Fallback is old text return translate( - 'Get a link sent to the email address associated with your account to log in instantly without your password.' + 'We’ll send you an email with a login link that will log you in right away.' ); } @@ -187,7 +167,6 @@ class RequestLoginEmailForm extends Component { hideSubHeaderText, inputPlaceholder, submitButtonLabel, - locale, customFormLabel, onSubmitEmail, errorMessage, @@ -223,16 +202,11 @@ class RequestLoginEmailForm extends Component { ? requestError : translate( 'Unable to complete request' ); - const buttonLabel = - englishLocales.includes( locale ) || hasTranslation( 'Send Link' ) - ? translate( 'Send link' ) - : translate( 'Get Link' ); + const buttonLabel = translate( 'Send link' ); - const formLabel = - customFormLabel || - ( hasTranslation( 'Email address or username' ) - ? this.props.translate( 'Email address or username' ) - : this.props.translate( 'Email Address or Username' ) ); + const formLabel = customFormLabel + ? this.props.translate( 'Email address or username' ) + : this.props.translate( 'Email Address or Username' ); const onSubmit = onSubmitEmail ? ( e ) => onSubmitEmail( this.getUsernameOrEmailFromState(), e ) diff --git a/client/me/account/toggle-sites-as-landing-page.tsx b/client/me/account/toggle-sites-as-landing-page.tsx index 94eba0d70181d..581cdd6bdc8e7 100644 --- a/client/me/account/toggle-sites-as-landing-page.tsx +++ b/client/me/account/toggle-sites-as-landing-page.tsx @@ -1,4 +1,3 @@ -import { useHasEnTranslation } from '@automattic/i18n-utils'; import { ToggleControl } from '@wordpress/components'; import { useTranslate } from 'i18n-calypso'; import { useDispatch, useSelector } from 'calypso/state'; @@ -33,22 +32,15 @@ function ToggleSitesAsLandingPage() { ); } - const oldCopy = translate( 'Show me all my sites when logging in to WordPress.com' ); - const updatedCopy = translate( - 'Display all my sites instead of just my primary site when I visit WordPress.com.' - ); - - const hasTranslationForNewCopy = useHasEnTranslation()( - 'Display all my sites instead of just my primary site when I visit WordPress.com.' - ); - return (
); diff --git a/client/me/developer/dev-survey-notice.tsx b/client/me/developer/dev-survey-notice.tsx index e9968f88912f8..ce295b418ff3d 100644 --- a/client/me/developer/dev-survey-notice.tsx +++ b/client/me/developer/dev-survey-notice.tsx @@ -1,6 +1,5 @@ import { Gridicon } from '@automattic/components'; import { Button } from '@wordpress/components'; -import { useI18n } from '@wordpress/react-i18n'; import { useTranslate } from 'i18n-calypso'; import surveyImage from 'calypso/assets/images/illustrations/developer-survey.svg'; @@ -19,8 +18,6 @@ export const DeveloperSurveyNotice = ( { localeSlug, }: DeveloperSurveyNoticeProps ) => { const translate = useTranslate(); - const { hasTranslation } = useI18n(); - const href = localeSlug === 'es' ? 'https://wordpressdotcom.survey.fm/developer-survey-es' @@ -61,9 +58,7 @@ export const DeveloperSurveyNotice = ( { variant="tertiary" onClick={ () => onClose( ONE_DAY_IN_SECONDS, 'remind-later-button' ) } > - { hasTranslation( 'Maybe later' ) || localeSlug === 'en' - ? translate( 'Maybe later' ) - : translate( 'Remind later' ) } + { translate( 'Maybe later' ) }
diff --git a/client/my-sites/patterns/components/pattern-library/index.tsx b/client/my-sites/patterns/components/pattern-library/index.tsx index 7ef155e8493b1..88a8499d2e820 100644 --- a/client/my-sites/patterns/components/pattern-library/index.tsx +++ b/client/my-sites/patterns/components/pattern-library/index.tsx @@ -1,11 +1,7 @@ import { isEnabled } from '@automattic/calypso-config'; import page from '@automattic/calypso-router'; import { Button } from '@automattic/components'; -import { - useLocale, - addLocaleToPathLocaleInFront, - useHasEnTranslation, -} from '@automattic/i18n-utils'; +import { useLocale, addLocaleToPathLocaleInFront } from '@automattic/i18n-utils'; import styled from '@emotion/styled'; import { Icon, category as iconCategory } from '@wordpress/icons'; import clsx from 'clsx'; @@ -93,7 +89,6 @@ export const PatternLibrary = ( { }: PatternLibraryProps ) => { const locale = useLocale(); const translate = useTranslate(); - const hasTranslation = useHasEnTranslation(); const navRef = useRef< HTMLDivElement >( null ); const readymadeTemplateSectionRef = useRef< HTMLDivElement >( null ); @@ -248,18 +243,6 @@ export const PatternLibrary = ( { } ); } - const pageLayoutsHeading = hasTranslation( 'Beautiful, curated page layouts' ) - ? translate( 'Beautiful, curated page layouts', { - comment: - 'Heading text for a section in the Pattern Library with links to block pattern categories containing page layouts', - textOnly: true, - } ) - : translate( 'Beautifully curated page layouts', { - comment: - 'Heading text for a section in the Pattern Library with links to block pattern categories containing page layouts', - textOnly: true, - } ); - return ( <> { isHomePage ? ( @@ -390,7 +373,11 @@ export const PatternLibrary = ( { { isHomePage && ( <> ( 'PLAN_ECOMMERCE' ); const selectedPlan = plans[ selectedInterval ]; @@ -177,17 +174,13 @@ export function EntrepreneurPlan( props: EntrepreneurPlanProps ) { setSelectedInterval( key ); }; - const hasNewTitleTranslation = hasTranslation( "What's included in your free trial:" ); - const titleTranslation = - isEnglish || hasNewTitleTranslation - ? translate( "What's included in your free trial:" ) - : translate( "What's included in your free trial" ); - return ( <> { ! hideTrialIncluded && ( <> -

{ titleTranslation }

+

+ { translate( "What's included in your free trial:" ) } +

@@ -212,22 +205,17 @@ export function EntrepreneurPlan( props: EntrepreneurPlanProps ) { { getPlan( PLAN_ECOMMERCE )?.getTitle() ?? '' }

- { isEnglish || - hasTranslation( - "Secure the full benefits of the %(planName)s plan. Purchase today and maximize your store's potential!" - ) - ? // translators: %(planName)s is a plan name. E.g. Commerce plan. - translate( - "Secure the full benefits of the %(planName)s plan. Purchase today and maximize your store's potential!", - { - args: { - planName: getPlan( PLAN_ECOMMERCE )?.getTitle() ?? '', - }, - } - ) - : translate( - "Secure the full benefits of the Entrepreneur plan. Purchase today and maximize your store's potential!" - ) } + { + // translators: %(planName)s is a plan name. E.g. Commerce plan. + translate( + "Secure the full benefits of the %(planName)s plan. Purchase today and maximize your store's potential!", + { + args: { + planName: getPlan( PLAN_ECOMMERCE )?.getTitle() ?? '', + }, + } + ) + }

diff --git a/client/my-sites/plans/ecommerce-trial/wooexpress-plans/index.tsx b/client/my-sites/plans/ecommerce-trial/wooexpress-plans/index.tsx index e2c3c36a82175..e116b2dcd40a8 100644 --- a/client/my-sites/plans/ecommerce-trial/wooexpress-plans/index.tsx +++ b/client/my-sites/plans/ecommerce-trial/wooexpress-plans/index.tsx @@ -8,8 +8,6 @@ import { import page from '@automattic/calypso-router'; import { Button } from '@automattic/components'; import { Plans } from '@automattic/data-stores'; -import { useIsEnglishLocale } from '@automattic/i18n-utils'; -import { hasTranslation } from '@wordpress/i18n'; import { useTranslate } from 'i18n-calypso'; import { useCallback, useMemo } from 'react'; import { getPlanCartItem } from 'calypso/lib/cart-values/cart-items'; @@ -46,8 +44,6 @@ export function WooExpressPlans( props: WooExpressPlansProps ) { yearlyControlProps, } = props; const translate = useTranslate(); - const isEnglishLocale = useIsEnglishLocale(); - const pricingMeta = Plans.usePricingMetaForGridPlans( { planSlugs: [ PLAN_WOOEXPRESS_MEDIUM, PLAN_WOOEXPRESS_MEDIUM_MONTHLY ], siteId, @@ -74,28 +70,16 @@ export function WooExpressPlans( props: WooExpressPlansProps ) { ...yearlyControlProps, content: ( - { isEnglishLocale || - hasTranslation( 'Pay Annually {{span}}(Save %(percentageSavings)s%%){{/span}}' ) - ? translate( 'Pay Annually {{span}}(Save %(percentageSavings)s%%){{/span}}', { - args: { percentageSavings }, - components: { span: }, - } ) - : translate( 'Pay Annually (Save %(percentageSavings)s%%)', { - args: { percentageSavings }, - } ) } + { translate( 'Pay Annually {{span}}(Save %(percentageSavings)s%%){{/span}}', { + args: { percentageSavings }, + components: { span: }, + } ) } ), selected: interval === 'yearly', }, ]; - }, [ - interval, - translate, - monthlyControlProps, - percentageSavings, - yearlyControlProps, - isEnglishLocale, - ] ); + }, [ interval, translate, monthlyControlProps, percentageSavings, yearlyControlProps ] ); const onUpgradeClick = useCallback( ( cartItems?: MinimalRequestCartProduct[] | null ) => { diff --git a/client/my-sites/plans/main.jsx b/client/my-sites/plans/main.jsx index 2af75574d3a8f..e44a6206c8783 100644 --- a/client/my-sites/plans/main.jsx +++ b/client/my-sites/plans/main.jsx @@ -15,10 +15,8 @@ import { } from '@automattic/calypso-products'; import page from '@automattic/calypso-router'; import { WpcomPlansUI, Plans } from '@automattic/data-stores'; -import { englishLocales } from '@automattic/i18n-utils'; import { withShoppingCart } from '@automattic/shopping-cart'; import { useDispatch } from '@wordpress/data'; -import { hasTranslation } from '@wordpress/i18n'; import { addQueryArgs } from '@wordpress/url'; import { localize, useTranslate } from 'i18n-calypso'; import PropTypes from 'prop-types'; @@ -397,22 +395,13 @@ class PlansComponent extends Component { const wooExpressSubHeaderText = translate( "Discover what's available in your Woo Express plan." ); - - const hasEntrepreneurTrialSubHeaderTextTranslation = hasTranslation( - "Discover what's available in your %(planName)s plan." - ); - - const isEnglishLocale = englishLocales.includes( this.props.locale ); - const entrepreneurTrialSubHeaderText = - isEnglishLocale || hasEntrepreneurTrialSubHeaderTextTranslation - ? // translators: %(planName)s is a plan name. E.g. Commerce plan. - translate( "Discover what's available in your %(planName)s plan.", { - args: { - planName: getPlan( PLAN_ECOMMERCE )?.getTitle() ?? '', - }, - } ) - : translate( "Discover what's available in your Entrepreneur plan." ); + // translators: %(planName)s is a plan name. E.g. Commerce plan. + translate( "Discover what's available in your %(planName)s plan.", { + args: { + planName: getPlan( PLAN_ECOMMERCE )?.getTitle() ?? '', + }, + } ); const isWooExpressTrial = purchase?.isWooExpressTrial; diff --git a/client/my-sites/plugins/plugins-browser/index.jsx b/client/my-sites/plugins/plugins-browser/index.jsx index 2cd2402278461..9d30176fcf288 100644 --- a/client/my-sites/plugins/plugins-browser/index.jsx +++ b/client/my-sites/plugins/plugins-browser/index.jsx @@ -1,4 +1,3 @@ -import { useLocale } from '@automattic/i18n-utils'; import { useI18n } from '@wordpress/react-i18n'; import clsx from 'clsx'; import { useTranslate } from 'i18n-calypso'; @@ -110,10 +109,8 @@ const PluginsBrowser = ( { trackPageViews = true, category, search } ) => { const sites = useSelector( getSelectedOrAllSitesJetpackCanManage ); const isLoggedIn = useSelector( isUserLoggedIn ); - const { __, hasTranslation } = useI18n(); + const { __ } = useI18n(); const translate = useTranslate(); - const locale = useLocale(); - const categories = useCategories(); const fallbackCategoryName = category ? category.charAt( 0 ).toUpperCase() + category.slice( 1 ) @@ -209,17 +206,9 @@ const PluginsBrowser = ( { trackPageViews = true, category, search } ) => { isSticky={ isAboveElement } searchTerm={ search } isSearching={ isFetchingPluginsBySearchTerm } - title={ - 'en' === locale || hasTranslation( 'Flex your site’s features with plugins' ) - ? __( 'Flex your site’s features with plugins' ) - : __( 'Plugins you need to get your projects done' ) - } + title={ __( 'Flex your site’s features with plugins' ) } subtitle={ ! isLoggedIn && - ( 'en' === locale || - hasTranslation( - 'Add new functionality and integrations to your site with thousands of plugins.' - ) ) && __( 'Add new functionality and integrations to your site with thousands of plugins.' ) diff --git a/client/my-sites/site-settings/settings-newsletter/newsletter-categories-section/newsletter-categories-toggle.tsx b/client/my-sites/site-settings/settings-newsletter/newsletter-categories-section/newsletter-categories-toggle.tsx index 072e7122a0b56..39b66a7c8b900 100644 --- a/client/my-sites/site-settings/settings-newsletter/newsletter-categories-section/newsletter-categories-toggle.tsx +++ b/client/my-sites/site-settings/settings-newsletter/newsletter-categories-section/newsletter-categories-toggle.tsx @@ -1,6 +1,4 @@ -import { useIsEnglishLocale } from '@automattic/i18n-utils'; import { ToggleControl } from '@wordpress/components'; -import { useI18n } from '@wordpress/react-i18n'; import { useTranslate } from 'i18n-calypso'; import FormSettingExplanation from 'calypso/components/forms/form-setting-explanation'; @@ -18,8 +16,6 @@ const NewsletterCategoriesToggle = ( { value = false, }: NewsletterCategoriesToggleProps ) => { const translate = useTranslate(); - const { hasTranslation } = useI18n(); - const isEnglishLocale = useIsEnglishLocale(); return (
@@ -30,20 +26,13 @@ const NewsletterCategoriesToggle = ( { label={ translate( 'Enable newsletter categories' ) } /> - { isEnglishLocale || - hasTranslation( + { translate( 'Newsletter categories allow visitors to subscribe only to specific topics.' - ) - ? translate( - 'Newsletter categories allow visitors to subscribe only to specific topics.' - ) + - ' ' + - translate( - 'When enabled, only posts published under the categories selected below will be emailed to your subscribers.' - ) - : translate( - 'This will allow your visitors to specifically subscribe to the selected categories. When this is enabled, only posts published under the created newsletter categories will be sent out to your subscribers.' - ) } + ) + + ' ' + + translate( + 'When enabled, only posts published under the categories selected below will be emailed to your subscribers.' + ) }
); diff --git a/client/my-sites/subscribers/components/grow-your-audience/grow-your-audience.tsx b/client/my-sites/subscribers/components/grow-your-audience/grow-your-audience.tsx index 86db978fcf765..e4169e7feddfe 100644 --- a/client/my-sites/subscribers/components/grow-your-audience/grow-your-audience.tsx +++ b/client/my-sites/subscribers/components/grow-your-audience/grow-your-audience.tsx @@ -1,6 +1,4 @@ -import { englishLocales, useLocale, localizeUrl } from '@automattic/i18n-utils'; import { Card, CardBody, Icon, ExternalLink } from '@wordpress/components'; -import { hasTranslation } from '@wordpress/i18n'; import { chartBar, people, trendingUp } from '@wordpress/icons'; import { useTranslate } from 'i18n-calypso'; import { SectionContainer } from 'calypso/components/section'; @@ -60,7 +58,6 @@ const GrowYourAudienceCard = ( { }; const GrowYourAudience = () => { - const locale = useLocale(); const translate = useTranslate(); const siteId = useSelector( getSelectedSiteId ); const selectedSiteSlug = useSelector( getSelectedSiteSlug ); @@ -74,52 +71,26 @@ const GrowYourAudience = () => { ); const globalSiteEnabled = isAdminInterfaceWPAdmin && isClassicEarlyRelease; - const statsCardTranslated = - englishLocales.includes( locale ) || - ( hasTranslation( 'Explore your stats' ) && - hasTranslation( - 'Take a look at your stats and refine your content strategy for better engagement.' - ) && - hasTranslation( 'Check stats' ) ); - const statsUrl = ! isWPCOMSite || globalSiteEnabled ? `${ siteAdminUrl }admin.php?page=stats#!/stats/subscribers/${ selectedSiteSlug }` : `https://wordpress.com/stats/subscribers/${ selectedSiteSlug }`; - const subscribeBlockUrl = ! isWPCOMSite - ? 'https://jetpack.com/support/jetpack-blocks/subscription-form-block/' - : 'https://wordpress.com/support/wordpress-editor/blocks/subscribe-block/'; - return (

{ translate( 'Grow your audience' ) }

- { statsCardTranslated ? ( - - ) : ( - - ) } + { isWPCOMSite && ( <> getIsSiteWPCOM( state, siteId ) ); @@ -77,25 +74,14 @@ const SubscribersHeader = ( { selectedSiteId, disableCta }: SubscribersHeaderPro }, }; - const subtitle = - isEnglishLocale || - hasTranslation( - 'Add subscribers to your site and send them a free or {{link}}paid newsletter{{/link}}.' - ) - ? translate( - 'Add subscribers to your site and send them a free or {{link}}paid newsletter{{/link}}.', - subtitleOptions - ) - : translate( - 'Add subscribers to your site and send them a free or paid {{link}}newsletter{{/link}}.', - subtitleOptions - ); - return ( diff --git a/client/signup/config/steps-pure.js b/client/signup/config/steps-pure.js index 531084388df28..3b8bd2ec8f9cd 100644 --- a/client/signup/config/steps-pure.js +++ b/client/signup/config/steps-pure.js @@ -555,18 +555,16 @@ export function generateSteps( { stepName: 'site-or-domain', props: { getHeaderText( domainCart ) { - return i18n.getLocaleSlug() === 'en' || - i18n.hasTranslation( 'Choose how to use your domains' ) - ? i18n.translate( 'Choose how to use your domain', 'Choose how to use your domains', { - count: domainCart.length, - } ) - : i18n.translate( 'Choose how to use your domain' ); + return i18n.translate( + 'Choose how to use your domain', + 'Choose how to use your domains', + { + count: domainCart.length, + } + ); }, get subHeaderText() { - return i18n.getLocaleSlug() === 'en' || - i18n.hasTranslation( 'Don’t worry, you can easily change it later.' ) - ? i18n.translate( 'Don’t worry, you can easily change it later.' ) - : i18n.translate( 'Don’t worry, you can easily add a site later' ); + return i18n.translate( 'Don’t worry, you can easily change it later.' ); }, }, providesDependencies: [ diff --git a/client/signup/steps/design-picker/design-picker.tsx b/client/signup/steps/design-picker/design-picker.tsx index 0994fb636c1ac..aa981661d9baf 100644 --- a/client/signup/steps/design-picker/design-picker.tsx +++ b/client/signup/steps/design-picker/design-picker.tsx @@ -9,7 +9,7 @@ import { import { MShotsImage } from '@automattic/onboarding'; import { Button } from '@wordpress/components'; import { useViewportMatch } from '@wordpress/compose'; -import { sprintf, hasTranslation } from '@wordpress/i18n'; +import { sprintf } from '@wordpress/i18n'; import { useI18n } from '@wordpress/react-i18n'; import clsx from 'clsx'; import { noop } from 'lodash'; @@ -118,9 +118,7 @@ const DesignButton: FC< DesignButtonProps > = ( { onCheckout?.(); } } > - { 'en' === locale || hasTranslation( 'Included in WordPress.com Premium' ) - ? __( 'Included in WordPress.com Premium' ) - : __( 'Upgrade to Premium' ) } + { __( 'Included in WordPress.com Premium' ) } ); } else if ( isPremiumDesign && ! shouldUpgrade && hasPurchasedTheme ) { diff --git a/client/signup/steps/site-or-domain/index.jsx b/client/signup/steps/site-or-domain/index.jsx index 43ec9ac5f6c4a..e1de77ff3e1a9 100644 --- a/client/signup/steps/site-or-domain/index.jsx +++ b/client/signup/steps/site-or-domain/index.jsx @@ -2,7 +2,7 @@ import config from '@automattic/calypso-config'; import { Gridicon } from '@automattic/components'; import { SelectItems } from '@automattic/onboarding'; import { globe, addCard, layout } from '@wordpress/icons'; -import i18n, { localize } from 'i18n-calypso'; +import { localize } from 'i18n-calypso'; import { get, isEmpty } from 'lodash'; import { Component } from 'react'; import { connect } from 'react-redux'; @@ -61,13 +61,9 @@ class SiteOrDomain extends Component { const { translate, isReskinned, isLoggedIn, siteCount } = this.props; const domainName = this.getDomainName(); - let buyADomainTitle = - i18n.getLocaleSlug() === 'en' || i18n.hasTranslation( 'Just buy domains' ) - ? translate( 'Just buy a domain', 'Just buy domains', { - count: this.getDomainCart().length, - } ) - : translate( 'Just buy a domain' ); - + let buyADomainTitle = translate( 'Just buy a domain', 'Just buy domains', { + count: this.getDomainCart().length, + } ); if ( this.isLeanDomainSearch() && domainName ) { // translators: %s is a domain name buyADomainTitle = translate( 'Just buy %s', { args: [ domainName ] } ); @@ -75,11 +71,7 @@ class SiteOrDomain extends Component { const choices = []; - const buyADomainDescription = - i18n.getLocaleSlug() === 'en' || i18n.hasTranslation( 'Add a site later.' ) - ? translate( 'Add a site later.' ) - : translate( 'Show a "coming soon" notice on your domain. Add a site later.' ); - + const buyADomainDescription = translate( 'Add a site later.' ); if ( isReskinned ) { choices.push( { key: 'domain', @@ -94,29 +86,15 @@ class SiteOrDomain extends Component { choices.push( { key: 'page', title: translate( 'New site' ), - description: - i18n.getLocaleSlug() === 'en' || - i18n.hasTranslation( - 'Customize and launch your site.{{br/}}{{strong}}Free domain for the first year on annual plans.{{/strong}}' - ) - ? translate( - 'Customize and launch your site.{{br/}}{{strong}}Free domain for the first year on annual plans.{{/strong}}', - { - components: { - strong: , - br:
, - }, - } - ) - : translate( - 'Customize and launch your site.{{br/}}{{strong}}Free domain for the first year*{{/strong}}', - { - components: { - strong: , - br:
, - }, - } - ), + description: translate( + 'Customize and launch your site.{{br/}}{{strong}}Free domain for the first year on annual plans.{{/strong}}', + { + components: { + strong: , + br:
, + }, + } + ), icon: null, titleIcon: addCard, value: 'page', @@ -127,29 +105,15 @@ class SiteOrDomain extends Component { choices.push( { key: 'existing-site', title: translate( 'Existing WordPress.com site' ), - description: - i18n.getLocaleSlug() === 'en' || - i18n.hasTranslation( - 'Use the domain with a site you already started.{{br/}}{{strong}}Free domain for the first year on annual plans.{{/strong}}' - ) - ? translate( - 'Use the domain with a site you already started.{{br/}}{{strong}}Free domain for the first year on annual plans.{{/strong}}', - { - components: { - strong: , - br:
, - }, - } - ) - : translate( - 'Use with a site you already started.{{br/}}{{strong}}Free domain for the first year*{{/strong}}', - { - components: { - strong: , - br:
, - }, - } - ), + description: translate( + 'Use the domain with a site you already started.{{br/}}{{strong}}Free domain for the first year on annual plans.{{/strong}}', + { + components: { + strong: , + br:
, + }, + } + ), icon: null, titleIcon: layout, value: 'existing-site', diff --git a/client/sites-dashboard/components/sites-site-launch-nag.tsx b/client/sites-dashboard/components/sites-site-launch-nag.tsx index 05387929222fa..b9b7a6d2003c1 100644 --- a/client/sites-dashboard/components/sites-site-launch-nag.tsx +++ b/client/sites-dashboard/components/sites-site-launch-nag.tsx @@ -1,5 +1,4 @@ import { recordTracksEvent } from '@automattic/calypso-analytics'; -import { englishLocales, useLocale } from '@automattic/i18n-utils'; import styled from '@emotion/styled'; import { useI18n } from '@wordpress/react-i18n'; import { useInView } from 'react-intersection-observer'; @@ -84,8 +83,7 @@ const recordNagView = () => { }; export const SiteLaunchNag = ( { site }: SiteLaunchNagProps ) => { - const { __, hasTranslation } = useI18n(); - const locale = useLocale(); + const { __ } = useI18n(); const { ref } = useInView( { onChange: ( inView ) => inView && recordNagView(), } ); @@ -107,11 +105,8 @@ export const SiteLaunchNag = ( { site }: SiteLaunchNagProps ) => { const link = validSiteIntent ? getLaunchpadUrl( site.slug, validSiteIntent ) : getDashboardUrl( site.slug ); - const checklistTranslation = - hasTranslation( 'Checklist' ) || englishLocales.includes( locale ) - ? __( 'Checklist' ) - : __( 'Launch checklist' ); - const text = validSiteIntent ? __( 'Launch guide' ) : checklistTranslation; + + const text = validSiteIntent ? __( 'Launch guide' ) : __( 'Checklist' ); return ( { - if ( - getLocaleSlug() === 'en' || - getLocaleSlug() === 'en-gb' || - i18n.hasTranslation( - 'Before deleting your site, consider exporting its content as a backup' - ) - ) { - return translate( 'Before deleting your site, consider exporting its content as a backup' ); - } - - return translate( '{{strong}}%(siteDomain)s{{/strong}} will be unavailable in the future.', { - components: { - strong: , - }, - args: { - siteDomain, - }, - } ); + return translate( 'Before deleting your site, consider exporting its content as a backup' ); }; return ( @@ -93,40 +76,21 @@ class DeleteSite extends Component { this.state.confirmDomain.replace( /\s/g, '' ) !== siteDomain; const isAtomicRemovalInProgress = isFreePlan && isAtomic; - let deletionText = translate( - 'Please type in {{warn}}%(siteAddress)s{{/warn}} in the field below to confirm. ' + - 'Your site will then be gone forever.', - { - components: { - warn: , - }, - args: { - siteAddress: this.props.siteId && this.props.siteDomain, - }, - } - ); - - if ( - getLocaleSlug() === 'en' || - getLocaleSlug() === 'en-gb' || - i18n.hasTranslation( 'Before deleting your site, consider exporting its content as a backup' ) - ) { - deletionText = translate( - 'Type {{strong}}%(siteDomain)s{{/strong}} below to confirm you want to delete the site:', - { - components: { - strong: , - }, - args: { - siteDomain: this.props.siteDomain, - }, - } - ); - } - return ( <> -

{ deletionText }

+

+ { translate( + 'Type {{strong}}%(siteDomain)s{{/strong}} below to confirm you want to delete the site:', + { + components: { + strong: , + }, + args: { + siteDomain: this.props.siteDomain, + }, + } + ) } +

<> { const localeSlug = useLocale(); - const { hasTranslation } = useI18n(); if ( localeSlug !== 'en' ) { return null; } - const title = hasTranslation( 'Share your thoughts on GitHub Deployments' ) - ? translate( 'Share your thoughts on GitHub Deployments' ) - : translate( 'Hey Developer!' ); - - const description = hasTranslation( - 'Got a moment? We’d love to hear about your experience using GitHub Deployments in our quick survey.' - ) - ? translate( - 'Got a moment? We’d love to hear about your experience using GitHub Deployments in our quick survey.' - ) - : translate( - 'Got a moment? How do you like using GitHub Deployments so far? Share your thoughts with us in our quick survey.' - ); - return ReactDOM.createPortal( , - }, - } - ) - : translate( - 'We do not recommend syncing or pushing data from a staging site to live production news sites or sites that use eCommerce plugins, such as WooCommerce, without proper planning and testing. Keep in mind that data on the destination site could have newer transactions, such as customers and orders, and would be lost when overwritten by the staging site’s data.' - ); + return ( <> { showSyncPanel && ( @@ -284,7 +268,16 @@ const StagingToProductionSync = ( { { isSiteWooStore && isSqlSyncOptionChecked && ( { translate( 'Warning:' ) } - { syncWarningTranslation } + + { translate( + '{{span}}This site has WooCommerce installed.{{/span}} We do not recommend syncing or pushing data from a staging site to live production news sites or sites that use eCommerce plugins, such as WooCommerce, without proper planning and testing. Keep in mind that data on the destination site could have newer transactions, such as customers and orders, and would be lost when overwritten by the staging site’s data.', + { + components: { + span: , + }, + } + ) } + ) } diff --git a/packages/calypso-products/src/features-list.tsx b/packages/calypso-products/src/features-list.tsx index d681568235574..39c85b53fed82 100644 --- a/packages/calypso-products/src/features-list.tsx +++ b/packages/calypso-products/src/features-list.tsx @@ -1,6 +1,6 @@ import { isEnabled } from '@automattic/calypso-config'; import { MaterialIcon, ExternalLink, ExternalLinkWithTracking } from '@automattic/components'; -import { englishLocales, localizeUrl } from '@automattic/i18n-utils'; +import { localizeUrl } from '@automattic/i18n-utils'; import { DOMAIN_PRICING_AND_AVAILABLE_TLDS } from '@automattic/urls'; import i18n from 'i18n-calypso'; import { MemoExoticComponent } from 'react'; @@ -2438,36 +2438,15 @@ const FEATURES_LIST: FeatureList = { }, [ FEATURE_FAST_SUPPORT_FROM_EXPERTS ]: { getSlug: () => FEATURE_FAST_SUPPORT_FROM_EXPERTS, - getTitle: () => { - if ( - englishLocales.includes( i18n.getLocaleSlug() || 'en' ) || - i18n.hasTranslation( 'Fast support from our expert team' ) - ) { - return i18n.translate( 'Fast support from our expert team' ); - } - - return i18n.translate( 'Expert support' ); - }, + getTitle: () => i18n.translate( 'Fast support from our expert team' ), getDescription: () => i18n.translate( 'Prompt support from our expert, friendly Happiness team' ), }, [ FEATURE_PRIORITY_24_7_SUPPORT ]: { getSlug: () => FEATURE_PRIORITY_24_7_SUPPORT, - getTitle: () => { - if ( - englishLocales.includes( i18n.getLocaleSlug() || 'en' ) || - i18n.hasTranslation( 'Priority 24/7 support from our expert team' ) - ) { - return i18n.translate( 'Priority 24/7 support from our expert team' ); - } - - return i18n.translate( '24/7 priority support' ); - }, + getTitle: () => i18n.translate( 'Priority 24/7 support from our expert team' ), getDescription: () => - englishLocales.includes( i18n.getLocaleSlug() || 'en' ) || - i18n.hasTranslation( 'The fastest 24/7 support from our expert, friendly Happiness team' ) - ? i18n.translate( 'The fastest 24/7 support from our expert, friendly Happiness team' ) - : i18n.translate( '24/7 priority support' ), + i18n.translate( 'The fastest 24/7 support from our expert, friendly Happiness team' ), }, /* END: 2023 Pricing Grid Features */ @@ -2635,11 +2614,7 @@ const FEATURES_LIST: FeatureList = { }, [ FEATURE_SENSEI_SELL_COURSES ]: { getSlug: () => FEATURE_SENSEI_SELL_COURSES, - getTitle: () => - englishLocales.includes( i18n.getLocaleSlug() || 'en' ) || - i18n.hasTranslation( 'Sell courses' ) - ? i18n.translate( 'Sell courses' ) - : i18n.translate( 'Sell courses and subscriptions' ), + getTitle: () => i18n.translate( 'Sell courses' ), }, [ FEATURE_SENSEI_STORAGE ]: { getSlug: () => FEATURE_SENSEI_STORAGE, diff --git a/packages/calypso-products/src/plans-list.tsx b/packages/calypso-products/src/plans-list.tsx index f81a2bed92057..41251480e1dab 100644 --- a/packages/calypso-products/src/plans-list.tsx +++ b/packages/calypso-products/src/plans-list.tsx @@ -1,5 +1,5 @@ import { isEnabled } from '@automattic/calypso-config'; -import i18n, { getLocaleSlug, translate } from 'i18n-calypso'; +import i18n, { translate } from 'i18n-calypso'; import { FEATURE_13GB_STORAGE, FEATURE_200GB_STORAGE, @@ -3506,10 +3506,7 @@ PLANS_LIST[ PLAN_WPCOM_STARTER ] = { getStoreSlug: () => PLAN_WPCOM_STARTER, getPathSlug: () => 'starter', getDescription: () => - i18n.hasTranslation( 'Start with a custom domain name, simple payments, and extra storage.' ) || - [ 'en', 'en-gb' ].includes( getLocaleSlug() || '' ) - ? i18n.translate( 'Start with a custom domain name, simple payments, and extra storage.' ) - : i18n.translate( 'Start your WordPress.com website. Limited functionality and storage.' ), + i18n.translate( 'Start with a custom domain name, simple payments, and extra storage.' ), getSubTitle: () => i18n.translate( 'Essential features. Freedom to grow.' ), getBillingTimeFrame: () => i18n.translate( 'per month, billed yearly' ), getPlanCompareFeatures: () => [ diff --git a/packages/domain-picker/src/components/domain-suggestion-item/suggestion-item.tsx b/packages/domain-picker/src/components/domain-suggestion-item/suggestion-item.tsx index 8ed9628695f45..5fe079fc96814 100644 --- a/packages/domain-picker/src/components/domain-suggestion-item/suggestion-item.tsx +++ b/packages/domain-picker/src/components/domain-suggestion-item/suggestion-item.tsx @@ -1,7 +1,7 @@ /* eslint-disable wpcalypso/jsx-classname-namespace */ import { recordTrainTracksInteract } from '@automattic/calypso-analytics'; -import { useLocale, useLocalizeUrl } from '@automattic/i18n-utils'; +import { useLocalizeUrl } from '@automattic/i18n-utils'; import { Spinner, Button } from '@wordpress/components'; import { useViewportMatch } from '@wordpress/compose'; import { createInterpolateElement } from '@wordpress/element'; @@ -55,8 +55,7 @@ const DomainPickerSuggestionItem: React.FC< Props > = ( { type = SUGGESTION_ITEM_TYPE_RADIO, buttonRef, } ) => { - const { __, hasTranslation } = useI18n(); - const locale = useLocale(); + const { __ } = useI18n(); const localizeUrl = useLocalizeUrl(); const isMobile = ! useViewportMatch( 'small', '>=' ); @@ -73,28 +72,10 @@ const DomainPickerSuggestionItem: React.FC< Props > = ( { const freeDomainLabelFree = __( 'Free', __i18n_text_domain__ ); const freeDomainLabel = type === SUGGESTION_ITEM_TYPE_INDIVIDUAL ? freeDomainLabelDefault : freeDomainLabelFree; - - const fallbackIncludedLabel = __( 'Included with annual plans', __i18n_text_domain__ ); - const newIncludedLabel = __( 'Included in annual plans', __i18n_text_domain__ ); - const includedLabel = - locale === 'en' || hasTranslation?.( 'Included in annual plans' ) - ? newIncludedLabel - : fallbackIncludedLabel; - - // translators: text in between the marks is styled as bold text - const fallbackIncludedLabelFormatted = __( - 'First year included in paid plans', - __i18n_text_domain__ - ); - // translators: text in between the marks is styled as bold text - const newIncludedLabelFormatted = __( - 'First year included in annual plans', - __i18n_text_domain__ - ); + const includedLabel = __( 'Included in annual plans', __i18n_text_domain__ ); const includedLabelFormatted = - locale === 'en' || hasTranslation?.( 'First year included in annual plans' ) - ? newIncludedLabelFormatted - : fallbackIncludedLabelFormatted; + // translators: text in between the marks is styled as bold text + __( 'First year included in annual plans', __i18n_text_domain__ ); const paidIncludedDomainLabel = isMobile ? includedLabel : createInterpolateElement( includedLabelFormatted, { diff --git a/packages/help-center/src/components/help-center-contact-page.tsx b/packages/help-center/src/components/help-center-contact-page.tsx index 518f15d597c26..5c4f1f4d0ec8a 100644 --- a/packages/help-center/src/components/help-center-contact-page.tsx +++ b/packages/help-center/src/components/help-center-contact-page.tsx @@ -11,7 +11,7 @@ import { useGetSupportInteractions } from '@automattic/odie-client/src/data'; import { useLoadZendeskMessaging } from '@automattic/zendesk-client'; import { Button } from '@wordpress/components'; import { useEffect, useMemo, useState } from '@wordpress/element'; -import { hasTranslation, sprintf } from '@wordpress/i18n'; +import { sprintf } from '@wordpress/i18n'; import { backup, comment, Icon } from '@wordpress/icons'; import { useI18n } from '@wordpress/react-i18n'; import clsx from 'clsx'; @@ -94,7 +94,7 @@ export const HelpCenterContactPage: FC< HelpCenterContactPageProps > = ( { if ( isLanguageSupported ) { const language = getLanguage( locale )?.name; - return language && hasTranslation( 'Email (%s)' ) + return language ? sprintf( // translators: %s is the language name __( 'Email (%s)', __i18n_text_domain__ ), @@ -103,11 +103,7 @@ export const HelpCenterContactPage: FC< HelpCenterContactPageProps > = ( { : __( 'Email', __i18n_text_domain__ ); } - if ( hasTranslation( 'Email (English)' ) ) { - return __( 'Email (English)', __i18n_text_domain__ ); - } - - return __( 'Email', __i18n_text_domain__ ); + return __( 'Email (English)', __i18n_text_domain__ ); }, [ __, locale, isEnglishLocale ] ); if ( isLoading ) { diff --git a/packages/help-center/src/components/help-center-contact-support-option.tsx b/packages/help-center/src/components/help-center-contact-support-option.tsx index b5ee09deec0c3..13fe95acc3318 100644 --- a/packages/help-center/src/components/help-center-contact-support-option.tsx +++ b/packages/help-center/src/components/help-center-contact-support-option.tsx @@ -1,13 +1,11 @@ import { recordTracksEvent } from '@automattic/calypso-analytics'; import { FormInputValidation } from '@automattic/components'; import { HelpCenterSelect, HelpCenterSite } from '@automattic/data-stores'; -import { useIsEnglishLocale } from '@automattic/i18n-utils'; import { useCanConnectToZendeskMessaging, useOpenZendeskMessaging, } from '@automattic/zendesk-client'; import { useDispatch, useSelect } from '@wordpress/data'; -import { hasTranslation } from '@wordpress/i18n'; import { Icon, comment } from '@wordpress/icons'; import { useI18n } from '@wordpress/react-i18n'; import { useMemo, useState } from 'react'; @@ -36,7 +34,6 @@ const HelpCenterContactSupportOption = ( { trackEventName, }: HelpCenterContactSupportOptionProps ) => { const { __ } = useI18n(); - const isEnglishLocale = useIsEnglishLocale(); const { hasActiveChats, isEligibleForChat } = useChatStatus(); const { resetStore, setShowHelpCenter } = useDispatch( HELP_CENTER_STORE ); const currentSupportInteraction = useSelect( @@ -59,12 +56,8 @@ const HelpCenterContactSupportOption = ( { const [ hasSubmittingError, setHasSubmittingError ] = useState< boolean >( false ); const supportHeaderText = useMemo( () => { - if ( isEnglishLocale || ! hasTranslation( 'Contact WordPress.com Support (English)' ) ) { - return __( 'Contact WordPress.com Support', __i18n_text_domain__ ); - } - - return __( 'Contact WordPress.com Support (English)', __i18n_text_domain__ ); - }, [ __, isEnglishLocale ] ); + return __( 'Contact WordPress.com Support', __i18n_text_domain__ ); + }, [ __ ] ); const handleOnClick = () => { generateContactOnClickEvent( 'chat', trackEventName ); diff --git a/packages/help-center/src/components/help-center-gpt.tsx b/packages/help-center/src/components/help-center-gpt.tsx index e00f379debef5..e30c51b01dea2 100644 --- a/packages/help-center/src/components/help-center-gpt.tsx +++ b/packages/help-center/src/components/help-center-gpt.tsx @@ -3,12 +3,11 @@ import { recordTracksEvent } from '@automattic/calypso-analytics'; import { LoadingPlaceholder } from '@automattic/components'; import { HelpCenterSelect } from '@automattic/data-stores'; -import { useIsEnglishLocale } from '@automattic/i18n-utils'; import styled from '@emotion/styled'; import { Button, ExternalLink } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; import { createElement, createInterpolateElement } from '@wordpress/element'; -import { hasTranslation, sprintf } from '@wordpress/i18n'; +import { sprintf } from '@wordpress/i18n'; import { useI18n } from '@wordpress/react-i18n'; import React, { useEffect, useMemo, useState } from 'react'; import stripTags from 'striptags'; @@ -72,8 +71,6 @@ const handleContentClick = ( event: React.MouseEvent ) => { export function HelpCenterGPT( { onResponseReceived, redirectToArticle }: Props ) { const { __ } = useI18n(); - const isEnglishLocale = useIsEnglishLocale(); - const [ feedbackGiven, setFeedbackGiven ] = useState< boolean >( false ); // Report loading state up. @@ -152,12 +149,8 @@ export function HelpCenterGPT( { onResponseReceived, redirectToArticle }: Props }; const aiResponseHeader = useMemo( () => { - if ( isEnglishLocale || hasTranslation( 'AI Generated Response:' ) ) { - return __( 'AI Generated Response:', __i18n_text_domain__ ); - } - - return __( 'Quick response:', __i18n_text_domain__ ); - }, [ __, isEnglishLocale ] ); + return __( 'AI Generated Response:', __i18n_text_domain__ ); + }, [ __ ] ); return (
diff --git a/packages/plans-grid/src/plans-interval-toggle/index.tsx b/packages/plans-grid/src/plans-interval-toggle/index.tsx index 2ef7ebbe5d649..54206acb34789 100644 --- a/packages/plans-grid/src/plans-interval-toggle/index.tsx +++ b/packages/plans-grid/src/plans-interval-toggle/index.tsx @@ -1,4 +1,3 @@ -import { useLocale } from '@automattic/i18n-utils'; import { Popover } from '@wordpress/components'; import { sprintf } from '@wordpress/i18n'; import { useI18n } from '@wordpress/react-i18n'; @@ -59,27 +58,14 @@ const PlansIntervalToggle: React.FunctionComponent< PlansIntervalToggleProps > = className = '', children, } ) => { - const { __, _x, hasTranslation } = useI18n(); - const locale = useLocale(); + const { __, _x } = useI18n(); const [ spanRef, setSpanRef ] = useState< HTMLSpanElement >(); - - const fallbackMonthlyLabel = __( 'Pay monthly', __i18n_text_domain__ ); - // Translators: intended as "pay monthly", as opposed to "pay annually" - const newMonthlyLabel = _x( 'Monthly', 'Adverb (as in "Pay monthly")', __i18n_text_domain__ ); const monthlyLabel = - locale === 'en' || - hasTranslation( 'Monthly', 'Adverb (as in "Pay monthly")', __i18n_text_domain__ ) - ? newMonthlyLabel - : fallbackMonthlyLabel; - - const fallbackAnnuallyLabel = __( 'Pay annually', __i18n_text_domain__ ); - // Translators: intended as "pay annually", as opposed to "pay monthly" - const newAnnuallyLabel = _x( 'Annually', 'Adverb (as in "Pay annually")', __i18n_text_domain__ ); + // Translators: intended as "pay monthly", as opposed to "pay annually" + _x( 'Monthly', 'Adverb (as in "Pay monthly")', __i18n_text_domain__ ); const annuallyLabel = - locale === 'en' || - hasTranslation( 'Annually', 'Adverb (as in "Pay annually")', __i18n_text_domain__ ) - ? newAnnuallyLabel - : fallbackAnnuallyLabel; + // Translators: intended as "pay annually", as opposed to "pay monthly" + _x( 'Annually', 'Adverb (as in "Pay annually")', __i18n_text_domain__ ); return (
= ( { popularBadgeText, CTAButtonLabel, } ) => { - const { __, hasTranslation } = useI18n(); - const locale = useLocale(); - + const { __ } = useI18n(); const planProduct = useSelect( ( select ) => ( select( PLANS_STORE ) as PlansSelect ).getPlanProduct( slug, billingPeriod ), [ slug, billingPeriod ] @@ -102,17 +99,15 @@ const PlanItem: React.FunctionComponent< Props > = ( { const fullWidthCtaLabelSelected = __( 'Current Selection', __i18n_text_domain__ ); // translators: %s is a WordPress.com plan name (eg: Free, Personal) const fullWidthCtaLabelUnselected = __( 'Select %s', __i18n_text_domain__ ); - - const fallbackPlanItemPriceLabelAnnually = __( 'billed annually', __i18n_text_domain__ ); // translators: %s is the cost per year (e.g "billed as 96$ annually") const newPlanItemPriceLabelAnnually = __( 'per month, billed as %s annually', __i18n_text_domain__ ); - const planItemPriceLabelAnnually = - locale === 'en' || hasTranslation?.( 'per month, billed as %s annually' ) - ? sprintf( newPlanItemPriceLabelAnnually, planProduct?.annualPrice ) - : fallbackPlanItemPriceLabelAnnually; + const planItemPriceLabelAnnually = sprintf( + newPlanItemPriceLabelAnnually, + planProduct?.annualPrice + ); const planItemPriceLabelMonthly = __( 'per month, billed monthly', __i18n_text_domain__ ); From 3693c8415c42b7c4750e4deac5e80a0576167403 Mon Sep 17 00:00:00 2001 From: Christos Date: Thu, 9 Jan 2025 17:37:41 +0200 Subject: [PATCH 2/3] use-my-domain/domain-input --- .../domains/use-my-domain/domain-input.jsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/client/components/domains/use-my-domain/domain-input.jsx b/client/components/domains/use-my-domain/domain-input.jsx index 3a4bf5b689289..1025d2d33af3a 100644 --- a/client/components/domains/use-my-domain/domain-input.jsx +++ b/client/components/domains/use-my-domain/domain-input.jsx @@ -1,6 +1,5 @@ import { Card, Button, FormInputValidation, Gridicon } from '@automattic/components'; -import { englishLocales, useLocale } from '@automattic/i18n-utils'; -import { __, hasTranslation } from '@wordpress/i18n'; +import { __ } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; import PropTypes from 'prop-types'; import { useEffect, useRef } from 'react'; @@ -25,7 +24,6 @@ function UseMyDomainInput( { validationError, } ) { const domainNameInput = useRef( null ); - const locale = useLocale(); useEffect( () => { shouldSetFocus && domainNameInput.current.focus(); @@ -47,12 +45,6 @@ function UseMyDomainInput( { } }; - const hasDomainPlaceholderLabel = - englishLocales.includes( locale ) || hasTranslation( 'yourgroovydomain.com' ); - const domainPlaceholderLabel = hasDomainPlaceholderLabel - ? __( 'yourgroovydomain.com' ) - : __( 'mydomain.com' ); - return ( { ! isSignupStep && ( @@ -64,7 +56,7 @@ function UseMyDomainInput( { Date: Thu, 9 Jan 2025 17:50:09 +0200 Subject: [PATCH 3/3] remove redundant memo --- .../src/components/help-center-contact-support-option.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/help-center/src/components/help-center-contact-support-option.tsx b/packages/help-center/src/components/help-center-contact-support-option.tsx index 13fe95acc3318..884d3c5b7bcf8 100644 --- a/packages/help-center/src/components/help-center-contact-support-option.tsx +++ b/packages/help-center/src/components/help-center-contact-support-option.tsx @@ -8,7 +8,7 @@ import { import { useDispatch, useSelect } from '@wordpress/data'; import { Icon, comment } from '@wordpress/icons'; import { useI18n } from '@wordpress/react-i18n'; -import { useMemo, useState } from 'react'; +import { useState } from 'react'; import useChatStatus from '../hooks/use-chat-status'; import { HELP_CENTER_STORE } from '../stores'; import ThirdPartyCookiesNotice from './help-center-third-party-cookies-notice'; @@ -55,10 +55,6 @@ const HelpCenterContactSupportOption = ( { const [ hasSubmittingError, setHasSubmittingError ] = useState< boolean >( false ); - const supportHeaderText = useMemo( () => { - return __( 'Contact WordPress.com Support', __i18n_text_domain__ ); - }, [ __ ] ); - const handleOnClick = () => { generateContactOnClickEvent( 'chat', trackEventName ); @@ -117,7 +113,7 @@ const HelpCenterContactSupportOption = ( {
-

{ supportHeaderText }

+

{ __( 'Contact WordPress.com Support', __i18n_text_domain__ ) }

{ __( 'Our Happiness team will get back to you soon', __i18n_text_domain__ ) }