异常处理/intl-format

PHP格式化和国际化值(如sprintf)的包装库

3.2.0 2024-07-06 18:07 UTC

This package is auto-updated.

Last update: 2024-09-17 18:10:21 UTC


README

PHP格式化和国际化值(如sprintf)的包装库

Latest Stable Version PHP from Packagist Tests Static Analysis License

为什么使用这个库?

当一个PHP项目覆盖多个国家时,国际化是一个非常重要的问题。每个国家都有自己的数字、日期或时间格式。Intl组件提供了处理所有所需格式的功能,但并不总是简单易行。

此库使用PHP的Intl组件来格式化消息,并提供类似于sprintf的API。

示例

echo $intlFormat->format('Today\'s number is %number', 1000.3);
// echo "Today's number is 1'000,3" in case of locale de_CH
// echo "Today's number is 1,000.3" in case of locale en_US

它也可以很容易地通过您自己的自定义格式进行扩展。

文档

文档中了解更多关于此库的信息。

它是否会影响GDPR?

Intl-Format本身仅使用PHP Intl扩展的给定数据(例如时区、地区)进行格式化目的。

安装

您可以使用Composer安装此库。

composer require senseexception/intl-format