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

Locale\Format throws away country part, results in wrong number format for Switzerland #5073

Closed
ktruehl opened this issue Jun 17, 2016 · 11 comments
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release

Comments

@ktruehl
Copy link

ktruehl commented Jun 17, 2016

In Magento\Framework\Locale\Format the getPriceFormat() method calls on DataBundle to return the ResourceBundle for a given locale. In ResourceBundle the get() method calls the cleanLocale() method with the given locale as parameter. The cleanLocale() method throws away the country part. This results in wrongly formated numbers for countries who share languages but not the number format with other major countries, such as Switzerland. The locale de_CH gets shortened to de. For the locale de the country DE (Germany) is implied. In Germany prices are formated as #.##0,00, whereas in the German-speaking part of Switzerland prices are formated as #,##0.00.

The country part is there for a reason! I had to stupidly patch the cleanLocale() method in the ResourceBundle class to check for Swiss locales, since I have no clue why the cleanLocale() method is there in the first place. Maybe there is a good reason, but I don't have the time to find out.

@andimov
Copy link
Contributor

andimov commented Jun 22, 2016

To allow us research the issue, please, provide description according to the template.
Please, provide the used version also. If the problem is actual for a specific branch, please, specify it and be sure that the latest update was used.

@ktruehl
Copy link
Author

ktruehl commented Jun 27, 2016

@andimov
The version is 2.0.7. I gave a description of where to find the relevant code lines and how and why the problem occurs. That should largely suffice. It's clear that if you cut out the country part from the locale de_CH you're left with de, which will default to de_DE. Germany and the swiss-speaking part of Switzerland have different number formats.

@ktruehl
Copy link
Author

ktruehl commented Jun 28, 2016

Fine! It turns out, the cleanLocale() method is there for a reason. But that only means that Magento has a bigger problem than originally thought. Admittedly it will only touch a very small part of your customers. In any case, in case you're interested in further looking into this, here are the steps to reproduce the problem:

  1. Install Magento 2.1 together with the demo data.
  2. In the admin backend, change the following settings in the configuration section "General" -> "General" -> "Country Options":
    • Default Country: Switzerland
    • Allow Country: Switzerland
  3. In the admin backend, change the following settings in the configuration section "General" -> "General" -> "Locale Options":
    • Timezone: Europe/Zurich
    • Locale: German (Switzerland)
    • Weight Unit: kgs
    • First Day of Week: Monday
    • Weekend Days: Saturday + Sunday
  4. In the frontend, visit the detail page of a simple product. The price should be displayed with , as a decimal separator. However, in the german-speaking part of Switzerland the decimal separator should be ..

@SchumacherFM
Copy link
Member

We have the same annoying issue and created a hack, just an around Plugin: aroundGetPriceFormat() to force set the Swiss price format :-(

We're running M 2.1.0

@andimov andimov added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Aug 17, 2016
@andimov
Copy link
Contributor

andimov commented Aug 17, 2016

@ktruehl
I've created an internal ticket for this issue - MAGETWO-57070 and linked it to this one.

@heldchen
Copy link
Contributor

problem still present in 2.1.1

@andimov andimov removed their assignment Sep 2, 2016
@ronnybremer
Copy link

Confirmed, still exists in 2.1.1. Is there any timeline for a fix?

@bh-ref
Copy link
Contributor

bh-ref commented Feb 20, 2017

This issue is still present in 2.1.4

@ewallkrishnaprakash
Copy link

This issue is still exist in 2.1.5

@SchumacherFM
Copy link
Member

IMHO: There will be no fix at all for the 2.1 branch. It might be fixed in 2.2 as many other things.

cpartica pushed a commit that referenced this issue Jul 14, 2017
cpartica pushed a commit that referenced this issue Jul 14, 2017
cpartica pushed a commit that referenced this issue Jul 14, 2017
cpartica pushed a commit that referenced this issue Jul 14, 2017
Fixed issues:
- MAGETWO-57995 [GITHUB] Simple product videos display the thumbnail image rather than the embedded video player. #6360
- MAGETWO-57070 [GitHub] Locale\Format throws away country part, results in wrong number format #5073
- MAGETWO-69854 Can't set allowed or default currencies using config:set command
- MAGETWO-66627 [GitHub] Default Post Code is applied for all Order's addresses if zip is not required
- MAGETWO-66906 Deprecate setup:store-config:set command
- MAGETWO-67274 Can't set value using config:set on uninstalled instance
- MAGETWO-70294 [GitHub] Mass Actions with Childs don't work in CMS #9854
- MAGETWO-70216 Remove section i18n from shared file (config.php)
- MAGETWO-59514 Hard coded "tax_region_id" in the \Magento\Tax\Setup\InstallData
@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@ktruehl, thank you for your report.
The issue is already fixed in 2.2.0

@magento-engcom-team magento-engcom-team added 2.1.x Fixed in 2.2.x The issue has been fixed in 2.2 release line Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release labels Sep 20, 2017
magento-engcom-team pushed a commit that referenced this issue Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release
Projects
None yet
Development

No branches or pull requests

8 participants