GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SenseException/IntlBundle: Improved and simple Intl implementations for Symfony

BranchesTags
Open more actions menu

Latest commit

 

History

148 Commits
148 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
UPGRADE.md
UPGRADE.md
 
 
composer.json
composer.json
 
 
infection.json.dist
infection.json.dist
 
 
phpcs.xml.dist
phpcs.xml.dist
 
 
phpstan.neon.dist
phpstan.neon.dist
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 

Repository files navigation

IntlBundle

Improved and simple Intl implementations for Symfony.

Latest Stable Version PHP from Packagist Tests Static Analysis License

Installation

You can install it with Composer.

composer require senseexception/intl-bundle

If the composer installation with symfony/flex didn't already register the bundle, you need to register it into your bundles.php manually:

return [
    // ...
    Budgegeria\Bundle\IntlBundle\BudgegeriaIntlBundle::class => ['all' => true],
    // ...
];

Configuration

By default a configuration doesn't need to be added if the needed locale is en_US and USD the currency. For any other locale or currency you can add the following configuration to your project and configure the needed locale and currency values:

budgegeria_intl:
  locale: 'de_DE'
  currency: 'EUR'

Usage

Formatter

The formatter can be used in two different ways: With a filter and a function

Filters

Internationalization text formatting:

{{ "This is the %ordinal time that the number %integer appears"|intl_format(4, 6000) }}
{# This is the 4th time that the number 6.000 appears #}

Functions

Internationalization text formatting:

{{ intl_format("This is the %ordinal time that the number %integer appears", 4, 6000) }}
{# This is the 4th time that the number 6.000 appears #}

Currency symbol of configured locale:

{{ currency_symbol() }}
{# € #}

Sorter

Example for configuring a sorter:

budgegeria_intl:
  locale: 'de_DE'
  currency: 'EUR'
  sorter:
    sorter_wo_locale:
      order_by_desc: ~
    my_sorter:
      order_by_desc: ~
      locale: 'de_DE'

my_sorter and sorter_wo_locale are free choosable keys that will be used to create new service ids budgegeria_intl_bundle.sorter.my_sorter and budgegeria_intl_bundle.sorter.sorter_wo_locale which can be used as dependencies.

class Foo
{
    /**
     * Injecting services "budgegeria_intl_bundle.sorter.my_sorter" or
     * "budgegeria_intl_bundle.sorter.sorter_wo_locale"
     */
    public function __construct(private Budgegeria\IntlSort\Sorter\Sorter $sorter)
    {
    }
    
    public function bar(): void
    {
        $sortedArray = $this->sorter->sort(['a', 'y', 'ä']);
    }
}

If a local is omitted like in budgegeria_intl_bundle.sorter.sorter_wo_locale, it uses the default locale set in the bundles configuration.

budgegeria_intl:
  locale: 'de_DE'

Available Configurations

Available are the method names of the Budgegeria\IntlSort\Sorter\Sorter class as underscore values.

  • enable_french_collation
  • disable_french_collation
  • lower_case_first
  • upper_case_first
  • remove_case_first
  • enable_normalization_mode
  • disable_normalization_mode
  • enable_numeric_collation
  • disable_numeric_collation
  • enable_case_level
  • disable_case_level
  • non_ignorable_alternate_handling
  • shifted_alternate_handling
  • primary_strength
  • secondary_strength
  • tertiary_strength
  • quaternary_strength
  • identical_strength
  • keep_keys
  • omit_keys
  • order_by_asc
  • order_by_desc
  • order_by_keys
  • order_by_values
  • null_first
  • null_last
  • remove_null_position

It's possible that you're using an older version of Intl-Sort where methods didn't existed yet. Read more about the methods in the Sorter documentation.

About

Improved and simple Intl implementations for Symfony

Resources

Readme
MIT license

Contributing

Contributing
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.