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

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

Closed
wants to merge 1 commit into from

Conversation

adrianrudnik
Copy link

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.

  • A new feature
  • Fixed an issue (resolve #ID)

Author's checklist

Summary of changes

Review checklist

  • All checks have passed
  • Changes are added to the CHANGELOG.md
  • Changes are approved by maintainer

@localheinz
Copy link
Member

@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

@localheinz localheinz added the enhancement New feature or request label Sep 6, 2023
@localheinz localheinz added this to the 2.0.0 milestone Sep 6, 2023
@adrianrudnik
Copy link
Author

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
Copy link
Member

@adrianrudnik

Let's keep it open!

@pimjansen
Copy link

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
Copy link
Author

@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
Copy link
Member

bram-pkg commented Sep 7, 2023

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
Copy link

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
Copy link

stale bot commented Oct 15, 2023

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.

Copy link

stale bot commented Dec 15, 2023

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 stale bot closed this Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lifecycle/stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants