{"action":"created","issue":{"url":"https://api.github.com/repos/processwire/processwire-issues/issues/423","repository_url":"https://api.github.com/repos/processwire/processwire-issues","labels_url":"https://api.github.com/repos/processwire/processwire-issues/issues/423/labels{/name}","comments_url":"https://api.github.com/repos/processwire/processwire-issues/issues/423/comments","events_url":"https://api.github.com/repos/processwire/processwire-issues/issues/423/events","html_url":"https://github.com/processwire/processwire-issues/issues/423","id":271270662,"number":423,"title":"Handling decimal numbers: setlocale(LC_NUMERIC, 'C')","user":{"login":"suntrop","id":1328092,"avatar_url":"https://avatars3.githubusercontent.com/u/1328092?v=4","gravatar_id":"","url":"https://api.github.com/users/suntrop","html_url":"https://github.com/suntrop","followers_url":"https://api.github.com/users/suntrop/followers","following_url":"https://api.github.com/users/suntrop/following{/other_user}","gists_url":"https://api.github.com/users/suntrop/gists{/gist_id}","starred_url":"https://api.github.com/users/suntrop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suntrop/subscriptions","organizations_url":"https://api.github.com/users/suntrop/orgs","repos_url":"https://api.github.com/users/suntrop/repos","events_url":"https://api.github.com/users/suntrop/events{/privacy}","received_events_url":"https://api.github.com/users/suntrop/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-05T11:51:10Z","updated_at":"2017-12-04T10:46:29Z","closed_at":null,"author_association":"NONE","body":"### Short description of the issue\r\nsetlocale() issue with decimal numbers\r\n\r\n### Expected behavior\r\n3.14\r\nPW should always work with the 'default' numeric representation and keep numbers with a point as decimal separator and not converting it globally with LC_ALL to a comma separated number (for most European locales).\r\n\r\n### Actual behavior\r\n3,14\r\nPW uses LC_ALL to \"print\" everything localised. While this is handy for names of months or displaying something like 32,99 € it makes working with numbers and saving difficult.\r\n\r\n### Optional: Screenshots/Links that demonstrate the issue\r\nPlease have a look at a problem I got here:\r\nhttps://processwire.com/talk/topic/17565-dont-convert-thousand-separator-point-comma/\r\n\r\nor\r\nhttps://processwire.com/talk/topic/4123-decimal-point-changed-to-in-base-of-setlocale/?do=findComment&comment=142861\r\nhttps://stackoverflow.com/questions/22019035/json-decode-reformatting-decimals-in-json-based-on-locale\r\nhttps://stackoverflow.com/questions/2906326/setlocale-to-fr-fr-in-php-and-number-formatting\r\n\r\n### Optional: Suggestion for a possible fix\r\nAdd setlocale(LC_NUMERIC, 'C')\r\n\r\n### Steps to reproduce the issue\r\nSee my first link above or \r\n\r\n```\r\n\r\n<?php\r\n$number = 1314.15;\r\nsetlocale(LC_ALL, 'de_DE');\r\nsetlocale(LC_NUMERIC, 'C');\r\necho $number; // raw\r\necho '<br>';\r\necho number_format($number, 1); // acording to LC_ALL\r\necho '<br>';\r\necho money_format('%(#10n', $number); // acording to LC_ALL\r\necho '<br>';\r\necho strftime('%B');\r\n\r\n\r\n```\r\n### Setup/Environment\r\n* ProcessWire version: 3.0.70\r\n* (Optional) PHP version: 7"},"comment":{"url":"https://api.github.com/repos/processwire/processwire-issues/issues/comments/348925854","html_url":"https://github.com/processwire/processwire-issues/issues/423#issuecomment-348925854","issue_url":"https://api.github.com/repos/processwire/processwire-issues/issues/423","id":348925854,"user":{"login":"ryancramerdesign","id":328272,"avatar_url":"https://avatars2.githubusercontent.com/u/328272?v=4","gravatar_id":"","url":"https://api.github.com/users/ryancramerdesign","html_url":"https://github.com/ryancramerdesign","followers_url":"https://api.github.com/users/ryancramerdesign/followers","following_url":"https://api.github.com/users/ryancramerdesign/following{/other_user}","gists_url":"https://api.github.com/users/ryancramerdesign/gists{/gist_id}","starred_url":"https://api.github.com/users/ryancramerdesign/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryancramerdesign/subscriptions","organizations_url":"https://api.github.com/users/ryancramerdesign/orgs","repos_url":"https://api.github.com/users/ryancramerdesign/repos","events_url":"https://api.github.com/users/ryancramerdesign/events{/privacy}","received_events_url":"https://api.github.com/users/ryancramerdesign/received_events","type":"User","site_admin":false},"created_at":"2017-12-04T10:46:29Z","updated_at":"2017-12-04T10:46:29Z","author_association":"CONTRIBUTOR","body":"If you want a different behavior than what the language setting dictates, you'd want to do as @matjazpotocnik suggested or use PW's `$languages->setLocale()` method (https://processwire.com/api/ref/languages/set-locale/). Also, I'd suggest putting in a /site/templates/_init.php file so that you affect on the front-end (assuming that is your `$config->prependTemplateFile` has that setting). "}}
{"actor":{"display_login":"ryancramerdesign"}}