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

A4A: Format currency #100135

Draft
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Draft

A4A: Format currency #100135

wants to merge 3 commits into from

Conversation

yashwin
Copy link
Contributor

@yashwin yashwin commented Feb 21, 2025

Closes https://github.com/Automattic/i18n-issues/issues/921

Related to #

Proposed Changes

Why are these changes being made?

Testing Instructions

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

" For example, if your client's store generates %(maxAmount)s in TPV per year, your revenue share for that year would be %(amount)s.",
{
args: {
maxAmount: formatCurrency( 1000000, 'USD' ),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably we can stick to $1M here?

Screenshot 2025-02-21 at 3 28 04 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting! We should probably add a "compact" notation to formatCurrency. Let's stick with $1M and I can follow up on this separately.

cc @sirbrillig / @Automattic/i18n We can just allow formatCurrency to accept numberFormatOptions in the same way numberFormat does, so someone can just tailor the rendering a little better. Or otherwise we can create a numberFormatCompactCurrency abstraction. I'll create an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

I think it's better to format this the same way. I did a workaround: bd67c53, a quick hack to get this right. Let me know if this works until we have a function for it. Or we could skip the formatting for this particular section for both $1M and $500.

Screenshot 2025-02-21 at 5 14 06 PM Screenshot 2025-02-21 at 5 18 51 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

This is perfect. Thanks! Good use of the currency object parts. Glad to see there is a workaround with the existing APIs :-)

@@ -14,27 +15,39 @@ const BudgetSelector = ( { setBudget, budgetLowerRange }: Props ) => {
value: '0',
},
{
label: '$500',
label: formatCurrency( 500, 'USD', {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

EL & EN:

Screenshot 2025-02-21 at 3 20 33 PM Screenshot 2025-02-21 at 3 21 06 PM

@@ -47,11 +48,16 @@ const MigrationOfferV3 = ( { isExpanded, onToggleView }: Props ) => {
<h3 className="a4a-migration-offer-v3__title">
<span>
{ translate(
'{{b}}Limited time offer:{{/b}} Migrate your sites to Pressable or WordPress.com and earn up to $10,000!*',
'{{b}}Limited time offer:{{/b}} Migrate your sites to Pressable or WordPress.com and earn up to %(maxCommission)s*',
Copy link
Contributor Author

@yashwin yashwin Feb 21, 2025

Choose a reason for hiding this comment

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

EL & EN:

Screenshot 2025-02-21 at 3 30 14 PM Screenshot 2025-02-21 at 3 29 53 PM

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug update/a4a/format-currency on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented Feb 21, 2025

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~491 bytes added 📈 [gzipped])

name                                parsed_size           gzip_size
a8c-for-agencies-marketplace             +699 B  (+0.1%)     +188 B  (+0.1%)
a8c-for-agencies-migrations              +524 B  (+0.1%)     +148 B  (+0.1%)
a8c-for-agencies-overview                +523 B  (+0.0%)      +69 B  (+0.0%)
a8c-for-agencies-referrals               +230 B  (+0.0%)      +96 B  (+0.0%)
a8c-for-agencies-partner-directory       +219 B  (+0.0%)      +49 B  (+0.0%)
a8c-for-agencies-client                  +161 B  (+0.0%)      +40 B  (+0.0%)
a8c-for-agencies-agency-tier             +160 B  (+0.1%)      +27 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Contributor

@chriskmnds chriskmnds left a comment

Choose a reason for hiding this comment

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

This is awesome. There were quite a few after all 👍

Thanks for spotting all of these cases. I left some comments, and I'll follow up myself on one of them. Thanks for bringing it up.

@@ -245,7 +246,13 @@ export default function PressablePlanSection( {

<span className="pressable-plan-section__details-footnote">
{ translate(
`*If you exceed your plan's storage or traffic limits, you will be charged $0.50 per GB and $8 per 10K visits per month.`
`*If you exceed your plan's storage or traffic limits, you will be charged %(storageCharge)s per GB and %(trafficCharge)s per 10K visits per month.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

per 10K visits

I think let's also pass 10K through numberFormatCompact - it should render as 10 χιλ. in EL/Greek.

" For example, if your client's store generates %(maxAmount)s in TPV per year, your revenue share for that year would be %(amount)s.",
{
args: {
maxAmount: formatCurrency( 1000000, 'USD' ),
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting! We should probably add a "compact" notation to formatCurrency. Let's stick with $1M and I can follow up on this separately.

cc @sirbrillig / @Automattic/i18n We can just allow formatCurrency to accept numberFormatOptions in the same way numberFormat does, so someone can just tailor the rendering a little better. Or otherwise we can create a numberFormatCompactCurrency abstraction. I'll create an issue.

@yashwin yashwin force-pushed the update/a4a/format-currency branch from e08e599 to 5be7de0 Compare February 21, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants