diff --git a/langfilter/composer.json b/langfilter/composer.json new file mode 100644 index 00000000..2f4f460f --- /dev/null +++ b/langfilter/composer.json @@ -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" +} diff --git a/langfilter/composer.lock b/langfilter/composer.lock new file mode 100644 index 00000000..0c6baf66 --- /dev/null +++ b/langfilter/composer.lock @@ -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" +} diff --git a/langfilter/lang/C/messages.po b/langfilter/lang/C/messages.po index 717a9374..0fed0fae 100644 --- a/langfilter/lang/C/messages.po +++ b/langfilter/lang/C/messages.po @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/langfilter/langfilter.php b/langfilter/langfilter.php index 95488421..abd3c704 100644 --- a/langfilter/langfilter.php +++ b/langfilter/langfilter.php @@ -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 diff --git a/langfilter/templates/settings.tpl b/langfilter/templates/settings.tpl index 8e62ef49..d2de7fce 100644 --- a/langfilter/templates/settings.tpl +++ b/langfilter/templates/settings.tpl @@ -10,7 +10,7 @@

{{$intro}}

{{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}}
diff --git a/langfilter/vendor/autoload.php b/langfilter/vendor/autoload.php new file mode 100644 index 00000000..23e5df1e --- /dev/null +++ b/langfilter/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * 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 + * @author Jordi Boggiano + * @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; +} diff --git a/langfilter/vendor/composer/LICENSE b/langfilter/vendor/composer/LICENSE new file mode 100644 index 00000000..f27399a0 --- /dev/null +++ b/langfilter/vendor/composer/LICENSE @@ -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. + diff --git a/langfilter/vendor/composer/autoload_classmap.php b/langfilter/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..7a91153b --- /dev/null +++ b/langfilter/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/matriphe/iso-639/src'), +); diff --git a/langfilter/vendor/composer/autoload_real.php b/langfilter/vendor/composer/autoload_real.php new file mode 100644 index 00000000..fed9c349 --- /dev/null +++ b/langfilter/vendor/composer/autoload_real.php @@ -0,0 +1,55 @@ += 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; + } +} diff --git a/langfilter/vendor/composer/autoload_static.php b/langfilter/vendor/composer/autoload_static.php new file mode 100644 index 00000000..51ac8bdf --- /dev/null +++ b/langfilter/vendor/composer/autoload_static.php @@ -0,0 +1,31 @@ + + 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); + } +} diff --git a/langfilter/vendor/composer/installed.json b/langfilter/vendor/composer/installed.json new file mode 100644 index 00000000..796c98f3 --- /dev/null +++ b/langfilter/vendor/composer/installed.json @@ -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" + ] + } +] diff --git a/langfilter/vendor/matriphe/iso-639/.gitignore b/langfilter/vendor/matriphe/iso-639/.gitignore new file mode 100644 index 00000000..8b7ef350 --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/.gitignore @@ -0,0 +1,2 @@ +/vendor +composer.lock diff --git a/langfilter/vendor/matriphe/iso-639/.php_cs b/langfilter/vendor/matriphe/iso-639/.php_cs new file mode 100644 index 00000000..e862e68d --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/.php_cs @@ -0,0 +1,122 @@ +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__) + ) +; \ No newline at end of file diff --git a/langfilter/vendor/matriphe/iso-639/.travis.yml b/langfilter/vendor/matriphe/iso-639/.travis.yml new file mode 100644 index 00000000..4e807d90 --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/.travis.yml @@ -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" diff --git a/langfilter/vendor/matriphe/iso-639/README.md b/langfilter/vendor/matriphe/iso-639/README.md new file mode 100644 index 00000000..7a0b0eb1 --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/README.md @@ -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 +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 \ No newline at end of file diff --git a/langfilter/vendor/matriphe/iso-639/composer.json b/langfilter/vendor/matriphe/iso-639/composer.json new file mode 100644 index 00000000..ec74c13c --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/composer.json @@ -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/" + } + } +} diff --git a/langfilter/vendor/matriphe/iso-639/phpunit.xml b/langfilter/vendor/matriphe/iso-639/phpunit.xml new file mode 100644 index 00000000..9ef10b1e --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/phpunit.xml @@ -0,0 +1,9 @@ + + + + + tests/ISO639Test.php + + + + diff --git a/langfilter/vendor/matriphe/iso-639/resources/iso-639.csv.gz b/langfilter/vendor/matriphe/iso-639/resources/iso-639.csv.gz new file mode 100644 index 00000000..e19eb777 Binary files /dev/null and b/langfilter/vendor/matriphe/iso-639/resources/iso-639.csv.gz differ diff --git a/langfilter/vendor/matriphe/iso-639/resources/iso-639.sql.gz b/langfilter/vendor/matriphe/iso-639/resources/iso-639.sql.gz new file mode 100644 index 00000000..bb5d15eb Binary files /dev/null and b/langfilter/vendor/matriphe/iso-639/resources/iso-639.sql.gz differ diff --git a/langfilter/vendor/matriphe/iso-639/resources/wikipedia.csv b/langfilter/vendor/matriphe/iso-639/resources/wikipedia.csv new file mode 100644 index 00000000..67dc7f57 --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/resources/wikipedia.csv @@ -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| +Niger–Congo|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 +Niger–Congo|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|| +Niger–Congo|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 +Niger–Congo|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| +Niger–Congo|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|| +Niger–Congo|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|| +Niger–Congo|Igbo|Asụsụ Igbo|ig|ibo|ibo|ibo|| +Eskimo–Aleut|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| +Eskimo–Aleut|Inuktitut|ᐃᓄᒃᑎᑐᑦ|iu|iku|iku|iku + 2||macrolanguage +Japonic|Japanese|日本語 (にほんご)|ja|jpn|jpn|jpn|| +Austronesian|Javanese|basa Jawa|jv|jav|jav|jav|| +Eskimo–Aleut|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 +Niger–Congo|Kikuyu, Gikuyu|Gĩkũyũ|ki|kik|kik|kik|| +Niger–Congo|Kinyarwanda|Ikinyarwanda|rw|kin|kin|kin|| +Turkic|Kyrgyz|Кыргызча, Кыргыз тили|ky|kir|kir|kir|| +Uralic|Komi|коми кыв|kv|kom|kom|kom + 2||macrolanguage +Niger–Congo|Kongo|Kikongo|kg|kon|kon|kon + 3||macrolanguage +Koreanic|Korean|한국어, 조선어|ko|kor|kor|kor|| +Indo-European|Kurdish|Kurdî, كوردی‎|ku|kur|kur|kur + 3||macrolanguage +Niger–Congo|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|| +Niger–Congo|Ganda|Luganda|lg|lug|lug|lug|| +Indo-European|Limburgish, Limburgan, Limburger|Limburgs|li|lim|lim|lim|| +Niger–Congo|Lingala|Lingála|ln|lin|lin|lin|| +Tai–Kadai|Lao|ພາສາລາວ|lo|lao|lao|lao|| +Indo-European|Lithuanian|lietuvių kalba|lt|lit|lit|lit|| +Niger–Congo|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|| +Niger–Congo|Northern Ndebele|isiNdebele|nd|nde|nde|nde|| +Indo-European|Nepali|नेपाली|ne|nep|nep|nep|| +Niger–Congo|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 +Niger–Congo|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|| +Niger–Congo|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|| +Niger–Congo|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|| +Niger–Congo|Southern Sotho|Sesotho|st|sot|sot|sot|| +Indo-European|Spanish|español|es|spa|spa|spa|| +Austronesian|Sundanese|Basa Sunda|su|sun|sun|sun|| +Niger–Congo|Swahili|Kiswahili|sw|swa|swa|swa + 2||macrolanguage +Niger–Congo|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|| +Tai–Kadai|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] +Niger–Congo|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|| +Niger–Congo|Tsonga|Xitsonga|ts|tso|tso|tso|| +Turkic|Tatar|татар теле, tatar tele|tt|tat|tat|tat|| +Niger–Congo|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 +Niger–Congo|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|| +Niger–Congo|Wolof|Wollof|wo|wol|wol|wol|| +Indo-European|Western Frisian|Frysk|fy|fry|fry|fry|| +Niger–Congo|Xhosa|isiXhosa|xh|xho|xho|xho|| +Indo-European|Yiddish|ייִדיש|yi|yid|yid|yid + 2||macrolanguage +Niger–Congo|Yoruba|Yorùbá|yo|yor|yor|yor|| +Tai–Kadai|Zhuang, Chuang|Saɯ cueŋƅ, Saw cuengh|za|zha|zha|zha + 16||macrolanguage +Niger–Congo|Zulu|isiZulu|zu|zul|zul|zul|| \ No newline at end of file diff --git a/langfilter/vendor/matriphe/iso-639/src/ISO639.php b/langfilter/vendor/matriphe/iso-639/src/ISO639.php new file mode 100644 index 00000000..13f9942a --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/src/ISO639.php @@ -0,0 +1,460 @@ +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; + } +} diff --git a/langfilter/vendor/matriphe/iso-639/tests/ISO639Test.php b/langfilter/vendor/matriphe/iso-639/tests/ISO639Test.php new file mode 100644 index 00000000..b4f22ed7 --- /dev/null +++ b/langfilter/vendor/matriphe/iso-639/tests/ISO639Test.php @@ -0,0 +1,239 @@ +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')); + } +}