senseexception / intl-format-bundle
v1.1.0
2021-09-01 22:19 UTC
Requires
- php: ^7.3 || ^8.0
- ext-intl: *
- senseexception/intl-format: ^2.0
- symfony/config: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/http-foundation: ^4.4 || >= 5.0.7, < 6.0.0
- symfony/http-kernel: ^4.4 || ^5.0
- symfony/twig-bundle: ^4.4 || ^5.0
Requires (Dev)
- infection/infection: ^0.18
- phpstan/phpstan: ^0.12
- phpstan/phpstan-phpunit: ^0.12
- phpunit/phpunit: ^9.3
- psalm/plugin-phpunit: ^0.15
- psalm/plugin-symfony: ^2.3
- vimeo/psalm: ^4.7
This package is auto-updated.
Last update: 2022-05-06 21:17:39 UTC
README
这是一个用于 PHP intl 消息的 Intl-Format 包装库 的 Symfony 扩展包。该包目前处于开发阶段,可能会引入 BC 破坏。
安装
您可以使用 Composer 进行安装。
composer require senseexception/intl-format-bundle
如果使用 symfony/flex 的 composer 安装没有预先注册该包,您需要手动将其注册到 bundles.php 中
return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Budgegeria\Bundle\IntlFormatBundle\BudgegeriaIntlFormatBundle::class => ['all' => true], // ... ];
配置
默认情况下,如果所需的区域设置为 en_US 且货币为 USD,则无需添加配置。对于任何其他区域或货币,您可以在项目中添加以下配置,并配置所需的区域和货币值
budgegeria_intl_format: locale: 'de_DE' currency: 'EUR'
使用方法
IntlFormatBundle 实现了 Intl-Format 的功能,并为使用库中记录的类型说明符提供了 Twig 扩展。
过滤器
国际化文本格式化
{{ "This is the %ordinal time that the number %integer appear"|intl_format(4, 6000) }}
{# This is the 4th time that the number 6.000 appear #}
函数
国际化文本格式化
{{ intl_format("This is the %ordinal time that the number %integer appear", 4, 6000) }}
{# This is the 4th time that the number 6.000 appear #}
配置区域设置的货币符号
{{ currency_symbol() }}
{# € #}