Language data and utilities

This library contains language related data, and utility libraries written in PHP and Node.js to interact with that data.

The language related data comprises of the following,

  1. The script in which a language is written
  2. The script code
  3. The language code
  4. The regions in which the language is spoken
  5. The autonym - language name written in its own script
  6. The directionality of the text

This data is populated from the current version of CLDR supplemental data and various other sources.

Using the PHP library

php-build

Installation

You can add this library to your project by running:

composer install wikimedia/language-data

Basic usage

The basic usage is like this:

<?php
use Wikimedia\LanguageData\LanguageUtil;

$languageUtil = LanguageUtil::get();
// Returns English
$languageUtil->getAutonym( 'en' );

For a full list of methods see the documentation for the LanguageUtil class.

Using the Node.js library

npm npm-build

Installation

You can add this library to your project by running,

npm i @wikimedia/language-data

Basic usage

The basic usage is like this:

const languageData = require('@wikimedia/language-data');

// Returns English
languageData.getAutonym( 'en');

The exposed methods are similar to the methods present in the PHP LanguageUtil class.

Changelog

The full changelog is available here.

Indices and tables