infobits/intl
Composer 安装命令:
composer require infobits/intl
包简介
Internationalization data: countries, languages, currencies, continents with i18n translations
README 文档
README
Internationalization data for countries, languages, currencies, and continents with translations and SVG flags.
Installation
composer require infobits/intl
Requires PHP 8.1+.
Usage
Countries
use Infobits\Intl\Country; // Get a country by alpha-2 code $usa = Country::tryFrom('US'); echo $usa->nativeName(); // United States echo $usa->alpha3Code(); // USA echo $usa->capital(); // Washington, D.C. echo $usa->callingCode(); // 1 // Get all countries $allCountries = Country::cases(); echo count($allCountries); // 248 // Lookup by alpha-3 code $country = Country::fromAlpha3('USA'); // Lookup by numeric code $country = Country::fromNumeric(840);
Languages
use Infobits\Intl\Language; // Get a language by code $english = Language::tryFrom('en'); echo $english->nativeName(); // english echo $english->code(); // en // Case-insensitive lookup $english = Language::fromCode('EN'); // Get all languages echo count(Language::cases()); // 184
Currencies
use Infobits\Intl\Currency; // Get a currency by code $usd = Currency::tryFrom('USD'); echo $usd->nativeName(); // United States Dollar echo $usd->nativeNamePlural(); // United States Dollars echo $usd->symbol(); // $ // Case-insensitive lookup $usd = Currency::fromCode('usd'); // Get all currencies echo count(Currency::cases()); // 179
Continents
use Infobits\Intl\Continent; // Get a continent by code $europe = Continent::tryFrom('EU'); echo $europe->label(); // Europe echo $europe->code(); // EU // Get all continents foreach (Continent::cases() as $continent) { echo $continent->label() . ' (' . $continent->code() . ')'; }
Flags
use Infobits\Intl\Flags; // Get SVG flag string $usFlag = Flags::svg('US'); // Use in HTML echo '<div class="flag">' . $usFlag . '</div>'; // Get all flags $allFlags = Flags::all(); echo count($allFlags); // 256
Emoji Flags
use Infobits\Intl\Country; $usa = Country::tryFrom('US'); echo $usa->emojiFlag(); // flag emoji
Translations
use Infobits\Intl\I18n\CountriesTranslations; use Infobits\Intl\I18n\LanguagesTranslations; use Infobits\Intl\I18n\CurrenciesTranslations; use Infobits\Intl\I18n\ContinentsTranslations; use Infobits\Intl\I18n\CapitalsTranslations; // Get translated country name $name = CountriesTranslations::get('US', 'de'); // Vereinigte Staaten // Get all translations for a locale $germanCountries = CountriesTranslations::all('de'); // Get available locales $locales = CountriesTranslations::locales(); // Other translation classes work the same way $languageName = LanguagesTranslations::get('en', 'fr'); $currencyName = CurrenciesTranslations::get('USD', 'it'); $continentName = ContinentsTranslations::get('EU', 'da'); $capitalName = CapitalsTranslations::get('JP', 'es');
Features
- 248 countries with ISO 3166-1 codes
- 184 languages with ISO 639-1 codes
- 179 currencies with ISO 4217 codes
- 7 continents
- SVG country flags (inline embedded)
- Multi-language translations
- PHP 8.1 backed enums for type safety
License
MIT
infobits/intl 适用场景与选型建议
infobits/intl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「i18n」 「translations」 「intl」 「countries」 「languages」 「currencies」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 infobits/intl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 infobits/intl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 infobits/intl 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use i18n translation PHP class for multi-language websites
A custom URL rule class for Yii 2 which allows to create translated URL rules
Easy to use internationalization functions for Laravel
Provides a customizable wrapper around Intl formatters to use it inside Laravel application. And also allows defining your own formats.
Deepl Automated translations for Laravel lang files
Easy to use internationalization functions for Laravel
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-10