此包已被弃用且不再维护。未建议替代包。

简化国际化的实用助手

维护者

详细信息

github.com/kbond/intl

源代码

问题

资助包维护!
kbond

v1.0.1 2013-12-11 15:45 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:25:55 UTC


README

此库包含用于简化PHP应用程序国际化的实用助手

地区

此组件提供所有地区的完整列表(包括元信息)。列表是从http://www.localeplanet.com/ API构建的,并包含在resources/locales.php中。

用法

// Provides the locales from the php resource
\Zenstruck\Intl\Locale::getAvailableLocales()

// Provides the locales as an assoc. array with the code as the key and name as the value
// Useful for a dropdown locale selector
\Zenstruck\Intl\Locale::getLocaleNames()

// Provides information for either the provided or default locale
\Zenstruck\Intl\Locale::getLocale('en_US')
\Zenstruck\Intl\Locale::getLocale()

// Provides only locales with both language and region set (ie "en_US", not "en")
\Zenstruck\Intl\Locale::getLocalesWithRegions()

// Provides the regions as an assoc. array with the code as the key and name as the value
\Zenstruck\Intl\Locale::getLocalesWithRegionNames()

// Provides language-only locales (ie "en", not "en_US")
\Zenstruck\Intl\Locale::getLanguages()

// Provides the languages as an assoc. array with the code as the key and name as the value
\Zenstruck\Intl\Locale::getLanguageNames()

// Provide the 3 digit ISO 4217 currency code for either the provided or default locale
\Zenstruck\Intl\Locale::getCurrency('en_US')
\Zenstruck\Intl\Locale::getCurrency()

// Provide the currency symbol for either the provided or default locale
\Zenstruck\Intl\Locale::getCurrencySymbol('en_US')
\Zenstruck\Intl\Locale::getCurrencySymbol()

资源

完整的地区列表以下格式提供

  • PHP: resources/locales.php
  • JSON: resources/locales.json

构建JSON/PHP资源

composer install --dev

php bin/build.php

运行测试套件

composer install --dev

phpunit