matriphe / iso-639
PHP library to convert ISO-639-1 code to language name.
Installs: 2 193 154
Dependents: 6
Suggesters: 0
Security: 0
Stars: 50
Watchers: 3
Forks: 19
Open Issues: 1
Requires
- php: 8.*
Requires (Dev)
- phpunit/phpunit: >=10
This package is auto-updated.
Last update: 2024-11-18 00:14:27 UTC
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
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 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 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 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 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']
To Do
- Convert language name to ISO-639 code