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

Localize currency formatter #12541

Open
2 of 3 tasks
irfano opened this issue Sep 5, 2024 · 1 comment
Open
2 of 3 tasks

Localize currency formatter #12541

irfano opened this issue Sep 5, 2024 · 1 comment
Assignees
Labels
category: i18n Related to localization/internationalization. feature: stats Related to stats shown in the app. good first issue The issue is a good candidate for a community contribution or for a newcomer to the team. type: bug A confirmed bug.

Comments

@irfano
Copy link
Contributor

irfano commented Sep 5, 2024

Describe the bug
Formatting high numbers like "1000 → 1k", "1000000 → 1M" should be localized, and "k", "m" chars shouldn't be hardcoded.

Note for the developer:

private fun currencyStringRounded(rawValue: Double): String {
val roundedValue = rawValue.roundToInt().toDouble()
return if (roundedValue.absoluteValue >= ONE_MILLION) {
currencyFormatterRounded.format(roundedValue / ONE_MILLION) + "m"
} else if (roundedValue.absoluteValue >= ONE_THOUSAND) {
currencyFormatterRounded.format(roundedValue / ONE_THOUSAND) + "k"
} else {
currencyFormatter.format(roundedValue).toString().removeSuffix(".00")
}
}
}

To Reproduce
Steps to reproduce the behavior:

  1. Set the app language to Turkish.
  2. Log in with a site that has more than $1000 revenue.
  3. Open the "My Store" tab.

Screenshots

Expected behavior
It should display "1b" for the Turkish language.

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active,
    or Storefront.
  • I can reproduce this bug consistently using the steps above.

Mobile Environment

  • Device: Emulator
  • Android version: 14
  • WooCommerce Android version: 9.2.3

WordPress Environment

