-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
toLocaleString straight up doesn't work on Android #19410
Comments
No temple gods answering yet i see... The problem still there, sacrifice another goat? Maybe a bigger one? |
Airbnb wrote a blog post that mentioned this issue. It seems to be caused by Android running an outdated version of JavaScriptCore. There's another issue open that's discussing a potential JSC update: #19737 As a workaround, you can use this: |
@rgabriel18 I lol'd a lot. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
This issue still exists. |
This is an issue with Javascript core used to run react native in Android and not with react native itself. To overcome this, you'll have to integrate latest javascript core into your android build or upgrade react native to 0.59. The details are documented in JSC Android Buildscripts repo. You can actually close this issue. Now for people who would like to do the locale string formatting without needing to integrate the entire javascript core, Javascript has Internationalization API which lets you format numbers to language sensitive format. Documentation available at MDN This API is not available in android and needs to be polyfilled using Intl In your project root, install the Intl library yarn add intl And then in your project's index file (index.js) add the following code at the top of the file: if(Platform.OS === 'android') { // only android needs polyfill
require('intl'); // import intl object
require('intl/locale-data/jsonp/en-IN'); // load the required locale details
} After doing the above two steps, you can now get locale string anywhere in your project using new Intl.NumberFormat('en-IN', { style: 'currency', currency: 'INR' }).format(10000000); In case you need to format number for another locale code, all the locale code details are available under the |
And the fucking issue still exist |
Since Facebook locked and closed |
Here is the function I used to display localized price for EUROPE. This only works on ios. To make it work on Android And then in your project's index file (index.js) add the following code at the top of the file:
It now works for both android and ios. |
Thanks to @DaniAkash locale now works. But i use it for dates and had another issue with the
Hope this helps others too. |
Use this method instead of using
|
Description
I would like to render a number as a properly formatted currency string.
I would also like the implementation to behave the same across both iOS and Android.
Sample code:
Environment
Steps to Reproduce
Expo Snack
Expected Behavior
I thought it would return
'$1,000'
on both iOS and Android.Actual Behavior
This only works on iOS; in this example no formatting happens at all on Android.
Screenshots
Android
iOS
The text was updated successfully, but these errors were encountered: