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,
- The script in which a language is written
- The script code
- The language code
- The regions in which the language is spoken
- The autonym - language name written in its own script
- 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¶
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¶
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.
Contribute¶
- Issue Tracker: https://github.com/wikimedia/language-data/issues
- Source Code: https://github.com/wikimedia/language-data