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

feat(locale): introduce 'Locale' component #445

Merged
merged 1 commit into from
Mar 19, 2024
Merged

feat(locale): introduce 'Locale' component #445

merged 1 commit into from
Mar 19, 2024

Conversation

azjezz
Copy link
Owner

@azjezz azjezz commented Mar 19, 2024

No description provided.

@azjezz azjezz added Priority: High After critical issues are fixed, these should be dealt with before any further issues. Status: Accepted It's clear what the subject of the issue is about, and what the resolution should be. Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness Type: Enhancement Most issues will probably ask for additions or changes. labels Mar 19, 2024
@azjezz azjezz requested a review from veewee March 19, 2024 06:26
@azjezz azjezz self-assigned this Mar 19, 2024
/**
* Represents a locale identifier.
*/
enum Locale: string
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cases for this enum were mostly generated using a script, we could add more in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to include said script and check from time to time that new locales are added automatically?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I used actually, but had to go over the result manually and update some names as they contained non-ASCII characters.

I think it would be nice to have a nice script for this in the future, but I don't see the value on having this in the repo.

foreach (\ResourceBundle::getLocales('') as $locale) {
    $name = \Locale::getDisplayName($locale, 'en');
    $name = \Psl\Str\replace_every($name, [
        '(' => '',
        ')' => '',
        '[' => '',
        ']' => '',
        ',' => '',
        '.' => '',
        '&' => '',
        '-' => '',
        ' ' => '',
    ]);

    echo 'case ' . $name . ' = "' . $locale . '";' . PHP_EOL;
}

@coveralls
Copy link

coveralls commented Mar 19, 2024

Pull Request Test Coverage Report for Build 8338640735

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 99.015%

Totals Coverage Status
Change from base Build 8045710476: 0.001%
Covered Lines: 4224
Relevant Lines: 4266

💛 - Coveralls

Copy link
Collaborator

@veewee veewee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@azjezz azjezz merged commit 5f0aeac into next Mar 19, 2024
28 checks passed
@azjezz azjezz deleted the feat/locale branch March 19, 2024 06:54
@azjezz azjezz added this to the 3.0.0 milestone Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High After critical issues are fixed, these should be dealt with before any further issues. Status: Accepted It's clear what the subject of the issue is about, and what the resolution should be. Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants