senseexception / intl-format-bundle

此包已被弃用且不再维护。作者建议使用senseexception/intl-bundle包。

PHP intl 消息的 IntlFormat 包装库的 Symfony 扩展包

安装: 15

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

v1.1.0 2021-09-01 22:19 UTC

This package is auto-updated.

Last update: 2022-05-06 21:17:39 UTC


README

这是一个用于 PHP intl 消息的 Intl-Format 包装库 的 Symfony 扩展包。该包目前处于开发阶段,可能会引入 BC 破坏。

Latest Stable Version PHP from Packagist Tests Static Analysis License

安装

您可以使用 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() }}
{##}