Add array for ISO639-2b language codes

This commit is contained in:
Joshua Ramon Enslin 2021-04-05 23:25:27 +02:00
parent fa593c4be1
commit e331d8fd2c
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
3 changed files with 271 additions and 1 deletions

View File

@ -200,7 +200,199 @@ final class MDLanguagesSet {
'yo' => 'Yoruba',
'za' => 'Zhuang, Chuang',
'zh' => 'Chinese',
'zu' => 'Zulu'
'zu' => 'Zulu',
];
const LANGUAGES_ISO639_2B = [
'aa' => 'aar', # 'Afar-áf',
'ab' => 'abk', # 'аҧсуа бызшәа',
'ae' => 'ave', # 'Avestan',
'af' => 'afr', # 'Afrikaans',
'ak' => 'aka', # 'Akan',
'am' => 'amh', # 'Amharic',
'an' => 'arg', # 'Aragonese',
'ar' => 'ara', # 'العربية',
'as' => 'asm', # 'Assamese',
'av' => 'ava', # 'Avaric',
'ay' => 'aym', # 'Aymara',
'az' => 'aze', # 'Azerbaijani',
'ba' => 'bak', # 'Bashkir',
'be' => 'bel', # 'беларуская мова',
'bg' => 'bul', # 'български език',
'bh' => 'bih', # 'Bihari',
'bi' => 'bis', # 'Bislama',
'bm' => 'bam', # 'Bambara',
'bn' => 'ben', # 'Bengali',
'bo' => 'tib', # 'བོད་སྐད',
'br' => 'bre', # 'Breton',
'bs' => 'bos', # 'Bosnian',
'ca' => 'cat', # 'català',
'ce' => 'che', # 'Chechen',
'ch' => 'cha', # 'Chamorro',
'co' => 'cos', # 'Corsican',
'cr' => 'cre', # 'Cree',
'cs' => 'cze', # 'čeština',
'cu' => 'chu', # 'словѣньскъ ѩзыкъ',
'cv' => 'chv', # 'Chuvash',
'cy' => 'wel', # 'Welsh',
'da' => 'dan', # 'Danish',
'de' => 'ger', # 'Deutsch',
'dsb' => 'dsb', # 'Dolnoserbšćina',
'dv' => 'div', # 'Divehi; Dhivehi; Maldivian;',
'dz' => 'dzo', # 'Dzongkha',
'ee' => 'ewe', # 'Ewe',
'egy' => 'egy', # 'Egyptian language',
'el' => 'gre', # 'ελληνικά',
'en' => 'eng', # 'English',
'eo' => 'epo', # 'Esperanto',
'es' => 'spa', # 'Spanish; Castilian',
'et' => 'est', # 'Estonian',
'eu' => 'baq', # 'Basque',
'fa' => 'per', # 'Persian',
'ff' => 'ful', # 'Fula; Fulah; Pulaar; Pular',
'fi' => 'fin', # 'Finnish',
'fj' => 'fij', # 'Fijian',
'fo' => 'fao', # 'Faroese',
'fr' => 'fre', # 'French',
'fy' => 'fry', # 'Western Frisian',
'ga' => 'gle', # 'Irish',
'gd' => 'gla', # 'Scottish Gaelic; Gaelic',
'gl' => 'glg', # 'Galician',
'gn' => 'grn', # 'Guaraní',
'grc' => 'grc', # 'Ancient Greek',
'gu' => 'guj', # 'Gujarati',
'gv' => 'glv', # 'Manx',
'ha' => 'hau', # 'Hausa',
'he' => 'heb', # 'Hebrew (modern)',
'hi' => 'hin', # 'Hindi',
'ho' => 'hmo', # 'Hiri Motu',
'hr' => 'hrv', # 'Croatian',
'hsb' => 'hsb', # 'Hornjoserbšćina',
'ht' => 'hat', # 'Haitian; Haitian Creole',
'hu' => 'hun', # 'Magyar',
'hy' => 'arm', # 'Armenian',
'hz' => 'her', # 'Herero',
'ia' => 'ina', # 'Interlingua',
'id' => 'ind', # 'Bahasa Indonesia',
'ie' => 'ile', # 'Interlingue',
'ig' => 'ibo', # 'Igbo',
'ii' => 'iii', # 'Nuosu',
'ik' => 'ipk', # 'Inupiaq',
'io' => 'ido', # 'Ido',
'is' => 'ice', # 'Icelandic',
'it' => 'ita', # 'Italian',
'iu' => 'iku', # 'Inuktitut',
'ja' => 'jpn', # 'Japanese (ja)',
'jv' => 'jav', # 'Javanese (jv)',
'ka' => 'geo', # 'Georgian',
'kg' => 'kon', # 'Kongo',
'ki' => 'kik', # 'Kikuyu, Gikuyu',
'kj' => 'kua', # 'Kwanyama, Kuanyama',
'kk' => 'kaz', # 'Kazakh',
'kl' => 'kal', # 'Kalaallisut, Greenlandic',
'km' => 'khm', # 'Khmer',
'kn' => 'kan', # 'Kannada',
'ko' => 'kor', # 'Korean',
'kr' => 'kau', # 'Kanuri',
'ks' => 'kas', # 'Kashmiri',
'ku' => 'kur', # 'Kurdish',
'kv' => 'kom', # 'Komi',
'kw' => 'cor', # 'Cornish',
'ky' => 'kir', # 'Kirghiz, Kyrgyz',
'la' => 'lat', # 'Latin',
'lb' => 'ltz', # 'Lëtzebuergesch',
'lg' => 'lug', # 'Luganda',
'li' => 'lim', # 'Limburgish, Limburgan, Limburger',
'ln' => 'lin', # 'Lingala',
'lo' => 'lao', # 'Lao',
'lt' => 'lit', # 'lietuvių kalba',
'lu' => 'lub', # 'Luba-Katanga',
'lv' => 'lav', # 'Latvian',
'mg' => 'mlg', # 'Malagasy',
'mh' => 'mah', # 'Marshallese',
'mi' => 'mao', # 'Maori',
'mk' => 'mac', # 'Macedonian',
'ml' => 'mal', # 'Malayalam',
'mn' => 'mon', # 'Mongolian',
'mr' => 'mar', # 'Marathi (Mara?hi)',
'ms' => 'may', # 'Malay',
'mt' => 'mlt', # 'Maltese',
'my' => 'bur', # 'Burmese',
'na' => 'nau', # 'Nauru',
'nb' => 'nob', # 'Bokmål',
'nd' => 'nde', # 'North Ndebele',
'ne' => 'nep', # 'Nepali',
'ng' => 'ndo', # 'Ndonga',
'nl' => 'dut', # 'Nederlands',
'nn' => 'nno', # 'Nynorsk',
'no' => 'nor', # 'Norsk',
'nr' => 'nbl', # 'South Ndebele',
'nv' => 'nav', # 'Navajo, Navaho',
'ny' => 'nya', # 'Chichewa; Chewa; Nyanja',
'oc' => 'oci', # 'Occitan',
'oj' => 'oji', # 'Ojibwe, Ojibwa',
'om' => 'orm', # 'Oromo',
'or' => 'ori', # 'Oriya',
'os' => 'oss', # 'Ossetian, Ossetic',
'pa' => 'pan', # 'Panjabi, Punjabi',
'pi' => 'pli', # 'Pali',
'pl' => 'pol', # 'Polish',
'ps' => 'pus', # 'Pashto, Pushto',
'pt' => 'por', # 'Português',
'qu' => 'que', # 'Quechua',
'rm' => 'roh', # 'Romansh',
'rn' => 'run', # 'Kirundi',
'ro' => 'rum', # 'Română',
'ru' => 'rus', # 'Russian',
'rw' => 'kin', # 'Kinyarwanda',
'sa' => 'san', # 'Sanskrit (संस्कृत)',
'sc' => 'srd', # 'Sardinian',
'sd' => 'snd', # 'Sindhi',
'se' => 'sme', # 'Northern Sami',
'sg' => 'sag', # 'Sango',
'si' => 'sin', # 'Sinhala, Sinhalese',
'sk' => 'slo', # 'Slovenčina',
'sl' => 'slv', # 'Slovenščina',
'sm' => 'smo', # 'Samoan',
'sn' => 'sna', # 'Shona',
'so' => 'som', # 'Somali',
'sq' => 'alb', # 'Albanian',
'sr' => 'srp', # 'Serbian',
'ss' => 'ssw', # 'Swati',
'st' => 'sot', # 'Southern Sotho',
'su' => 'sun', # 'Sundanese',
'sv' => 'swe', # 'Swedish',
'sw' => 'swa', # 'Swahili',
'ta' => 'tam', # 'Tamil',
'te' => 'tel', # 'Telugu',
'tg' => 'tgk', # 'Tajik',
'th' => 'tha', # 'ภาษาไทย',
'ti' => 'tir', # 'Tigrinya',
'tk' => 'tuk', # 'Turkmen',
'tl' => 'tgl', # 'Tagalog',
'tn' => 'tsn', # 'Tswana',
'to' => 'ton', # 'Tonga (Tonga Islands)',
'tr' => 'tur', # 'Türkçe',
'ts' => 'tso', # 'Tsonga',
'tt' => 'tat', # 'Tatar',
'tw' => 'twi', # 'Twi',
'ty' => 'tah', # 'Tahitian',
'ug' => 'uig', # 'Uighur, Uyghur',
'uk' => 'ukr', # 'Ukrainian',
'ur' => 'urd', # 'اردو',
'uz' => 'uzb', # 'Uzbek',
've' => 'ven', # 'Venda',
'vi' => 'vie', # 'Vietnamese',
'vo' => 'vol', # 'Volapük',
'wa' => 'wln', # 'Walloon',
'wen' => 'wen', # 'Sorbisch',
'wo' => 'wol', # 'Wolof',
'xh' => 'xho', # 'Xhosa',
'yi' => 'yid', # 'Yiddish',
'yo' => 'yor', # 'Yoruba',
'za' => 'zha', # 'Zhuang, Chuang',
'zh' => 'chi', # 'Chinese',
'zu' => 'zul', # 'Zulu',
];
}

View File

@ -0,0 +1,38 @@
<?PHP
/**
* This script contains tests for the home page.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
use PHPUnit\Framework\TestCase;
require __DIR__ . '/../src/MDLanguagesSet.php';
/**
* Tests for home page.
*/
final class MDLanguagesSetTest extends TestCase {
/**
* Test to check whether the HTML page is correctly generated.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testIso639ListIsCorrect():void {
foreach (MDLanguagesSet::AVAILABLE_LANGUAGES as $language_code => $language_name) {
self::assertArrayHasKey($language_code, MDLanguagesSet::LANGUAGES_ISO639_2B, 'Language ' . $language_code . ' (' . $language_name . ') has no entry in ISO639-2b language code list');
self::assertEquals(3, strlen(MDLanguagesSet::LANGUAGES_ISO639_2B[$language_code]), 'ISO639-2b entry for language ' . $language_code . ' (' . $language_name . ') is not = 3');
}
foreach (MDLanguagesSet::LANGUAGES_ISO639_2B as $language_code => $language_name) {
self::assertArrayHasKey($language_code, MDLanguagesSet::AVAILABLE_LANGUAGES, 'Language ' . $language_code . ' (' . $language_name . ') has an entry in ISO639-2b language code list, but not in the main list.');
}
}
}

40
tests/config.xml Normal file
View File

@ -0,0 +1,40 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/|version|/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutChangesToGlobalState="false"
beStrictAboutOutputDuringTests="false"
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutTodoAnnotatedTests="true"
beStrictAboutCoversAnnotation="false"
cacheResult="false"
colors="true"
convertErrorsToExceptions="true"
convertDeprecationsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
enforceTimeLimit="true"
failOnWarning="true"
forceCoversAnnotation="false"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
processIsolation="true"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="true"
stopOnSkipped="true"
stopOnRisky="true"
testSuiteLoaderClass="PHPUnit\Runner\StandardTestSuiteLoader"
timeoutForSmallTests="1"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
verbose="true">
<!-- <file>/path/to/file</file>
<exclude>
<directory suffix=".php">/path/to/files</directory>
<file>/path/to/file</file>
preserveGlobalState="false"
runTestInSeparateProcess="true"
</exclude>-->
</phpunit>