matriphe/iso-639
Composer 安装命令:
composer require matriphe/iso-639
包简介
PHP library to convert ISO-639-1 code to language name.
README 文档
README
PHP library to convert ISO-639-1 code to language name, based on Wikipedia's List of ISO 639-1 codes.
Installation
For PHP 8.1 or latest:
composer require matriphe/iso-639
For older PHP version:
composer require matriphe/iso-639:1.3
Requirements
- PHP 8.0 or higher
- Optional:
ext-mbstringextension for better multibyte character support
The library will work without the mbstring extension, but for optimal handling of multibyte characters (like accented characters, Cyrillic, Arabic, etc.) in language names, it's recommended to install the mbstring extension.
Usage Example
<?php required 'src/ISO639.php'; //required 'vendor/autoload.php'; // If using composer $iso = new Matriphe\ISO639\ISO639; // Get language name from ISO-639-1 code echo $iso->languageByCode1('en'); // English echo $iso->languageByCode1('id'); // Indonesian echo $iso->languageByCode1('jv'); // Javanese // Get native language name from ISO-639-1 code echo $iso->nativeByCode1('en'); // English echo $iso->nativeByCode1('id'); // Bahasa Indonesia echo $iso->nativeByCode1('jv'); // basa Jawa // Get native language name from ISO-639-1 code with capitalized echo $iso->nativeByCode1('en', true); // English echo $iso->nativeByCode1('id', true); // Bahasa Indonesia echo $iso->nativeByCode1('jv', true); // Basa Jawa echo $iso->nativeByCode1('hi', true); // हिन्दी, हिंदी echo $iso->nativeByCode1('th', true); // ไทย echo $iso->nativeByCode1('ko', true); // 한국어 echo $iso->nativeByCode1('ja', true); // 日本語 (にほんご) echo $iso->nativeByCode1('zh', true); // '中文 (Zhōngwén), 汉语, 漢語 echo $iso->nativeByCode1('ru', true); // Русский echo $iso->nativeByCode1('ar', true); // االعربية echo $iso->nativeByCode1('vi', true); // Việt Nam // Get language name from ISO-639-2t code echo $iso->languageByCode2t('eng'); // English echo $iso->languageByCode2t('ind'); // Indonesian echo $iso->languageByCode2t('jav'); // Javanese // Get native language name from ISO-639-2t code echo $iso->nativeByCode2t('eng'); // English echo $iso->nativeByCode2t('ind'); // Bahasa Indonesia echo $iso->nativeByCode2t('jav'); // basa Jawa // Get native language name from ISO-639-2t code with capitalized echo $iso->nativeByCode2t('eng', true); // English echo $iso->nativeByCode2t('ind', true); // Bahasa Indonesia echo $iso->nativeByCode2t('jav', true); // Basa Jawa echo $iso->nativeByCode2t('hin', true); // हिन्दी, हिंदी echo $iso->nativeByCode2t('tha', true); // ไทย echo $iso->nativeByCode2t('kor', true); // 한국어 echo $iso->nativeByCode2t('jpn', true); // 日本語 (にほんご) echo $iso->nativeByCode2t('zho', true); // '中文 (Zhōngwén), 汉语, 漢語 echo $iso->nativeByCode2t('rus', true); // Русский echo $iso->nativeByCode2t('ara', true); // االعربية echo $iso->nativeByCode2t('vie', true); // Việt Nam // Get language name from ISO-639-2b code echo $iso->languageByCode2b('eng'); // English echo $iso->languageByCode2b('ind'); // Indonesian echo $iso->languageByCode2b('jav'); // Javanese // Get native language name from ISO-639-2b code echo $iso->nativeByCode2b('eng'); // English echo $iso->nativeByCode2b('ind'); // Bahasa Indonesia echo $iso->nativeByCode2b('jav'); // basa Jawa // Get native language name from ISO-639-2b code with capitalized echo $iso->nativeByCode2b('eng', true); // English echo $iso->nativeByCode2b('ind', true); // Bahasa Indonesia echo $iso->nativeByCode2b('jav', true); // Basa Jawa echo $iso->nativeByCode2b('hin', true); // हिन्दी, हिंदी echo $iso->nativeByCode2b('tha', true); // ไทย echo $iso->nativeByCode2b('kor', true); // 한국어 echo $iso->nativeByCode2b('jpn', true); // 日本語 (にほんご) echo $iso->nativeByCode2b('chi', true); // '中文 (Zhōngwén), 汉语, 漢語 echo $iso->nativeByCode2b('rus', true); // Русский echo $iso->nativeByCode2b('ara', true); // االعربية echo $iso->nativeByCode2b('vie', true); // Việt Nam // Get language name from ISO-639-3 code echo $iso->languageByCode3('eng'); // English echo $iso->languageByCode3('ind'); // Indonesian echo $iso->languageByCode3('jav'); // Javanese // Get native language name from ISO-639-3 code echo $iso->nativeByCode3('eng'); // English echo $iso->nativeByCode3('ind'); // Bahasa Indonesia echo $iso->nativeByCode3('jav'); // basa Jawa // Get native language name from ISO-639-3 code with capitalized echo $iso->nativeByCode3('eng', true); // English echo $iso->nativeByCode3('ind', true); // Bahasa Indonesia echo $iso->nativeByCode3('jav', true); // Basa Jawa echo $iso->nativeByCode3('hin', true); // हिन्दी, हिंदी echo $iso->nativeByCode3('tha', true); // ไทย echo $iso->nativeByCode3('kor', true); // 한국어 echo $iso->nativeByCode3('jpn', true); // 日本語 (にほんご) echo $iso->nativeByCode3('zho', true); // '中文 (Zhōngwén), 汉语, 漢語 echo $iso->nativeByCode3('rus', true); // Русский echo $iso->nativeByCode3('ara', true); // االعربية echo $iso->nativeByCode3('vie', true); // Việt Nam // Get language array from ISO-639-2b code echo $iso->getLanguageByIsoCode2b('eng'); // ['en', 'eng', 'eng', 'eng', 'English', 'English'] echo $iso->getLanguageByIsoCode2b('ind'); // ['id', 'ind', 'ind', 'ind', 'Indonesian', 'Bahasa Indonesia'] echo $iso->getLanguageByIsoCode2b('jav'); // ['jv', 'jav', 'jav', 'jav', 'Javanese', 'basa Jawa']
Contributing
Do as usual contribution on open source projects by creating a pull request!
Install Composer
composer install
Run Test
composer run-script test
Run Linter Fix
composer run-script lint:fix
matriphe/iso-639 适用场景与选型建议
matriphe/iso-639 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.56M 次下载、GitHub Stars 达 50, 最近一次更新时间为 2015 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「language」 「laravel」 「iso」 「lang」 「iso-639」 「639」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 matriphe/iso-639 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 matriphe/iso-639 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 matriphe/iso-639 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Easy to use i18n translation PHP class for multi-language websites
Package for convenient work with Laravel's localization features
Store your language lines in the database, yaml or other sources
Set Links with a specific language parameter
A PHP library providing ISO 639-1 data.
统计信息
- 总下载量: 3.56M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 50
- 点击次数: 30
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-25