2017 © Pedro Peláez
 

library langcode-conv

Convert language codes to any available format

image

leodido/langcode-conv

Convert language codes to any available format

  • Thursday, April 28, 2016
  • by leodido
  • Repository
  • 2 Watchers
  • 4 Stars
  • 8,000 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 4 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

Language Codes Converter

Latest Stable Version Build Status Coverage, (*1)

This library, based on conversio library, is aimed to convert every existing language code to any format you want. No matter which format the input language code is., (*2)

Details

The available output formats are:, (*3)

  1. name, (*4)

    The international (often english) name of the language, (*5)

  2. native, (*6)

    The language name written in native representation/s, (*7)

  3. iso639-1, (*8)

    The ISO 639-1 (two-letters code) language representation, (*9)

  4. iso639-2/t, (*10)

    The ISO 639-2/T (three-letters code for terminology applications) language representation, (*11)

  5. iso639-2/b, (*12)

    The ISO 639-2/B (three-letters code, for bibliographic applications) language representation, (*13)

  6. iso639-3, (*14)

    The ISO 639-3 (same as ISO 639-2/T except that for the macrolanguages) language representation, (*15)

Currently 184 languages are fully supported., (*16)

Examples

First of all you need to create the conversion adapter and its options class., (*17)

use Conversio\Conversion;
use Conversio\Adapter\LanguageCode;
use Conversio\Adapter\Options\LanguageCode;
// ...
$adapter = new LanguageCode();
$options = new LanguageCodeOptions();

Then, you can pass it to the Conversion class constructor (from conversio library):, (*18)

$converter = new Conversion($adapter);
$converter->setAdapterOptions($options);

Or, compactly:, (*19)

$converter = new Conversion(['adapter' => $adapter, 'options' => $options]);

Finally we need to specify the desired output format (see above the supported formats) of the conversion and perform it., (*20)

$options->setOutput('native');
// ISO 639-1 => NATIVE
$converter->filter('it'); // italiano

Which ouputs, in this case italiano., (*21)

Have fun, try other language codes (e.g., vie, tam)., (*22)

// ISO 639-2/T => NATIVE
$converter->filter('vie'); // tiếng việt
$converter->filter('tam'); // தமிழ்
// ISO 639-3 => NATIVE
$converter->filter('yid + 2'); // ייִדיש
// ISO 639-3 => NAME
$options->setOutput('name');
$converter->filter('vie'); // vietnamese
$converter->filter('tam'); // tamil
$converter->filter('yid + 2'); // yiddish

Installation

Add leodido/langcode-conv to your composer.json., (*23)

{
   "require": {
       "leodido/langcode-conv": "v0.3.0"
   }
}

References


Analytics, (*24)

The Versions

28/04 2016

dev-develop

dev-develop

Convert language codes to any available format

  Sources   Download

ISC

The Requires

 

The Development Requires

language library converter languages conversion convert native name codes language code iso639-1 iso639-2t iso639-2b iso639-3

09/01 2015

dev-master

9999999-dev

Convert language codes to any available format

  Sources   Download

ISC

The Requires

 

The Development Requires

library converter conversion convert native name iso639-1 iso639-2t iso639-2b iso639-3

09/01 2015

v0.2.0

0.2.0.0

Convert language codes to any available format

  Sources   Download

ISC

The Requires

 

The Development Requires

library converter conversion convert native name iso639-1 iso639-2t iso639-2b iso639-3