gmo/iso-639

Convert between ISO-639 codes

v1.0.0 2015-07-17 00:18 UTC

This package is not auto-updated.

Last update: 2024-11-19 04:37:53 UTC


README

Install with composer:

composer require "gmo/iso-639:^1.0"

Usage

Initialize the Languages class, then find a Language by one of its properties.

use Gmo\Iso639\Languages;

$languages = new Languages();

$english = $languages->findByName('English');

echo $english->code1();  // en
echo $english->code2t(); // eng
echo $english->code2b(); // eng
echo $english->code3();  // eng
echo $english->name();   // English

Converting ISO 639-3 codes to ISO 639-1 codes:

$languages->findByCode3('eng')->code1(); // en

Or reverse:

$languages->findByCode1('en')->code3(); // eng

Languages can be iterated:

foreach ($languages as $language) {
    echo $language->name();
}

Or a list can be retrieved:

$languages->getLanguages();