Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show "postal code check" label based on store country #9952

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-9896-postal-code-label
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Localize postal code check label based on country.
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ exports[`Order details page should match the snapshot - Charge without payment i
<h4
class="payment-method-detail__label"
>
Zip check
ZIP check
</h4>
<p
class="payment-method-detail__value"
Expand Down
18 changes: 17 additions & 1 deletion client/payment-details/payment-method/card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ const formatPaymentMethodDetails = ( charge ) => {
};
};

/**
* Returns the label for the postal code check.
*
* @return {string} The label for the postal code check.
*/
const getPostalCodeCheckLabel = () => {
switch ( wcpaySettings.connect.country ) {
case 'US':
return 'ZIP check';
case 'UK':
return 'Postcode check';
default:
return __( 'Postal code check', 'woocommerce-payments' );
}
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes the "postal code check" label to display dynamically based on the store country. I chose that approach over just localizing "Postal code check" because that leaves it open to the translator to decide how to translate.

I think this should be left up to the translator. This is just part of the knowledge you need to have if you're doing translations. For example, I know that in Canada a "ZIP code" is typically called a "postal code", and in Icelandic it's "póstnúmer" (e. post number).

If we're worried that the addition of "check" creates some confusion for translators I think it'd be better to add a translation note with some additional context like Label for results of a ZIP check performed by a credit card issuer, or something along those lines instead of trying to localize this ourselves for some countries but not others.

FYI @aheckler since I think you reported the original issue? I think "Postal code check" will be just as confusing for a US person as a "ZIP code check" will be for a UK/CA person. I think this is best left to localizations instead of trying to maintain this ourselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just part of the knowledge you need to have if you're doing translations

I went down that path initially because anyone can contribute to translations. But I agree with your other points, especially about maintenance, and that's why I adopted your suggestion for reverting that and adding a translator note in 85b041d 👍

Copy link
Contributor

@reykjalin reykjalin Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making that change! I'd still like to see what @aheckler thinks, so lets give Adam another day to reply :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it'd be OK to localize it ourselves here since Stripe's AVS integration really only applies to the UK, U.S., and Canada. Source. Since we know the appropriate terms for those locations, perhaps we can hardcode those and then just use AVS Check for other countries where the check won't occur anyway?

/**
* Placeholders to display while loading.
*/
Expand Down Expand Up @@ -205,7 +221,7 @@ const CardDetails = ( { charge = {}, isLoading } ) => {

<Detail
isLoading={ isLoading }
label={ __( 'Zip check', 'woocommerce-payments' ) }
label={ getPostalCodeCheckLabel() }
>
<Check checked={ postalCodeCheck } />
</Detail>
Expand Down
4 changes: 2 additions & 2 deletions client/payment-details/test/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ exports[`Payment details page should match the snapshot - Charge query param 1`]
aria-busy="true"
class="is-loadable-placeholder is-block"
>
Zip check
ZIP check
</span>
</h4>
<p
Expand Down Expand Up @@ -1048,7 +1048,7 @@ exports[`Payment details page should match the snapshot - Payment Intent query p
<h4
class="payment-method-detail__label"
>
Zip check
ZIP check
</h4>
<p
class="payment-method-detail__value"
Expand Down
Loading