Title: toLocaleString() doesn't localise the number · Issue #8249 · NativeScript/NativeScript · GitHub
Open Graph Title: toLocaleString() doesn't localise the number · Issue #8249 · NativeScript/NativeScript
X Title: toLocaleString() doesn't localise the number · Issue #8249 · NativeScript/NativeScript
Description: Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project): CLI: ? Cross-platform modules: ? Android Runtime...
Open Graph Description: Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project): CLI: ? C...
X Description: Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project): CLI: ? C...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/8249
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"toLocaleString() doesn't localise the number","articleBody":"**Environment**\r\nProvide version numbers for the following components (information can be retrieved by running `tns info` in your project folder or by inspecting the `package.json` of the project):\r\n - CLI: ?\r\n - Cross-platform modules: ?\r\n - Android Runtime: ?\r\n - iOS Runtime: ?\r\n - Plugin(s): ?\r\n\r\nI'm running the latest version of everything (the project is a month old), but couldn't find any version numbers matching the mentioned packages in with either `tns info` or by looking in my package file.\r\n\r\n**Describe the bug**\r\n\u003c!-- A clear and concise description of what the bug is. Please, explain whether it's a build time error or a runtime error. More detailed logs can be easily obtained by following the instructions in this guide: https://docs.nativescript.org/get-support#how-to-obtain-diagnostic-reports. -->\r\n\r\nTo format nice readable numbers all modern browsers support the function `toLocaleString`, which helps adding localised thousand separators, decimal separators, rounding of decimals, padding of decimals and a lot more.\r\nIn NativeScript this functions returns the same value as `toString` which doesn't support any of the mentioned features.\r\n\r\n**To Reproduce**\r\n\u003c!-- Add commands used or steps taken to reproduce the behaviour. -->\r\n```javascript\r\nconst someNumber = 1337.4242\r\nconst formattedNumber = someNumber.toLocaleString('en', {maximumFractionDigits: 2})\r\n```\r\n\r\n**Expected behavior**\r\n`formattedNumber` should now contain the string `1,337.42`\r\nInstead it contains the string `1337.4242`\r\n\r\n**Sample project**\r\n\u003c!-- If possible, provide a link from the [Playground](https://play.nativescript.org) with reproduction of the problem. If not, consider attaching a sample project or link to a repository with such project. -->\r\nI don't have a sample project, but expect the behaviour to be the same in alle projects.\r\n\r\n**Additional context**\r\n\u003c!-- Add any other context about the problem here. -->\r\nWe could implement a formatting function ourself, but because of code sharing between projects, it would also mean that this custom formatter would be used in our web based projects, which seems a bit silly, since the browsers already know how to format numbers.\r\n\r\nDocumentation for the browser implementation can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString","author":{"url":"https://github.com/Znegl","@type":"Person","name":"Znegl"},"datePublished":"2020-01-15T12:27:07Z","url":"https://github.com/NativeScript/NativeScript/issues/8249"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7e12bc1e-d09a-29bb-8104-1289139a407d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AED8:2C4BED:121CF59:1711E18:6B011DD8 |
| html-safe-nonce | 0c29e0f80970cb8b7913e2635b30e5296ce20e192f00069d2cf30b65cd8c1490 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUQ4OjJDNEJFRDoxMjFDRjU5OjE3MTFFMTg6NkIwMTFERDgiLCJ2aXNpdG9yX2lkIjoiMTQ5Nzk3MTEyMTYwNDA3NDk2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e29ff334412b80a3120d35360131d2d14e14f4e3003185efcef879712f0ec97f |
| hovercard-subject-tag | issue:550156302 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/NativeScript/8249/issue_layout |
| twitter:image | https://opengraph.githubassets.com/94b2c14b3a630502de56581ae4781c8df781b340f4486269c4d17062044c2a7d/NativeScript/NativeScript/issues/8249 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/94b2c14b3a630502de56581ae4781c8df781b340f4486269c4d17062044c2a7d/NativeScript/NativeScript/issues/8249 |
| og:image:alt | Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project): CLI: ? C... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Znegl |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width