mibo / languages
PHP Library for ISO 639-2, ISO 639-1 language codes
Installs: 4 271
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
Requires (Dev)
- jetbrains/phpstorm-attributes: ^1.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.5
- phpstan/phpstan-strict-rules: ^1.5
- phpunit/php-invoker: ^4.0
- phpunit/phpunit: ^10.1
- slevomat/coding-standard: ^8.13
README
mibo/languages
The library provides a simple interface for a language entity and language provider, which retrieves
a language by its ISO 639 alpha-2 code, alpha-3 code, alpha-3/B code.
If the provider does not find the language, it throws an exception.
The Language entity contains its name, ISO 639-1 alpha-2 code, 639-2 alpha-3 code (639-2/T), 639-2/B code, and the language's name.
The list of the available languages can be changed by the provider, because the library (ISO) provider allows the dev to insert his/her own array of languages.
$provider = new \MiBo\Languages\ISO\LanguageProvider($myLanguageList ?? []); $lang = $provider->getByAlpha2('sk'); echo $lang->getName(); // Slovak echo $lang->getAlpha2(); // sk echo $lang->getAlpha3(); // slk echo $lang->getAlpha3T(); // slk echo $lang->getAlpha3B(); // slo