8000 [Intl] Locale::getFallback does not split on dash · Issue #24154 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Intl] Locale::getFallback does not split on dash #24154
Closed
@lyrixx

Description

@lyrixx
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? yes
Symfony version 3.3.8 (but all others I guess, did not check yet)

Hello.

I just hit an issue with the country type and the Intl component.

According to PHP, the first parameter of Locale::setDefault
should be a BCP 47 compliant tag.

So according to the RFC, it should be something like fr or fr-FR.
In my case it's fr-FR.

Now the CountryType use the Locale::getDefault. Refs:

Then symfony will use will default locale to find the best locale by "fallbacking" on "wider" locale (fr_FR -> fr)

And here
there is something wrong IMHO. Symfony only try to split the local with an underscore (_) and not
with a dash (-). But the RFC states the locale should use an underscore and not a dash.


Some facts to take in consideration:

  • The Translator component use another RFC for the format of the locale. (fr_FR);
  • The Validator component use another RFC for the format of the locale. (fr_FR);
  • It's really weird I'm the first one to hit this issue => Did I miss something ?

What I suggest: We could update the Locale::getFallback method to support splitting on -.

WDYT? I can make the PR if this RFC is accepted.


I pushed a reproducer

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIntlRFCRFC = Request For Comments (proposals about features that you want to be discussed)Status: Needs Review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0