Skip to content

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

Closed
@ktruehl

Description

@ktruehl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releasebug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions