Merge pull request #1027 from MrPetovan/task/9328-add-range-percent-template

[langfilter] Add slider to addon settings
This commit is contained in:
Michael Vogel 2020-10-04 06:27:58 +02:00 committed by GitHub
commit 14c09c1bbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 1860 additions and 22 deletions

23
langfilter/composer.json Normal file
View file

@ -0,0 +1,23 @@
{
"name": "friendica-addons/langfilter",
"description": "A language filter to collapse posts matching user-selected languages",
"type": "friendica-addon",
"require": {
"matriphe/iso-639": "^1.2"
},
"license": "AGPL-3",
"authors": [
{
"name": "Tobias Diekershoff",
"homepage": "https://f.diekershoff.de/u/tobias",
"role": "Developer"
},
{
"name": "Hypolite Petovan",
"email": "hypolite@mrpetovan.com",
"homepage": "https://friendica.mrpetovan.com/profile/hypolite",
"role": "Maintainer"
}
],
"minimum-stability": "stable"
}

63
langfilter/composer.lock generated Normal file
View file

@ -0,0 +1,63 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "7524bbd9381490bdfd604a84385da630",
"packages": [
{
"name": "matriphe/iso-639",
"version": "1.2",
"source": {
"type": "git",
"url": "https://github.com/matriphe/php-iso-639.git",
"reference": "0245d844daeefdd22a54b47103ffdb0e03c323e1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/matriphe/php-iso-639/zipball/0245d844daeefdd22a54b47103ffdb0e03c323e1",
"reference": "0245d844daeefdd22a54b47103ffdb0e03c323e1",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "^4.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Matriphe\\ISO639\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Muhammad Zamroni",
"email": "halo@matriphe.com"
}
],
"description": "PHP library to convert ISO-639-1 code to language name.",
"keywords": [
"639",
"iso",
"iso-639",
"lang",
"language",
"laravel"
],
"time": "2017-07-19T15:11:19+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "1.1.0"
}

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-01 11:11-0400\n"
"POT-Creation-Date: 2020-10-03 22:02-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,62 +17,58 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: langfilter.php:58
#: langfilter.php:52
msgid "Language Filter"
msgstr ""
#: langfilter.php:59
#: langfilter.php:53
msgid ""
"This addon tries to identify the language posts are writen in. If it does "
"not match any language specifed below, posts will be hidden by collapsing "
"them."
msgstr ""
#: langfilter.php:60
#: langfilter.php:54
msgid "Use the language filter"
msgstr ""
#: langfilter.php:61
#: langfilter.php:55
msgid "Able to read"
msgstr ""
#: langfilter.php:61
#: langfilter.php:55
msgid ""
"List of abbreviations (iso2 codes) for languages you speak, comma separated. "
"For example \"de,it\"."
"List of abbreviations (ISO 639-1 codes) for languages you speak, comma "
"separated. For example \"de,it\"."
msgstr ""
#: langfilter.php:62
#: langfilter.php:56
msgid "Minimum confidence in language detection"
msgstr ""
#: langfilter.php:62
#: langfilter.php:56
msgid ""
"Minimum confidence in language detection being correct, from 0 to 100. Posts "
"will not be filtered when the confidence of language detection is below this "
"percent value."
msgstr ""
#: langfilter.php:63
#: langfilter.php:57
msgid "Minimum length of message body"
msgstr ""
#: langfilter.php:63
#: langfilter.php:57
msgid ""
"Minimum number of characters in message body for filter to be used. Posts "
"shorter than this will not be filtered. Note: Language detection is "
"unreliable for short content (<200 characters)."
msgstr ""
#: langfilter.php:64
#: langfilter.php:58
msgid "Save Settings"
msgstr ""
#: langfilter.php:105
msgid "Language Filter Settings saved."
msgstr ""
#: langfilter.php:182
#: langfilter.php:189
#, php-format
msgid "Filtered language: %s"
msgstr ""

View file

@ -13,6 +13,8 @@ use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
require __DIR__ . '/vendor/autoload.php';
/* Define the hooks we want to use
* that is, we have settings, we need to save the settings and we want
* to modify the content of a posting when friendica prepares it.
@ -50,7 +52,7 @@ function langfilter_addon_settings(App $a, &$s)
'$title' => DI::l10n()->t("Language Filter"),
'$intro' => DI::l10n()->t('This addon tries to identify the language posts are writen in. If it does not match any language specifed below, posts will be hidden by collapsing them.'),
'$enabled' => ['langfilter_enable', DI::l10n()->t('Use the language filter'), $enable_checked, ''],
'$languages' => ['langfilter_languages', DI::l10n()->t('Able to read'), $languages, DI::l10n()->t('List of abbreviations (iso2 codes) for languages you speak, comma separated. For example "de,it".')],
'$languages' => ['langfilter_languages', DI::l10n()->t('Able to read'), $languages, DI::l10n()->t('List of abbreviations (ISO 639-1 codes) for languages you speak, comma separated. For example "de,it".')],
'$minconfidence' => ['langfilter_minconfidence', DI::l10n()->t('Minimum confidence in language detection'), $minconfidence, DI::l10n()->t('Minimum confidence in language detection being correct, from 0 to 100. Posts will not be filtered when the confidence of language detection is below this percent value.')],
'$minlength' => ['langfilter_minlength', DI::l10n()->t('Minimum length of message body'), $minlength, DI::l10n()->t('Minimum number of characters in message body for filter to be used. Posts shorter than this will not be filtered. Note: Language detection is unreliable for short content (<200 characters).')],
'$submit' => DI::l10n()->t('Save Settings'),
@ -138,6 +140,8 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data)
}
$read_languages_array = explode(',', $read_languages_string);
$iso639 = new Matriphe\ISO639\ISO639;
// Extract the language of the post
if (!empty($hook_data['item']['language'])) {
$languages = json_decode($hook_data['item']['language'], true);
@ -153,7 +157,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data)
return;
}
$lang = Text_LanguageDetect_ISO639::code2ToName($iso2);
$lang = $iso639->languageByCode1($iso2);
} else {
$opts = $hook_data['item']['postopts'];
if (!$opts) {
@ -169,7 +173,7 @@ function langfilter_prepare_body_content_filter(App $a, &$hook_data)
$lang = $matches[1];
$confidence = $matches[2];
$iso2 = Text_LanguageDetect_ISO639::nameToCode2($lang);
$iso2 = $iso639->code1ByLanguage($lang);
}
// Do not filter if language detection confidence is too low

View file

@ -10,7 +10,7 @@
<p>{{$intro}}</p>
{{include file="field_checkbox.tpl" field=$enabled}}
{{include file="field_input.tpl" field=$languages}}
{{include file="field_input.tpl" field=$minconfidence}}
{{include file="field/range_percent.tpl" field=$minconfidence}}
{{include file="field_input.tpl" field=$minlength}}
</div>
<div class="settings-submit-wrapper" >

7
langfilter/vendor/autoload.php vendored Normal file
View file

@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit6449f021327d95a4e323188b673aed62::getLoader();

View file

@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

21
langfilter/vendor/composer/LICENSE vendored Normal file
View file

@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -0,0 +1,9 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View file

@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View file

@ -0,0 +1,10 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Matriphe\\ISO639\\' => array($vendorDir . '/matriphe/iso-639/src'),
);

View file

@ -0,0 +1,55 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit6449f021327d95a4e323188b673aed62
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit6449f021327d95a4e323188b673aed62', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit6449f021327d95a4e323188b673aed62', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit6449f021327d95a4e323188b673aed62::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}

View file

@ -0,0 +1,31 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit6449f021327d95a4e323188b673aed62
{
public static $prefixLengthsPsr4 = array (
'M' =>
array (
'Matriphe\\ISO639\\' => 16,
),
);
public static $prefixDirsPsr4 = array (
'Matriphe\\ISO639\\' =>
array (
0 => __DIR__ . '/..' . '/matriphe/iso-639/src',
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit6449f021327d95a4e323188b673aed62::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit6449f021327d95a4e323188b673aed62::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
}

View file

@ -0,0 +1,48 @@
[
{
"name": "matriphe/iso-639",
"version": "1.2",
"version_normalized": "1.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/matriphe/php-iso-639.git",
"reference": "0245d844daeefdd22a54b47103ffdb0e03c323e1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/matriphe/php-iso-639/zipball/0245d844daeefdd22a54b47103ffdb0e03c323e1",
"reference": "0245d844daeefdd22a54b47103ffdb0e03c323e1",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "^4.7"
},
"time": "2017-07-19T15:11:19+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Matriphe\\ISO639\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Muhammad Zamroni",
"email": "halo@matriphe.com"
}
],
"description": "PHP library to convert ISO-639-1 code to language name.",
"keywords": [
"639",
"iso",
"iso-639",
"lang",
"language",
"laravel"
]
}
]

View file

@ -0,0 +1,2 @@
/vendor
composer.lock

View file

@ -0,0 +1,122 @@
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'long'],
'no_extra_consecutive_blank_lines' => [
'break', 'continue', 'extra', 'return', 'throw', 'use',
'parenthesis_brace_block', 'square_brace_block',
'curly_brace_block'
],
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'braces' => true,
'blank_line_before_return' => true,
'cast_spaces' => true,
'class_definition' => true,
'class_keyword_remove' => false,
'concat_space' => true,
'combine_consecutive_unsets' => true,
'declare_equal_normalize' => false,
'elseif' => true,
'encoding' => true,
'ereg_to_preg' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'indentation_type' => true,
'line_ending' => true,
'linebreak_after_opening_tag' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
//'mb_str_functions' => false,
'method_argument_space' => true,
'method_separation' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_braces' => true,
//'no_alias_functions' => false,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => false,
'no_blank_lines_before_namespace' => false,
'no_closing_tag' => true,
'no_empty_comment' => false,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_php4_constructor' => true,
'no_short_bool_cast' => true,
'no_short_echo_tag' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => false,
/*
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_align' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_scalar' => true,
*/
'protected_to_private' => true,
'psr4' => true,
'random_api_migration' => true,
'return_type_declaration' => false,
'self_accessor' => true,
//'semicolon_after_instruction' => true,
'short_scalar_cast' => true,
//'simplified_null_return' => false,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'strict_comparison' => false,
'strict_param' => false,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('storage')
->in(__DIR__)
)
;

View file

@ -0,0 +1,13 @@
language: php
install: composer install
script: vendor/bin/phpunit
php:
- "7.1"
- "7.0"
- "5.6"
- "5.5"
- "5.4"
- "5.3"

View file

@ -0,0 +1,65 @@
# PHP ISO-639
[![Build Status](https://travis-ci.org/matriphe/php-iso-639.svg)](https://travis-ci.org/matriphe/php-iso-639)
PHP library to convert ISO-639-1 code to language name, based on Wikipedia's [List of ISO 639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
## Installation
Using composer: `composer require matriphe/iso-639`
## Usage Example
```php
<?php
required 'src/ISO639.php';
//required 'vendor/autoload.php'; // If using composer
$iso = new Matriphe\ISO639\ISO639;
// Get language name from ISO-639-1 code
echo $iso->languageByCode1('en'); // English
echo $iso->languageByCode1('id'); // Indonesian
echo $iso->languageByCode1('jv'); // Javanese
// Get native language name from ISO-639-1 code
echo $iso->nativeByCode1('en'); // English
echo $iso->nativeByCode1('id'); // Bahasa Indonesia
echo $iso->nativeByCode1('jv'); // basa Jawa
// Get language name from ISO-639-2t code
echo $iso->languageByCode2t('eng'); // English
echo $iso->languageByCode2t('ind'); // Indonesian
echo $iso->languageByCode2t('jav'); // Javanese
// Get native language name from ISO-639-2t code
echo $iso->nativeByCode2t('eng'); // English
echo $iso->nativeByCode2t('ind'); // Bahasa Indonesia
echo $iso->nativeByCode2t('jav'); // basa Jawa
// Get language name from ISO-639-2b code
echo $iso->languageByCode2b('eng'); // English
echo $iso->languageByCode2b('ind'); // Indonesian
echo $iso->languageByCode2b('jav'); // Javanese
// Get native language name from ISO-639-2b code
echo $iso->nativeByCode2b('eng'); // English
echo $iso->nativeByCode2b('ind'); // Bahasa Indonesia
echo $iso->nativeByCode2b('jav'); // basa Jawa
// Get language name from ISO-639-3 code
echo $iso->languageByCode3('eng'); // English
echo $iso->languageByCode3('ind'); // Indonesian
echo $iso->languageByCode3('jav'); // Javanese
// Get native language name from ISO-639-3 code
echo $iso->nativeByCode3('eng'); // English
echo $iso->nativeByCode3('ind'); // Bahasa Indonesia
echo $iso->nativeByCode3('jav'); // basa Jawa
```
## To Do
* Convert language name to ISO-639 code

View file

@ -0,0 +1,22 @@
{
"name": "matriphe/iso-639",
"description": "PHP library to convert ISO-639-1 code to language name.",
"keywords": ["iso", "iso-639", "639", "lang", "language", "laravel"],
"type": "library",
"require-dev": {
"phpunit/phpunit": "^4.7"
},
"license": "MIT",
"authors": [
{
"name": "Muhammad Zamroni",
"email": "halo@matriphe.com"
}
],
"require": {},
"autoload": {
"psr-4": {
"Matriphe\\ISO639\\": "src/"
}
}
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="src/ISO639.php">
<testsuites>
<testsuite name="ISO-639 Test Unit">
<directory>tests/ISO639Test.php</directory>
</testsuite>
</testsuites>
</phpunit>

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,185 @@
Northwest Caucasian|Abkhaz|аҧсуа бызшәа, аҧсшәа|ab|abk|abk|abk|abks|
Afro-Asiatic|Afar|Afaraf|aa|aar|aar|aar|aars|
Indo-European|Afrikaans|Afrikaans|af|afr|afr|afr|afrs|
NigerCongo|Akan|Akan|ak|aka|aka|aka + 2||macrolanguage, Twi is [tw/twi], Fanti is [fat]
Indo-European|Albanian|Shqip|sq|sqi|alb|sqi + 4||macrolanguage, "Albanian Phylozone" in 639-6
Afro-Asiatic|Amharic|አማርኛ|am|amh|amh|amh||
Afro-Asiatic|Arabic|العربية|ar|ara|ara|ara + 30||macrolanguage, Standard Arabic is [arb]
Indo-European|Aragonese|aragonés|an|arg|arg|arg||
Indo-European|Armenian|Հայերեն|hy|hye|arm|hye||
Indo-European|Assamese|অসমীয়া|as|asm|asm|asm||
Northeast Caucasian|Avaric|авар мацӀ, магӀарул мацӀ|av|ava|ava|ava||
Indo-European|Avestan|avesta|ae|ave|ave|ave||ancient
Aymaran|Aymara|aymar aru|ay|aym|aym|aym + 2||macrolanguage
Turkic|Azerbaijani|azərbaycan dili|az|aze|aze|aze + 2||macrolanguage
NigerCongo|Bambara|bamanankan|bm|bam|bam|bam||
Turkic|Bashkir|башҡорт теле|ba|bak|bak|bak||
Language isolate|Basque|euskara, euskera|eu|eus|baq|eus||
Indo-European|Belarusian|беларуская мова|be|bel|bel|bel||
Indo-European|Bengali, Bangla|বাংলা|bn|ben|ben|ben||
Indo-European|Bihari|भोजपुरी|bh|bih|bih|||Collective language code for Bhojpuri, Magahi, and Maithili
Creole|Bislama|Bislama|bi|bis|bis|bis||
Indo-European|Bosnian|bosanski jezik|bs|bos|bos|bos|boss|
Indo-European|Breton|brezhoneg|br|bre|bre|bre||
Indo-European|Bulgarian|български език|bg|bul|bul|bul|buls|
Sino-Tibetan|Burmese|ဗမာစာ|my|mya|bur|mya||
Indo-European|Catalan|català|ca|cat|cat|cat||
Austronesian|Chamorro|Chamoru|ch|cha|cha|cha||
Northeast Caucasian|Chechen|нохчийн мотт|ce|che|che|che||
NigerCongo|Chichewa, Chewa, Nyanja|chiCheŵa, chinyanja|ny|nya|nya|nya||
Sino-Tibetan|Chinese|中文 (Zhōngwén), 汉语, 漢語|zh|zho|chi|zho + 13||macrolanguage
Turkic|Chuvash|чӑваш чӗлхи|cv|chv|chv|chv||
Indo-European|Cornish|Kernewek|kw|cor|cor|cor||
Indo-European|Corsican|corsu, lingua corsa|co|cos|cos|cos||
Algonquian|Cree|ᓀᐦᐃᔭᐍᐏᐣ|cr|cre|cre|cre + 6||macrolanguage
Indo-European|Croatian|hrvatski jezik|hr|hrv|hrv|hrv||
Indo-European|Czech|čeština, český jazyk|cs|ces|cze|ces||
Indo-European|Danish|dansk|da|dan|dan|dan||
Indo-European|Divehi, Dhivehi, Maldivian|ދިވެހި|dv|div|div|div||
Indo-European|Dutch|Nederlands, Vlaams|nl|nld|dut|nld||
Sino-Tibetan|Dzongkha|རྫོང་ཁ|dz|dzo|dzo|dzo||
Indo-European|English|English|en|eng|eng|eng|engs|
Constructed|Esperanto|Esperanto|eo|epo|epo|epo||constructed, initiated from L.L. Zamenhof, 1887
Uralic|Estonian|eesti, eesti keel|et|est|est|est + 2||macrolanguage
NigerCongo|Ewe|Eʋegbe|ee|ewe|ewe|ewe||
Indo-European|Faroese|føroyskt|fo|fao|fao|fao||
Austronesian|Fijian|vosa Vakaviti|fj|fij|fij|fij||
Uralic|Finnish|suomi, suomen kieli|fi|fin|fin|fin||
Indo-European|French|français, langue française|fr|fra|fre|fra|fras|
NigerCongo|Fula, Fulah, Pulaar, Pular|Fulfulde, Pulaar, Pular|ff|ful|ful|ful + 9||macrolanguage
Indo-European|Galician|galego|gl|glg|glg|glg||
South Caucasian|Georgian|ქართული|ka|kat|geo|kat||
Indo-European|German|Deutsch|de|deu|ger|deu|deus|
Indo-European|Greek (modern)|ελληνικά|el|ell|gre|ell|ells|
Tupian|Guaraní|Avañe'ẽ|gn|grn|grn|grn + 5||macrolanguage
Indo-European|Gujarati|ગુજરાતી|gu|guj|guj|guj||
Creole|Haitian, Haitian Creole|Kreyòl ayisyen|ht|hat|hat|hat||
Afro-Asiatic|Hausa|(Hausa) هَوُسَ|ha|hau|hau|hau||
Afro-Asiatic|Hebrew (modern)|עברית|he|heb|heb|heb||
NigerCongo|Herero|Otjiherero|hz|her|her|her||
Indo-European|Hindi|हिन्दी, हिंदी|hi|hin|hin|hin|hins|
Austronesian|Hiri Motu|Hiri Motu|ho|hmo|hmo|hmo||
Uralic|Hungarian|magyar|hu|hun|hun|hun||
Constructed|Interlingua|Interlingua|ia|ina|ina|ina||constructed by International Auxiliary Language Association
Austronesian|Indonesian|Bahasa Indonesia|id|ind|ind|ind||Covered by macrolanguage [ms/msa]
Constructed|Interlingue|Originally called Occidental; then Interlingue after WWII|ie|ile|ile|ile||constructed by Edgar de Wahl, first published in 1922
Indo-European|Irish|Gaeilge|ga|gle|gle|gle||
NigerCongo|Igbo|Asụsụ Igbo|ig|ibo|ibo|ibo||
EskimoAleut|Inupiaq|Iñupiaq, Iñupiatun|ik|ipk|ipk|ipk + 2||macrolanguage
Constructed|Ido|Ido|io|ido|ido|ido|idos|constructed by De Beaufront, 1907, as variation of Esperanto
Indo-European|Icelandic|Íslenska|is|isl|ice|isl||
Indo-European|Italian|italiano|it|ita|ita|ita|itas|
EskimoAleut|Inuktitut|ᐃᓄᒃᑎᑐᑦ|iu|iku|iku|iku + 2||macrolanguage
Japonic|Japanese|日本語 (にほんご)|ja|jpn|jpn|jpn||
Austronesian|Javanese|basa Jawa|jv|jav|jav|jav||
EskimoAleut|Kalaallisut, Greenlandic|kalaallisut, kalaallit oqaasii|kl|kal|kal|kal||
Dravidian|Kannada|ಕನ್ನಡ|kn|kan|kan|kan||
Nilo-Saharan|Kanuri|Kanuri|kr|kau|kau|kau + 3||macrolanguage
Indo-European|Kashmiri|कश्मीरी, كشميري‎|ks|kas|kas|kas||
Turkic|Kazakh|қазақ тілі|kk|kaz|kaz|kaz||
Austroasiatic|Khmer|ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ|km|khm|khm|khm||a.k.a. Cambodian
NigerCongo|Kikuyu, Gikuyu|Gĩkũyũ|ki|kik|kik|kik||
NigerCongo|Kinyarwanda|Ikinyarwanda|rw|kin|kin|kin||
Turkic|Kyrgyz|Кыргызча, Кыргыз тили|ky|kir|kir|kir||
Uralic|Komi|коми кыв|kv|kom|kom|kom + 2||macrolanguage
NigerCongo|Kongo|Kikongo|kg|kon|kon|kon + 3||macrolanguage
Koreanic|Korean|한국어, 조선어|ko|kor|kor|kor||
Indo-European|Kurdish|Kurdî, كوردی‎|ku|kur|kur|kur + 3||macrolanguage
NigerCongo|Kwanyama, Kuanyama|Kuanyama|kj|kua|kua|kua||
Indo-European|Latin|latine, lingua latina|la|lat|lat|lat|lats|ancient
Indo-European|Ladin|ladin, lingua ladina||||lld||
Indo-European|Luxembourgish, Letzeburgesch|Lëtzebuergesch|lb|ltz|ltz|ltz||
NigerCongo|Ganda|Luganda|lg|lug|lug|lug||
Indo-European|Limburgish, Limburgan, Limburger|Limburgs|li|lim|lim|lim||
NigerCongo|Lingala|Lingála|ln|lin|lin|lin||
TaiKadai|Lao|ພາສາລາວ|lo|lao|lao|lao||
Indo-European|Lithuanian|lietuvių kalba|lt|lit|lit|lit||
NigerCongo|Luba-Katanga|Tshiluba|lu|lub|lub|lub||
Indo-European|Latvian|latviešu valoda|lv|lav|lav|lav + 2||macrolanguage
Indo-European|Manx|Gaelg, Gailck|gv|glv|glv|glv||
Indo-European|Macedonian|македонски јазик|mk|mkd|mac|mkd||
Austronesian|Malagasy|fiteny malagasy|mg|mlg|mlg|mlg + 10||macrolanguage
Austronesian|Malay|bahasa Melayu, بهاس ملايو‎|ms|msa|may|msa + 13||macrolanguage, Standard Malay is [zsm], Indonesian is [id/ind]
Dravidian|Malayalam|മലയാളം|ml|mal|mal|mal||
Afro-Asiatic|Maltese|Malti|mt|mlt|mlt|mlt||
Austronesian|Māori|te reo Māori|mi|mri|mao|mri||
Indo-European|Marathi (Marāṭhī)|मराठी|mr|mar|mar|mar||
Austronesian|Marshallese|Kajin M̧ajeļ|mh|mah|mah|mah||
Mongolic|Mongolian|монгол|mn|mon|mon|mon + 2||macrolanguage
Austronesian|Nauru|Ekakairũ Naoero|na|nau|nau|nau||
DenéYeniseian|Navajo, Navaho|Diné bizaad|nv|nav|nav|nav||
NigerCongo|Northern Ndebele|isiNdebele|nd|nde|nde|nde||
Indo-European|Nepali|नेपाली|ne|nep|nep|nep||
NigerCongo|Ndonga|Owambo|ng|ndo|ndo|ndo||
Indo-European|Norwegian Bokmål|Norsk bokmål|nb|nob|nob|nob||Covered by macrolanguage [no/nor]
Indo-European|Norwegian Nynorsk|Norsk nynorsk|nn|nno|nno|nno||Covered by macrolanguage [no/nor]
Indo-European|Norwegian|Norsk|no|nor|nor|nor + 2||macrolanguage, Bokmål is [nb/nob], Nynorsk is [nn/nno]
Sino-Tibetan|Nuosu|ꆈꌠ꒿ Nuosuhxop|ii|iii|iii|iii||Standard form of Yi languages
NigerCongo|Southern Ndebele|isiNdebele|nr|nbl|nbl|nbl||
Indo-European|Occitan|occitan, lenga d'òc|oc|oci|oci|oci||
Algonquian|Ojibwe, Ojibwa|ᐊᓂᔑᓈᐯᒧᐎᓐ|oj|oji|oji|oji + 7||macrolanguage
Indo-European|Old Church Slavonic, Church Slavonic, Old Bulgarian|ѩзыкъ словѣньскъ|cu|chu|chu|chu||ancient, in use by Orthodox Church
Afro-Asiatic|Oromo|Afaan Oromoo|om|orm|orm|orm + 4||macrolanguage
Indo-European|Oriya|ଓଡ଼ିଆ|or|ori|ori|ori||
Indo-European|Ossetian, Ossetic|ирон æвзаг|os|oss|oss|oss||
Indo-European|Panjabi, Punjabi|ਪੰਜਾਬੀ, پنجابی‎|pa|pan|pan|pan||
Indo-European|Pāli|पाऴि|pi|pli|pli|pli||ancient
Indo-European|Persian (Farsi)|فارسی|fa|fas|per|fas + 2||macrolanguage
Indo-European|Polish|język polski, polszczyzna|pl|pol|pol|pol|pols|
Indo-European|Pashto, Pushto|پښتو|ps|pus|pus|pus + 3||macrolanguage
Indo-European|Portuguese|português|pt|por|por|por||
Quechuan|Quechua|Runa Simi, Kichwa|qu|que|que|que + 44||macrolanguage
Indo-European|Romansh|rumantsch grischun|rm|roh|roh|roh||
NigerCongo|Kirundi|Ikirundi|rn|run|run|run||
Indo-European|Romanian|limba română|ro|ron|rum|ron||[mo] for Moldavian has been withdrawn, recommending [ro] also for Moldavian
Indo-European|Russian|Русский|ru|rus|rus|rus||
Indo-European|Sanskrit (Saṁskṛta)|संस्कृतम्|sa|san|san|san||ancient, still spoken
Indo-European|Sardinian|sardu|sc|srd|srd|srd + 4||macrolanguage
Indo-European|Sindhi|सिन्धी, سنڌي، سندھی‎|sd|snd|snd|snd||
Uralic|Northern Sami|Davvisámegiella|se|sme|sme|sme||
Austronesian|Samoan|gagana fa'a Samoa|sm|smo|smo|smo||
Creole|Sango|yângâ tî sängö|sg|sag|sag|sag||
Indo-European|Serbian|српски језик|sr|srp|srp|srp||The ISO 639-2/T code srp deprecated the ISO 639-2/B code scc[1]
Indo-European|Scottish Gaelic, Gaelic|Gàidhlig|gd|gla|gla|gla||
NigerCongo|Shona|chiShona|sn|sna|sna|sna||
Indo-European|Sinhala, Sinhalese|සිංහල|si|sin|sin|sin||
Indo-European|Slovak|slovenčina, slovenský jazyk|sk|slk|slo|slk||
Indo-European|Slovene|slovenski jezik, slovenščina|sl|slv|slv|slv||
Afro-Asiatic|Somali|Soomaaliga, af Soomaali|so|som|som|som||
NigerCongo|Southern Sotho|Sesotho|st|sot|sot|sot||
Indo-European|Spanish|español|es|spa|spa|spa||
Austronesian|Sundanese|Basa Sunda|su|sun|sun|sun||
NigerCongo|Swahili|Kiswahili|sw|swa|swa|swa + 2||macrolanguage
NigerCongo|Swati|SiSwati|ss|ssw|ssw|ssw||
Indo-European|Swedish|svenska|sv|swe|swe|swe||
Dravidian|Tamil|தமிழ்|ta|tam|tam|tam||
Dravidian|Telugu|తెలుగు|te|tel|tel|tel||
Indo-European|Tajik|тоҷикӣ, toçikī, تاجیکی‎|tg|tgk|tgk|tgk||
TaiKadai|Thai|ไทย|th|tha|tha|tha||
Afro-Asiatic|Tigrinya|ትግርኛ|ti|tir|tir|tir||
Sino-Tibetan|Tibetan Standard, Tibetan, Central|བོད་ཡིག|bo|bod|tib|bod||
Turkic|Turkmen|Türkmen, Түркмен|tk|tuk|tuk|tuk||
Austronesian|Tagalog|Wikang Tagalog, ᜏᜒᜃᜅ᜔ ᜆᜄᜎᜓᜄ᜔|tl|tgl|tgl|tgl||Note: Filipino (Pilipino) has the code [fil]
NigerCongo|Tswana|Setswana|tn|tsn|tsn|tsn||
Austronesian|Tonga (Tonga Islands)|faka Tonga|to|ton|ton|ton||
Turkic|Turkish|Türkçe|tr|tur|tur|tur||
NigerCongo|Tsonga|Xitsonga|ts|tso|tso|tso||
Turkic|Tatar|татар теле, tatar tele|tt|tat|tat|tat||
NigerCongo|Twi|Twi|tw|twi|twi|twi||Covered by macrolanguage [ak/aka]
Austronesian|Tahitian|Reo Tahiti|ty|tah|tah|tah||One of the Reo Mā`ohi (languages of French Polynesia)
Turkic|Uyghur|ئۇيغۇرچە‎, Uyghurche|ug|uig|uig|uig||
Indo-European|Ukrainian|українська мова|uk|ukr|ukr|ukr||
Indo-European|Urdu|اردو|ur|urd|urd|urd||
Turkic|Uzbek|Oʻzbek, Ўзбек, أۇزبېك‎|uz|uzb|uzb|uzb + 2||macrolanguage
NigerCongo|Venda|Tshivenḓa|ve|ven|ven|ven||
Austroasiatic|Vietnamese|Việt Nam|vi|vie|vie|vie||
Constructed|Volapük|Volapük|vo|vol|vol|vol||constructed
Indo-European|Walloon|walon|wa|wln|wln|wln||
Indo-European|Welsh|Cymraeg|cy|cym|wel|cym||
NigerCongo|Wolof|Wollof|wo|wol|wol|wol||
Indo-European|Western Frisian|Frysk|fy|fry|fry|fry||
NigerCongo|Xhosa|isiXhosa|xh|xho|xho|xho||
Indo-European|Yiddish|ייִדיש|yi|yid|yid|yid + 2||macrolanguage
NigerCongo|Yoruba|Yorùbá|yo|yor|yor|yor||
TaiKadai|Zhuang, Chuang|Saɯ cueŋƅ, Saw cuengh|za|zha|zha|zha + 16||macrolanguage
NigerCongo|Zulu|isiZulu|zu|zul|zul|zul||
Can't render this file because it has a wrong number of fields in line 2.

View file

@ -0,0 +1,460 @@
<?php
namespace Matriphe\ISO639;
class ISO639
{
/*
* Language database, based on Wikipedia.
* Source: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
*/
protected $languages = array(
array('ab', 'abk', 'abk', 'abk', 'Abkhaz', 'аҧсуа бызшәа, аҧсшәа'),
array('aa', 'aar', 'aar', 'aar', 'Afar', 'Afaraf'),
array('af', 'afr', 'afr', 'afr', 'Afrikaans', 'Afrikaans'),
array('ak', 'aka', 'aka', 'aka', 'Akan', 'Akan'),
array('sq', 'sqi', 'alb', 'sqi', 'Albanian', 'Shqip'),
array('am', 'amh', 'amh', 'amh', 'Amharic', 'አማርኛ'),
array('ar', 'ara', 'ara', 'ara', 'Arabic', 'العربية'),
array('an', 'arg', 'arg', 'arg', 'Aragonese', 'aragonés'),
array('hy', 'hye', 'arm', 'hye', 'Armenian', 'Հայերեն'),
array('as', 'asm', 'asm', 'asm', 'Assamese', 'অসমীয়া'),
array('av', 'ava', 'ava', 'ava', 'Avaric', 'авар мацӀ, магӀарул мацӀ'),
array('ae', 'ave', 'ave', 'ave', 'Avestan', 'avesta'),
array('ay', 'aym', 'aym', 'aym', 'Aymara', 'aymar aru'),
array('az', 'aze', 'aze', 'aze', 'Azerbaijani', 'azərbaycan dili'),
array('bm', 'bam', 'bam', 'bam', 'Bambara', 'bamanankan'),
array('ba', 'bak', 'bak', 'bak', 'Bashkir', 'башҡорт теле'),
array('eu', 'eus', 'baq', 'eus', 'Basque', 'euskara, euskera'),
array('be', 'bel', 'bel', 'bel', 'Belarusian', 'беларуская мова'),
array('bn', 'ben', 'ben', 'ben', 'Bengali, Bangla', 'বাংলা'),
array('bh', 'bih', 'bih', '', 'Bihari', 'भोजपुरी'),
array('bi', 'bis', 'bis', 'bis', 'Bislama', 'Bislama'),
array('bs', 'bos', 'bos', 'bos', 'Bosnian', 'bosanski jezik'),
array('br', 'bre', 'bre', 'bre', 'Breton', 'brezhoneg'),
array('bg', 'bul', 'bul', 'bul', 'Bulgarian', 'български език'),
array('my', 'mya', 'bur', 'mya', 'Burmese', 'ဗမာစာ'),
array('ca', 'cat', 'cat', 'cat', 'Catalan', 'català'),
array('ch', 'cha', 'cha', 'cha', 'Chamorro', 'Chamoru'),
array('ce', 'che', 'che', 'che', 'Chechen', 'нохчийн мотт'),
array('ny', 'nya', 'nya', 'nya', 'Chichewa, Chewa, Nyanja', 'chiCheŵa, chinyanja'),
array('zh', 'zho', 'chi', 'zho', 'Chinese', '中文 (Zhōngwén), 汉语, 漢語'),
array('cv', 'chv', 'chv', 'chv', 'Chuvash', 'чӑваш чӗлхи'),
array('kw', 'cor', 'cor', 'cor', 'Cornish', 'Kernewek'),
array('co', 'cos', 'cos', 'cos', 'Corsican', 'corsu, lingua corsa'),
array('cr', 'cre', 'cre', 'cre', 'Cree', 'ᓀᐦᐃᔭᐍᐏᐣ'),
array('hr', 'hrv', 'hrv', 'hrv', 'Croatian', 'hrvatski jezik'),
array('cs', 'ces', 'cze', 'ces', 'Czech', 'čeština, český jazyk'),
array('da', 'dan', 'dan', 'dan', 'Danish', 'dansk'),
array('dv', 'div', 'div', 'div', 'Divehi, Dhivehi, Maldivian', 'ދިވެހި'),
array('nl', 'nld', 'dut', 'nld', 'Dutch', 'Nederlands, Vlaams'),
array('dz', 'dzo', 'dzo', 'dzo', 'Dzongkha', 'རྫོང་ཁ'),
array('en', 'eng', 'eng', 'eng', 'English', 'English'),
array('eo', 'epo', 'epo', 'epo', 'Esperanto', 'Esperanto'),
array('et', 'est', 'est', 'est', 'Estonian', 'eesti, eesti keel'),
array('ee', 'ewe', 'ewe', 'ewe', 'Ewe', 'Eʋegbe'),
array('fo', 'fao', 'fao', 'fao', 'Faroese', 'føroyskt'),
array('fj', 'fij', 'fij', 'fij', 'Fijian', 'vosa Vakaviti'),
array('fi', 'fin', 'fin', 'fin', 'Finnish', 'suomi, suomen kieli'),
array('fr', 'fra', 'fre', 'fra', 'French', 'français, langue française'),
array('ff', 'ful', 'ful', 'ful', 'Fula, Fulah, Pulaar, Pular', 'Fulfulde, Pulaar, Pular'),
array('gl', 'glg', 'glg', 'glg', 'Galician', 'galego'),
array('ka', 'kat', 'geo', 'kat', 'Georgian', 'ქართული'),
array('de', 'deu', 'ger', 'deu', 'German', 'Deutsch'),
array('el', 'ell', 'gre', 'ell', 'Greek (modern)', 'ελληνικά'),
array('gn', 'grn', 'grn', 'grn', 'Guaraní', 'Avañe\'ẽ'),
array('gu', 'guj', 'guj', 'guj', 'Gujarati', 'ગુજરાતી'),
array('ht', 'hat', 'hat', 'hat', 'Haitian, Haitian Creole', 'Kreyòl ayisyen'),
array('ha', 'hau', 'hau', 'hau', 'Hausa', '(Hausa) هَوُسَ'),
array('he', 'heb', 'heb', 'heb', 'Hebrew (modern)', 'עברית'),
array('hz', 'her', 'her', 'her', 'Herero', 'Otjiherero'),
array('hi', 'hin', 'hin', 'hin', 'Hindi', 'हिन्दी, हिंदी'),
array('ho', 'hmo', 'hmo', 'hmo', 'Hiri Motu', 'Hiri Motu'),
array('hu', 'hun', 'hun', 'hun', 'Hungarian', 'magyar'),
array('ia', 'ina', 'ina', 'ina', 'Interlingua', 'Interlingua'),
array('id', 'ind', 'ind', 'ind', 'Indonesian', 'Bahasa Indonesia'),
array('ie', 'ile', 'ile', 'ile', 'Interlingue', 'Originally called Occidental; then Interlingue after WWII'),
array('ga', 'gle', 'gle', 'gle', 'Irish', 'Gaeilge'),
array('ig', 'ibo', 'ibo', 'ibo', 'Igbo', 'Asụsụ Igbo'),
array('ik', 'ipk', 'ipk', 'ipk', 'Inupiaq', 'Iñupiaq, Iñupiatun'),
array('io', 'ido', 'ido', 'ido', 'Ido', 'Ido'),
array('is', 'isl', 'ice', 'isl', 'Icelandic', 'Íslenska'),
array('it', 'ita', 'ita', 'ita', 'Italian', 'italiano'),
array('iu', 'iku', 'iku', 'iku', 'Inuktitut', 'ᐃᓄᒃᑎᑐᑦ'),
array('ja', 'jpn', 'jpn', 'jpn', 'Japanese', '日本語 (にほんご)'),
array('jv', 'jav', 'jav', 'jav', 'Javanese', 'basa Jawa'),
array('kl', 'kal', 'kal', 'kal', 'Kalaallisut, Greenlandic', 'kalaallisut, kalaallit oqaasii'),
array('kn', 'kan', 'kan', 'kan', 'Kannada', 'ಕನ್ನಡ'),
array('kr', 'kau', 'kau', 'kau', 'Kanuri', 'Kanuri'),
array('ks', 'kas', 'kas', 'kas', 'Kashmiri', 'कश्मीरी, كشميري‎'),
array('kk', 'kaz', 'kaz', 'kaz', 'Kazakh', 'қазақ тілі'),
array('km', 'khm', 'khm', 'khm', 'Khmer', 'ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ'),
array('ki', 'kik', 'kik', 'kik', 'Kikuyu, Gikuyu', 'Gĩkũyũ'),
array('rw', 'kin', 'kin', 'kin', 'Kinyarwanda', 'Ikinyarwanda'),
array('ky', 'kir', 'kir', 'kir', 'Kyrgyz', 'Кыргызча, Кыргыз тили'),
array('kv', 'kom', 'kom', 'kom', 'Komi', 'коми кыв'),
array('kg', 'kon', 'kon', 'kon', 'Kongo', 'Kikongo'),
array('ko', 'kor', 'kor', 'kor', 'Korean', '한국어, 조선어'),
array('ku', 'kur', 'kur', 'kur', 'Kurdish', 'Kurdî, كوردی‎'),
array('kj', 'kua', 'kua', 'kua', 'Kwanyama, Kuanyama', 'Kuanyama'),
array('la', 'lat', 'lat', 'lat', 'Latin', 'latine, lingua latina'),
array('', '', '', 'lld', 'Ladin', 'ladin, lingua ladina'),
array('lb', 'ltz', 'ltz', 'ltz', 'Luxembourgish, Letzeburgesch', 'Lëtzebuergesch'),
array('lg', 'lug', 'lug', 'lug', 'Ganda', 'Luganda'),
array('li', 'lim', 'lim', 'lim', 'Limburgish, Limburgan, Limburger', 'Limburgs'),
array('ln', 'lin', 'lin', 'lin', 'Lingala', 'Lingála'),
array('lo', 'lao', 'lao', 'lao', 'Lao', 'ພາສາລາວ'),
array('lt', 'lit', 'lit', 'lit', 'Lithuanian', 'lietuvių kalba'),
array('lu', 'lub', 'lub', 'lub', 'Luba-Katanga', 'Tshiluba'),
array('lv', 'lav', 'lav', 'lav', 'Latvian', 'latviešu valoda'),
array('gv', 'glv', 'glv', 'glv', 'Manx', 'Gaelg, Gailck'),
array('mk', 'mkd', 'mac', 'mkd', 'Macedonian', 'македонски јазик'),
array('mg', 'mlg', 'mlg', 'mlg', 'Malagasy', 'fiteny malagasy'),
array('ms', 'msa', 'may', 'msa', 'Malay', 'bahasa Melayu, بهاس ملايو‎'),
array('ml', 'mal', 'mal', 'mal', 'Malayalam', 'മലയാളം'),
array('mt', 'mlt', 'mlt', 'mlt', 'Maltese', 'Malti'),
array('mi', 'mri', 'mao', 'mri', 'Māori', 'te reo Māori'),
array('mr', 'mar', 'mar', 'mar', 'Marathi (Marāṭhī)', 'मराठी'),
array('mh', 'mah', 'mah', 'mah', 'Marshallese', 'Kajin M̧ajeļ'),
array('mn', 'mon', 'mon', 'mon', 'Mongolian', 'монгол'),
array('na', 'nau', 'nau', 'nau', 'Nauru', 'Ekakairũ Naoero'),
array('nv', 'nav', 'nav', 'nav', 'Navajo, Navaho', 'Diné bizaad'),
array('nd', 'nde', 'nde', 'nde', 'Northern Ndebele', 'isiNdebele'),
array('ne', 'nep', 'nep', 'nep', 'Nepali', 'नेपाली'),
array('ng', 'ndo', 'ndo', 'ndo', 'Ndonga', 'Owambo'),
array('nb', 'nob', 'nob', 'nob', 'Norwegian Bokmål', 'Norsk bokmål'),
array('nn', 'nno', 'nno', 'nno', 'Norwegian Nynorsk', 'Norsk nynorsk'),
array('no', 'nor', 'nor', 'nor', 'Norwegian', 'Norsk'),
array('ii', 'iii', 'iii', 'iii', 'Nuosu', 'ꆈꌠ꒿ Nuosuhxop'),
array('nr', 'nbl', 'nbl', 'nbl', 'Southern Ndebele', 'isiNdebele'),
array('oc', 'oci', 'oci', 'oci', 'Occitan', 'occitan, lenga d\'òc'),
array('oj', 'oji', 'oji', 'oji', 'Ojibwe, Ojibwa', 'ᐊᓂᔑᓈᐯᒧᐎᓐ'),
array('cu', 'chu', 'chu', 'chu', 'Old Church Slavonic, Church Slavonic, Old Bulgarian', 'ѩзыкъ словѣньскъ'),
array('om', 'orm', 'orm', 'orm', 'Oromo', 'Afaan Oromoo'),
array('or', 'ori', 'ori', 'ori', 'Oriya', 'ଓଡ଼ିଆ'),
array('os', 'oss', 'oss', 'oss', 'Ossetian, Ossetic', 'ирон æвзаг'),
array('pa', 'pan', 'pan', 'pan', 'Panjabi, Punjabi', 'ਪੰਜਾਬੀ, پنجابی‎'),
array('pi', 'pli', 'pli', 'pli', 'Pāli', 'पाऴि'),
array('fa', 'fas', 'per', 'fas', 'Persian (Farsi)', 'فارسی'),
array('pl', 'pol', 'pol', 'pol', 'Polish', 'język polski, polszczyzna'),
array('ps', 'pus', 'pus', 'pus', 'Pashto, Pushto', 'پښتو'),
array('pt', 'por', 'por', 'por', 'Portuguese', 'português'),
array('qu', 'que', 'que', 'que', 'Quechua', 'Runa Simi, Kichwa'),
array('rm', 'roh', 'roh', 'roh', 'Romansh', 'rumantsch grischun'),
array('rn', 'run', 'run', 'run', 'Kirundi', 'Ikirundi'),
array('ro', 'ron', 'rum', 'ron', 'Romanian', 'limba română'),
array('ru', 'rus', 'rus', 'rus', 'Russian', 'Русский'),
array('sa', 'san', 'san', 'san', 'Sanskrit (Saṁskṛta)', 'संस्कृतम्'),
array('sc', 'srd', 'srd', 'srd', 'Sardinian', 'sardu'),
array('sd', 'snd', 'snd', 'snd', 'Sindhi', 'सिन्धी, سنڌي، سندھی‎'),
array('se', 'sme', 'sme', 'sme', 'Northern Sami', 'Davvisámegiella'),
array('sm', 'smo', 'smo', 'smo', 'Samoan', 'gagana fa\'a Samoa'),
array('sg', 'sag', 'sag', 'sag', 'Sango', 'yângâ tî sängö'),
array('sr', 'srp', 'srp', 'srp', 'Serbian', 'српски језик'),
array('gd', 'gla', 'gla', 'gla', 'Scottish Gaelic, Gaelic', 'Gàidhlig'),
array('sn', 'sna', 'sna', 'sna', 'Shona', 'chiShona'),
array('si', 'sin', 'sin', 'sin', 'Sinhala, Sinhalese', 'සිංහල'),
array('sk', 'slk', 'slo', 'slk', 'Slovak', 'slovenčina, slovenský jazyk'),
array('sl', 'slv', 'slv', 'slv', 'Slovene', 'slovenski jezik, slovenščina'),
array('so', 'som', 'som', 'som', 'Somali', 'Soomaaliga, af Soomaali'),
array('st', 'sot', 'sot', 'sot', 'Southern Sotho', 'Sesotho'),
array('es', 'spa', 'spa', 'spa', 'Spanish', 'español'),
array('su', 'sun', 'sun', 'sun', 'Sundanese', 'Basa Sunda'),
array('sw', 'swa', 'swa', 'swa', 'Swahili', 'Kiswahili'),
array('ss', 'ssw', 'ssw', 'ssw', 'Swati', 'SiSwati'),
array('sv', 'swe', 'swe', 'swe', 'Swedish', 'svenska'),
array('ta', 'tam', 'tam', 'tam', 'Tamil', 'தமிழ்'),
array('te', 'tel', 'tel', 'tel', 'Telugu', 'తెలుగు'),
array('tg', 'tgk', 'tgk', 'tgk', 'Tajik', 'тоҷикӣ, toçikī, تاجیکی‎'),
array('th', 'tha', 'tha', 'tha', 'Thai', 'ไทย'),
array('ti', 'tir', 'tir', 'tir', 'Tigrinya', 'ትግርኛ'),
array('bo', 'bod', 'tib', 'bod', 'Tibetan Standard, Tibetan, Central', 'བོད་ཡིག'),
array('tk', 'tuk', 'tuk', 'tuk', 'Turkmen', 'Türkmen, Түркмен'),
array('tl', 'tgl', 'tgl', 'tgl', 'Tagalog', 'Wikang Tagalog, ᜏᜒᜃᜅ᜔ ᜆᜄᜎᜓᜄ᜔'),
array('tn', 'tsn', 'tsn', 'tsn', 'Tswana', 'Setswana'),
array('to', 'ton', 'ton', 'ton', 'Tonga (Tonga Islands)', 'faka Tonga'),
array('tr', 'tur', 'tur', 'tur', 'Turkish', 'Türkçe'),
array('ts', 'tso', 'tso', 'tso', 'Tsonga', 'Xitsonga'),
array('tt', 'tat', 'tat', 'tat', 'Tatar', 'татар теле, tatar tele'),
array('tw', 'twi', 'twi', 'twi', 'Twi', 'Twi'),
array('ty', 'tah', 'tah', 'tah', 'Tahitian', 'Reo Tahiti'),
array('ug', 'uig', 'uig', 'uig', 'Uyghur', 'ئۇيغۇرچە‎, Uyghurche'),
array('uk', 'ukr', 'ukr', 'ukr', 'Ukrainian', 'українська мова'),
array('ur', 'urd', 'urd', 'urd', 'Urdu', 'اردو'),
array('uz', 'uzb', 'uzb', 'uzb', 'Uzbek', 'Oʻzbek, Ўзбек, أۇزبېك‎'),
array('ve', 'ven', 'ven', 'ven', 'Venda', 'Tshivenḓa'),
array('vi', 'vie', 'vie', 'vie', 'Vietnamese', 'Việt Nam'),
array('vo', 'vol', 'vol', 'vol', 'Volapük', 'Volapük'),
array('wa', 'wln', 'wln', 'wln', 'Walloon', 'walon'),
array('cy', 'cym', 'wel', 'cym', 'Welsh', 'Cymraeg'),
array('wo', 'wol', 'wol', 'wol', 'Wolof', 'Wollof'),
array('fy', 'fry', 'fry', 'fry', 'Western Frisian', 'Frysk'),
array('xh', 'xho', 'xho', 'xho', 'Xhosa', 'isiXhosa'),
array('yi', 'yid', 'yid', 'yid', 'Yiddish', 'ייִדיש'),
array('yo', 'yor', 'yor', 'yor', 'Yoruba', 'Yorùbá'),
array('za', 'zha', 'zha', 'zha', 'Zhuang, Chuang', 'Saɯ cueŋƅ, Saw cuengh'),
array('zu', 'zul', 'zul', 'zul', 'Zulu', 'isiZulu'),
);
/*
* Get all language data
*
* @return (array)
*/
public function allLanguages()
{
return $this->languages;
}
/*
* Get language name from ISO-639-1 (two-letters code)
*
* @return (string)
*/
public function languageByCode1($code)
{
$code = strtolower($code);
$result = '';
foreach ($this->languages as $lang) {
if ($lang[0] == $code) {
$result = $lang[4];
break;
}
}
return $result;
}
/*
* Get native language name from ISO-639-1 (two-letters code)
*
* @return (string)
*/
public function nativeByCode1($code)
{
$code = strtolower($code);
$result = '';
foreach ($this->languages as $lang) {
if ($lang[0] == $code) {
$result = $lang[5];
break;
}
}
return $result;
}
/*
* Get language name from ISO-639-2/t (three-letter codes) terminologic
*
* @return (string)
*/
public function languageByCode2t($code)
{
$code = strtolower($code);
$result = '';
foreach ($this->languages as $lang) {
if ($lang[1] == $code) {
$result = $lang[4];
break;
}
}
return $result;
}
/*
* Get native language name from ISO-639-2/t (three-letter codes) terminologic
*
* @return (string)
*/
public function nativeByCode2t($code)
{
$code = strtolower($code);
$result = '';
foreach ($this->languages as $lang) {
if ($lang[1] == $code) {
$result = $lang[5];
break;
}
}
return $result;
}
/*
* Get language name from ISO-639-2/b (three-letter codes) bibliographic
*
* @return (string)
*/
public function languageByCode2b($code)
{
$code = strtolower($code);
$result = '';
foreach ($this->languages as $lang) {
if ($lang[2] == $code) {
$result = $lang[4];
break;
}
}
return $result;
}
/*
* Get native language name from ISO-639-2/b (three-letter codes) bibliographic
*
* @return (string)
*/
public function nativeByCode2b($code)
{
$code = strtolower($code);
$result = '';
foreach ($this->languages as $lang) {
if ($lang[2] == $code) {
$result = $lang[5];
break;
}
}
return $result;
}
/*
* Get language name from ISO-639-3 (three-letter codes)
*
* @return (string)
*/
public function languageByCode3($code)
{
$code = strtolower($code);
$result = '';
foreach ($this->languages as $lang) {
if ($lang[3] == $code) {
$result = $lang[4];
break;
}
}
return $result;
}
/*
* Get native language name from ISO-639-3 (three-letter codes)
*
* @return (string)
*/
public function nativeByCode3($code)
{
$code = strtolower($code);
$result = '';
foreach ($this->languages as $lang) {
if ($lang[3] == $code) {
$result = $lang[5];
break;
}
}
return $result;
}
/*
* Get ISO-639-1 (two-letters code) from language name
*
* @return (string)
*/
public function code1ByLanguage($language)
{
$language_key = ucwords(strtolower($language));
$result = '';
foreach ($this->languages as $lang) {
if (in_array($language_key, explode(', ', $lang[4]))) {
$result = $lang[0];
break;
}
}
return $result;
}
/*
* Get ISO-639-2/t (three-letter codes) terminologic from language name
*
* @return (string)
*/
public function code2tByLanguage($language)
{
$language_key = ucwords(strtolower($language));
$result = '';
foreach ($this->languages as $lang) {
if (in_array($language_key, explode(', ', $lang[4]))) {
$result = $lang[1];
break;
}
}
return $result;
}
/*
* Get ISO-639-2/b (three-letter codes) bibliographic from language name
*
* @return (string)
*/
public function code2bByLanguage($language)
{
$language_key = ucwords(strtolower($language));
$result = '';
foreach ($this->languages as $lang) {
if (in_array($language_key, explode(', ', $lang[4]))) {
$result = $lang[2];
break;
}
}
return $result;
}
/*
* Get ISO-639-3 (three-letter codes) from language name
*
* @return (string)
*/
public function code3ByLanguage($language)
{
$language_key = ucwords(strtolower($language));
$result = '';
foreach ($this->languages as $lang) {
if (in_array($language_key, explode(', ', $lang[4]))) {
$result = $lang[3];
break;
}
}
return $result;
}
}

View file

@ -0,0 +1,239 @@
<?php
use Matriphe\ISO639\ISO639;
class ISO639Test extends PHPUnit_Framework_TestCase
{
public function __construct()
{
$this->iso = new ISO639();
}
public function testLanguageISO6391()
{
$this->assertSame('English', $this->iso->languageByCode1('en'));
$this->assertSame('French', $this->iso->languageByCode1('fr'));
$this->assertSame('Spanish', $this->iso->languageByCode1('es'));
$this->assertSame('Indonesian', $this->iso->languageByCode1('id'));
$this->assertSame('Javanese', $this->iso->languageByCode1('jv'));
$this->assertSame('Hindi', $this->iso->languageByCode1('hi'));
$this->assertSame('Thai', $this->iso->languageByCode1('th'));
$this->assertSame('Korean', $this->iso->languageByCode1('ko'));
$this->assertSame('Japanese', $this->iso->languageByCode1('ja'));
$this->assertSame('Chinese', $this->iso->languageByCode1('zh'));
$this->assertSame('Russian', $this->iso->languageByCode1('ru'));
$this->assertSame('Arabic', $this->iso->languageByCode1('ar'));
$this->assertSame('Vietnamese', $this->iso->languageByCode1('vi'));
$this->assertSame('Malay', $this->iso->languageByCode1('ms'));
$this->assertSame('Sundanese', $this->iso->languageByCode1('su'));
}
public function testNativeISO6391()
{
$this->assertSame('English', $this->iso->nativeByCode1('en'));
$this->assertSame('français, langue française', $this->iso->nativeByCode1('fr'));
$this->assertSame('español', $this->iso->nativeByCode1('es'));
$this->assertSame('Bahasa Indonesia', $this->iso->nativeByCode1('id'));
$this->assertSame('basa Jawa', $this->iso->nativeByCode1('jv'));
$this->assertSame('हिन्दी, हिंदी', $this->iso->nativeByCode1('hi'));
$this->assertSame('ไทย', $this->iso->nativeByCode1('th'));
$this->assertSame('한국어, 조선어', $this->iso->nativeByCode1('ko'));
$this->assertSame('日本語 (にほんご)', $this->iso->nativeByCode1('ja'));
$this->assertSame('中文 (Zhōngwén), 汉语, 漢語', $this->iso->nativeByCode1('zh'));
$this->assertSame('Русский', $this->iso->nativeByCode1('ru'));
$this->assertSame('العربية', $this->iso->nativeByCode1('ar'));
$this->assertSame('Việt Nam', $this->iso->nativeByCode1('vi'));
$this->assertSame('bahasa Melayu, بهاس ملايو‎', $this->iso->nativeByCode1('ms'));
$this->assertSame('Basa Sunda', $this->iso->nativeByCode1('su'));
}
public function testLanguageISO6392t()
{
$this->assertSame('English', $this->iso->languageByCode2t('eng'));
$this->assertSame('French', $this->iso->languageByCode2t('fra'));
$this->assertSame('Spanish', $this->iso->languageByCode2t('spa'));
$this->assertSame('Indonesian', $this->iso->languageByCode2t('ind'));
$this->assertSame('Javanese', $this->iso->languageByCode2t('jav'));
$this->assertSame('Hindi', $this->iso->languageByCode2t('hin'));
$this->assertSame('Thai', $this->iso->languageByCode2t('tha'));
$this->assertSame('Korean', $this->iso->languageByCode2t('kor'));
$this->assertSame('Japanese', $this->iso->languageByCode2t('jpn'));
$this->assertSame('Chinese', $this->iso->languageByCode2t('zho'));
$this->assertSame('Russian', $this->iso->languageByCode2t('rus'));
$this->assertSame('Arabic', $this->iso->languageByCode2t('ara'));
$this->assertSame('Vietnamese', $this->iso->languageByCode2t('vie'));
$this->assertSame('Malay', $this->iso->languageByCode2t('msa'));
$this->assertSame('Sundanese', $this->iso->languageByCode2t('sun'));
}
public function testNativeISO6392t()
{
$this->assertSame('English', $this->iso->nativeByCode2t('eng'));
$this->assertSame('français, langue française', $this->iso->nativeByCode2t('fra'));
$this->assertSame('español', $this->iso->nativeByCode2t('spa'));
$this->assertSame('Bahasa Indonesia', $this->iso->nativeByCode2t('ind'));
$this->assertSame('basa Jawa', $this->iso->nativeByCode2t('jav'));
$this->assertSame('हिन्दी, हिंदी', $this->iso->nativeByCode2t('hin'));
$this->assertSame('ไทย', $this->iso->nativeByCode2t('tha'));
$this->assertSame('한국어, 조선어', $this->iso->nativeByCode2t('kor'));
$this->assertSame('日本語 (にほんご)', $this->iso->nativeByCode2t('jpn'));
$this->assertSame('中文 (Zhōngwén), 汉语, 漢語', $this->iso->nativeByCode2t('zho'));
$this->assertSame('Русский', $this->iso->nativeByCode2t('rus'));
$this->assertSame('العربية', $this->iso->nativeByCode2t('ara'));
$this->assertSame('Việt Nam', $this->iso->nativeByCode2t('vie'));
$this->assertSame('bahasa Melayu, بهاس ملايو‎', $this->iso->nativeByCode2t('msa'));
$this->assertSame('Basa Sunda', $this->iso->nativeByCode2t('sun'));
}
public function testLanguageISO6392b()
{
$this->assertSame('English', $this->iso->languageByCode2b('eng'));
$this->assertSame('French', $this->iso->languageByCode2b('fre'));
$this->assertSame('Spanish', $this->iso->languageByCode2b('spa'));
$this->assertSame('Indonesian', $this->iso->languageByCode2b('ind'));
$this->assertSame('Javanese', $this->iso->languageByCode2b('jav'));
$this->assertSame('Hindi', $this->iso->languageByCode2b('hin'));
$this->assertSame('Thai', $this->iso->languageByCode2b('tha'));
$this->assertSame('Korean', $this->iso->languageByCode2b('kor'));
$this->assertSame('Japanese', $this->iso->languageByCode2b('jpn'));
$this->assertSame('Chinese', $this->iso->languageByCode2b('chi'));
$this->assertSame('Russian', $this->iso->languageByCode2b('rus'));
$this->assertSame('Arabic', $this->iso->languageByCode2b('ara'));
$this->assertSame('Vietnamese', $this->iso->languageByCode2b('vie'));
$this->assertSame('Malay', $this->iso->languageByCode2b('may'));
$this->assertSame('Sundanese', $this->iso->languageByCode2b('sun'));
}
public function testNativeISO6392b()
{
$this->assertSame('English', $this->iso->nativeByCode2b('eng'));
$this->assertSame('français, langue française', $this->iso->nativeByCode2b('fre'));
$this->assertSame('español', $this->iso->nativeByCode2b('spa'));
$this->assertSame('Bahasa Indonesia', $this->iso->nativeByCode2b('ind'));
$this->assertSame('basa Jawa', $this->iso->nativeByCode2b('jav'));
$this->assertSame('हिन्दी, हिंदी', $this->iso->nativeByCode2b('hin'));
$this->assertSame('ไทย', $this->iso->nativeByCode2b('tha'));
$this->assertSame('한국어, 조선어', $this->iso->nativeByCode2b('kor'));
$this->assertSame('日本語 (にほんご)', $this->iso->nativeByCode2b('jpn'));
$this->assertSame('中文 (Zhōngwén), 汉语, 漢語', $this->iso->nativeByCode2b('chi'));
$this->assertSame('Русский', $this->iso->nativeByCode2b('rus'));
$this->assertSame('العربية', $this->iso->nativeByCode2b('ara'));
$this->assertSame('Việt Nam', $this->iso->nativeByCode2b('vie'));
$this->assertSame('bahasa Melayu, بهاس ملايو‎', $this->iso->nativeByCode2b('may'));
$this->assertSame('Basa Sunda', $this->iso->nativeByCode2b('sun'));
}
public function testLanguageISO6393()
{
$this->assertSame('English', $this->iso->languageByCode3('eng'));
$this->assertSame('French', $this->iso->languageByCode3('fra'));
$this->assertSame('Spanish', $this->iso->languageByCode3('spa'));
$this->assertSame('Indonesian', $this->iso->languageByCode3('ind'));
$this->assertSame('Javanese', $this->iso->languageByCode3('jav'));
$this->assertSame('Hindi', $this->iso->languageByCode3('hin'));
$this->assertSame('Thai', $this->iso->languageByCode3('tha'));
$this->assertSame('Korean', $this->iso->languageByCode3('kor'));
$this->assertSame('Japanese', $this->iso->languageByCode3('jpn'));
$this->assertSame('Chinese', $this->iso->languageByCode3('zho'));
$this->assertSame('Russian', $this->iso->languageByCode3('rus'));
$this->assertSame('Arabic', $this->iso->languageByCode3('ara'));
$this->assertSame('Vietnamese', $this->iso->languageByCode3('vie'));
$this->assertSame('Malay', $this->iso->languageByCode3('msa'));
$this->assertSame('Sundanese', $this->iso->languageByCode3('sun'));
}
public function testNativeISO6393()
{
$this->assertSame('English', $this->iso->nativeByCode3('eng'));
$this->assertSame('français, langue française', $this->iso->nativeByCode3('fra'));
$this->assertSame('español', $this->iso->nativeByCode3('spa'));
$this->assertSame('Bahasa Indonesia', $this->iso->nativeByCode3('ind'));
$this->assertSame('basa Jawa', $this->iso->nativeByCode3('jav'));
$this->assertSame('हिन्दी, हिंदी', $this->iso->nativeByCode3('hin'));
$this->assertSame('ไทย', $this->iso->nativeByCode3('tha'));
$this->assertSame('한국어, 조선어', $this->iso->nativeByCode3('kor'));
$this->assertSame('日本語 (にほんご)', $this->iso->nativeByCode3('jpn'));
$this->assertSame('中文 (Zhōngwén), 汉语, 漢語', $this->iso->nativeByCode3('zho'));
$this->assertSame('Русский', $this->iso->nativeByCode3('rus'));
$this->assertSame('العربية', $this->iso->nativeByCode3('ara'));
$this->assertSame('Việt Nam', $this->iso->nativeByCode3('vie'));
$this->assertSame('bahasa Melayu, بهاس ملايو‎', $this->iso->nativeByCode3('msa'));
$this->assertSame('Basa Sunda', $this->iso->nativeByCode3('sun'));
}
public function testISO6391Language()
{
$this->assertSame('en', $this->iso->code1ByLanguage('English'));
$this->assertSame('fr', $this->iso->code1ByLanguage('French'));
$this->assertSame('es', $this->iso->code1ByLanguage('Spanish'));
$this->assertSame('id', $this->iso->code1ByLanguage('Indonesian'));
$this->assertSame('jv', $this->iso->code1ByLanguage('Javanese'));
$this->assertSame('hi', $this->iso->code1ByLanguage('Hindi'));
$this->assertSame('th', $this->iso->code1ByLanguage('Thai'));
$this->assertSame('ko', $this->iso->code1ByLanguage('Korean'));
$this->assertSame('ja', $this->iso->code1ByLanguage('Japanese'));
$this->assertSame('zh', $this->iso->code1ByLanguage('Chinese'));
$this->assertSame('ru', $this->iso->code1ByLanguage('Russian'));
$this->assertSame('ar', $this->iso->code1ByLanguage('Arabic'));
$this->assertSame('vi', $this->iso->code1ByLanguage('Vietnamese'));
$this->assertSame('ms', $this->iso->code1ByLanguage('Malay'));
$this->assertSame('su', $this->iso->code1ByLanguage('Sundanese'));
}
public function testISO6392tLanguage()
{
$this->assertSame('eng', $this->iso->code2tByLanguage('English'));
$this->assertSame('fra', $this->iso->code2tByLanguage('French'));
$this->assertSame('spa', $this->iso->code2tByLanguage('Spanish'));
$this->assertSame('ind', $this->iso->code2tByLanguage('Indonesian'));
$this->assertSame('jav', $this->iso->code2tByLanguage('Javanese'));
$this->assertSame('hin', $this->iso->code2tByLanguage('Hindi'));
$this->assertSame('tha', $this->iso->code2tByLanguage('Thai'));
$this->assertSame('kor', $this->iso->code2tByLanguage('Korean'));
$this->assertSame('jpn', $this->iso->code2tByLanguage('Japanese'));
$this->assertSame('zho', $this->iso->code2tByLanguage('Chinese'));
$this->assertSame('rus', $this->iso->code2tByLanguage('Russian'));
$this->assertSame('ara', $this->iso->code2tByLanguage('Arabic'));
$this->assertSame('vie', $this->iso->code2tByLanguage('Vietnamese'));
$this->assertSame('msa', $this->iso->code2tByLanguage('Malay'));
$this->assertSame('sun', $this->iso->code2tByLanguage('Sundanese'));
}
public function testISO6392bLanguage()
{
$this->assertSame('eng', $this->iso->code2bByLanguage('English'));
$this->assertSame('fre', $this->iso->code2bByLanguage('French'));
$this->assertSame('spa', $this->iso->code2bByLanguage('Spanish'));
$this->assertSame('ind', $this->iso->code2bByLanguage('Indonesian'));
$this->assertSame('jav', $this->iso->code2bByLanguage('Javanese'));
$this->assertSame('hin', $this->iso->code2bByLanguage('Hindi'));
$this->assertSame('tha', $this->iso->code2bByLanguage('Thai'));
$this->assertSame('kor', $this->iso->code2bByLanguage('Korean'));
$this->assertSame('jpn', $this->iso->code2bByLanguage('Japanese'));
$this->assertSame('chi', $this->iso->code2bByLanguage('Chinese'));
$this->assertSame('rus', $this->iso->code2bByLanguage('Russian'));
$this->assertSame('ara', $this->iso->code2bByLanguage('Arabic'));
$this->assertSame('vie', $this->iso->code2bByLanguage('Vietnamese'));
$this->assertSame('may', $this->iso->code2bByLanguage('Malay'));
$this->assertSame('sun', $this->iso->code2bByLanguage('Sundanese'));
}
public function testISO6393Language()
{
$this->assertSame('eng', $this->iso->code3ByLanguage('English'));
$this->assertSame('fra', $this->iso->code3ByLanguage('French'));
$this->assertSame('spa', $this->iso->code3ByLanguage('Spanish'));
$this->assertSame('ind', $this->iso->code3ByLanguage('Indonesian'));
$this->assertSame('jav', $this->iso->code3ByLanguage('Javanese'));
$this->assertSame('hin', $this->iso->code3ByLanguage('Hindi'));
$this->assertSame('tha', $this->iso->code3ByLanguage('Thai'));
$this->assertSame('kor', $this->iso->code3ByLanguage('Korean'));
$this->assertSame('jpn', $this->iso->code3ByLanguage('Japanese'));
$this->assertSame('zho', $this->iso->code3ByLanguage('Chinese'));
$this->assertSame('rus', $this->iso->code3ByLanguage('Russian'));
$this->assertSame('ara', $this->iso->code3ByLanguage('Arabic'));
$this->assertSame('vie', $this->iso->code3ByLanguage('Vietnamese'));
$this->assertSame('msa', $this->iso->code3ByLanguage('Malay'));
$this->assertSame('sun', $this->iso->code3ByLanguage('Sundanese'));
}
}