You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
toLocaleString straight up doesn't work on Android #19410
The problem still there, sacrifice another goat? Maybe a bigger one?
Reacted by Simon, Lucas Veiga, Lev Izraelit, Stefano Cerelli, Felipe Morales, Richard Lindhout, Reid Weber, Shahzore Qureshi and Martin Braun
Reacted by Lucas Veiga, Lev Izraelit, Ben, Stefano Cerelli, Andrei Albesteanu, Lorenzo Pieri, salazarpardo, MJ Schoen, Abhi, Richard Lindhout and 6 more
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 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.
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 polyfillrequire('intl');// import intl objectrequire('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
In case you need to format number for another locale code, all the locale code details are available under the intl/locale-data/jsonp/ directory. Simply require the ones you need in your index.js file. Hope it helps.
Reacted by IKEDA Sho, Eric Butler, Calvin Webster, Gustavo Gard, Arthur Costa, Tankred Hase, P. Michael Ossareh, Pablo Herrera, Maulik Dhameliya, Nicolas Rouanne and 8 more
Reacted by Gustavo Gard, Arthur Costa, Tankred Hase, Abhi and Daniel Reichhart
Activity
rgabriel18 commentedon Jun 8, 2018
No temple gods answering yet i see...
The problem still there, sacrifice another goat? Maybe a bigger one?
bilalq commentedon Jun 19, 2018
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:
https://github.com/react-community/jsc-android-buildscripts
luco commentedon Jul 24, 2018
@rgabriel18 I lol'd a lot.
stale commentedon Oct 22, 2018
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.
bilalq commentedon Oct 24, 2018
This issue still exists.
DaniAkash commentedon Oct 30, 2018
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
And then in your project's index file (index.js) add the following code at the top of the file:
After doing the above two steps, you can now get locale string anywhere in your project using
In case you need to format number for another locale code, all the locale code details are available under the
intl/locale-data/jsonp/directory. Simplyrequirethe ones you need in your index.js file. Hope it helps.ardyfeb commentedon Dec 7, 2018
And the fucking issue still exist
jpdriver commentedon Dec 7, 2018
Since Facebook locked and closed
#15717 and this is being discussed elsewhere, I'm following suit and closing this off 🙇🏻♂️
06 : maj searchform : bug date.toLocaleDateString() : cf. react/react…
maulikdhameliya commentedon Mar 25, 2019
Here is the function I used to display localized price for EUROPE. This only works on ios.
To make it work on Android
just install
intlusingnpm install intlAnd 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.
ehsunoo commentedon Apr 25, 2019
Use this method instead of using
toLocaleString:number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")