FakerPHP / Faker

Faker is a PHP library that generates fake data for you
https://fakerphp.github.io
Other
3.48k stars 332 forks source link

Enhancement: Added support for BCP47 / IETF language tags #746

Closed adrianrudnik closed 3 months ago

adrianrudnik commented 10 months ago

What is the reason for this PR?

Use case: Using an API Platform based project, the user chooses a locale for display of UI language, number and date formatting based on the browsers BCP 47 language tags.

The UI itself uses Javascript, so the Intl namespace is used there. The classes and functions available there operate around a BCP 47 language tag maintained by the IANA Language Subtag Registry. While similar, they are not the same. It is simple to derive a PHP Locale from that BCP 47 language tag, it is not as easy the other way around.

The goal is allow Faker to produce valid BCP 47 / IETF language tags (either with subtag or not).

Is this a worthwhile addition before I invest time into the documentation?

In addition I get errors on make test about locale based providers, i.e. InvalidArgumentException: Unable to find provider "Ietf" with locale "ar_EG", not sure why, I tried to stick with the NumberProvider for the implementation but must have missed something. getProviderClassname does not seem to fall back here.

Author's checklist

Summary of changes

Review checklist

localheinz commented 10 months ago

@adrianrudnik

Thank you for your contribution!

As far as I can tell, we have agreed a while ago not to accept any new features for fakerphp/faker:1. However, your contribution could be good for fakerphp/faker:2.0.0.

Also see

adrianrudnik commented 10 months ago

Ah thank you for the hint. I'll take a look and migrate it to 2.x if possible. Should I close this PR or reuse it for that?

localheinz commented 10 months ago

@adrianrudnik

Let's keep it open!

pimjansen commented 10 months ago

Since it depends on intl i dont see this going in the main core repo of faker. Best is to provide a custom provider that can easily be added as an extension

adrianrudnik commented 10 months ago

@pimjansen It depends on the context of Intl yes, but it does not have a code depdency or what are you referencing to?

bram-pkg commented 10 months ago

Since it depends on intl i dont see this going in the main core repo of faker. Best is to provide a custom provider that can easily be added as an extension

I don't see any of the code referencing the intl extension?

pimjansen commented 10 months ago

Since it depends on intl i dont see this going in the main core repo of faker. Best is to provide a custom provider that can easily be added as an extension

I don't see any of the code referencing the intl extension?

Ah crap i was wrong. My bad

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

stale[bot] commented 6 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.