``` ### System Status Report generated via the WooCommerce Android app ###

WordPress Environment

WordPress Address (URL): https://irfanwoo.wpcomstaging.com
Site Address (URL): https://irfanwoo.wpcomstaging.com
WC Version: 9.2.3
Log Directory Writable: ✔
WP Version: 6.6.1
WP Multisite: –
WP Memory Limit: 512 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
External object cache: ✔

Server Environment

Server Info: nginx
PHP Version: 8.1.29
PHP Post Max Size: 1 GB
PHP Time Limit: 1200 s
PHP Max input Vars: 6144
cURL Version: 8.7.1, OpenSSL/3.0.11
Suhosin installed: –
MySQL Version: 10.6.18-MariaDB-log
PHP Post Max Size: 1 GB
Default Timezone: UTC
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibye String: ✔
Remote Post: ✔
Remote Get: ✔

Database

WC Database Version: 9.2.3
WC Database Prefix: wp_
Total Database Size: 14.57 MB
Database Data Size: 9.05 MB
Database Index Size: 5.52 MB
wp_woocommerce_sessions: Data: 0.30MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_order_itemmeta: Data: 0.11MB + Index: 0.14MB + Engine InnoDB
wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_actionscheduler_actions: Data: 1.47MB + Index: 0.73MB + Engine InnoDB
wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_actionscheduler_logs: Data: 0.34MB + Index: 0.28MB + Engine InnoDB
wp_automatewoo_abandoned_carts: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
wp_automatewoo_customers: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
wp_automatewoo_customer_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_automatewoo_guests: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_automatewoo_guest_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_automatewoo_logs: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_automatewoo_log_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_automatewoo_queue: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_automatewoo_queue_meta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_comments: Data: 0.05MB + Index: 0.09MB + Engine InnoDB
wp_gla_attribute_mapping_rules: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_gla_budget_recommendations: Data: 0.19MB + Index: 0.14MB + Engine InnoDB
wp_gla_merchant_issues: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_gla_shipping_rates: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_gla_shipping_times: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_jetpack_sync_queue: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_automations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_mailpoet_automation_runs: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
wp_mailpoet_automation_run_logs: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_mailpoet_automation_run_subjects: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_mailpoet_automation_triggers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_mailpoet_automation_versions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_custom_fields: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_dynamic_segment_filters: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_feature_flags: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_forms: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_mailpoet_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_mailpoet_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_newsletters: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_mailpoet_newsletter_links: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_mailpoet_newsletter_option: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_newsletter_option_fields: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_newsletter_posts: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_newsletter_segment: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_newsletter_templates: Data: 2.52MB + Index: 0.00MB + Engine InnoDB
wp_mailpoet_scheduled_tasks: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_mailpoet_scheduled_task_subscribers: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_segments: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_mailpoet_sending_queues: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_mailpoet_settings: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_statistics_bounces: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_mailpoet_statistics_clicks: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_mailpoet_statistics_forms: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_statistics_newsletters: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_mailpoet_statistics_opens: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
wp_mailpoet_statistics_unsubscribes: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_mailpoet_statistics_woocommerce_purchases: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
wp_mailpoet_stats_notifications: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_mailpoet_subscribers: Data: 0.02MB + Index: 0.23MB + Engine InnoDB
wp_mailpoet_subscriber_custom_field: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_subscriber_ips: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_subscriber_segment: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_mailpoet_subscriber_tag: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_mailpoet_tags: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_user_agents: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_mailpoet_user_flags: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_options: Data: 1.34MB + Index: 0.08MB + Engine InnoDB
wp_postmeta: Data: 0.19MB + Index: 0.06MB + Engine InnoDB
wp_posts: Data: 0.14MB + Index: 0.06MB + Engine InnoDB
wp_snippets: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_usermeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_wc_admin_notes: Data: 0.06MB + Index: 0.00MB + Engine InnoDB
wp_wc_admin_note_actions: Data: 0.08MB + Index: 0.02MB + Engine InnoDB
wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_orders: Data: 0.05MB + Index: 0.11MB + Engine InnoDB
wp_wc_orders_meta: Data: 0.06MB + Index: 0.11MB + Engine InnoDB
wp_wc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_wc_order_bundle_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.11MB + Engine InnoDB
wp_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_bis_activity: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
wp_woocommerce_bis_notifications: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
wp_woocommerce_bis_notificationsmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_bundled_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_bundled_items: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_gc_activity: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_gc_cards: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_gc_cardsmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_prl_deploymentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
wp_woocommerce_prl_deployments: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
wp_woocommerce_prl_frequencies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_prl_generator_queue: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
wp_woocommerce_prl_tracking_conversions: Data: 0.02MB + Index: 0.05MB + Engine InnoDB

Security

Secure Connection (HTTPS): ✔
Hide errors from visitors: ✔

Active Plugins

Akismet Anti-spam: Spam Protection: by Automattic - Anti-spam Team - 5.3.3
AutomateWoo: by WooCommerce - 6.1.0
Blaze Ads: by Automattic - 0.3.1
Code Snippets: by Code Snippets Pro - 3.6.5.1
Crowdsignal Forms: by Automattic - 1.7.2
Facebook for WooCommerce: by Facebook - 3.2.8
WordPress.com Editing Toolkit: by Automattic - 4.30504
Google for WooCommerce: by WooCommerce - 2.8.4
Gutenberg: by Gutenberg Team - 19.1.0
Hello Dolly: by Matt Mullenweg - 1.7.2
Jetpack: by Automattic - 13.8
Layout Grid: by Automattic - 1.8.4
MailPoet Premium: by MailPoet - 5.1.0
MailPoet: by MailPoet - 5.1.1
Page Optimize: by Automattic - 0.5.5
Pinterest for WooCommerce: by WooCommerce - 1.4.8
Crowdsignal Polls & Ratings: by Automattic, Inc. - 3.1.2
TikTok: by TikTok - 1.2.8
Woo AI: by WooCommerce - 0.6.0
WooCommerce.com Update Manager: by Automattic - 1.0.3
Woo Back In Stock Notifications: by Woo - 2.0.3
WooCommerce Brands: by WooCommerce - 1.7.5
Woo Gift Cards: by Woo - 2.0.3
Google Analytics for WooCommerce: by WooCommerce - 2.1.6
Woo Min/Max Quantities: by Woo - 5.0.1
Woo Product Add-ons: by Woo - 7.0.1 (update to version 7.0.3 available)
WooCommerce Product Bundles: by Woo - 8.0.3
WooCommerce Product Recommendations: by Woo - 4.0.3
WooCommerce Shipping & Tax: by WooCommerce - 2.8.0
WooCommerce Shipment Tracking: by WooCommerce - 2.5.0
WooCommerce Subscriptions: by WooCommerce - 6.5.0 (update to version 6.6.1 available)
WooCommerce: by Automattic - 9.2.3

Settings

API Enabled: –
Force SSL: –
Currency: TRY (₺)
Currency Position: left
Thousand Separator: .
Decimal Separator: ,
Number of Decimals: 2
Taxonomies: Product Types:
bundle (bundle)
external (external)
grouped (grouped)
simple (simple)
subscription (subscription)
variable (variable)
variable-subscription (variable subscription)

Taxonomies: Product Visibility:
exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

Connected to WooCommerce.com: –

WC Pages

Shop base: Page ID #7
Cart: Page ID #8
Checkout: Page ID #9
My account: Page ID #10
Terms and conditions: X Page not set

Theme

Name: Twenty Twenty
Version: 2.2-wpcom
Author URL: https://wordpress.org/
WooCommerce support: ✔
WooCommerce files: –
Outdated templates: –

Status report information

Generated at: 2024-09-05 20:11:40 +0300

</details>
@irfano irfano added type: bug A confirmed bug. category: i18n Related to localization/internationalization. labels Sep 5, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Sep 5, 2024

Thanks for reporting! 👍

@irfano irfano added feature: stats Related to stats shown in the app. good first issue The issue is a good candidate for a community contribution or for a newcomer to the team. labels Sep 6, 2024
@rossanafmenezes rossanafmenezes self-assigned this Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: i18n Related to localization/internationalization. feature: stats Related to stats shown in the app. good first issue The issue is a good candidate for a community contribution or for a newcomer to the team. type: bug A confirmed bug.
Projects
None yet
Development

No branches or pull requests

3 participants