├── .github └── workflows │ └── test-pipeline.yml ├── .gitignore ├── .php_cs ├── .travis.yml ├── README.md ├── composer.json ├── phpunit.xml ├── resources ├── iso-639.csv.gz ├── iso-639.sql.gz └── wikipedia.csv ├── src └── ISO639.php └── tests └── ISO639Test.php /.github/workflows/test-pipeline.yml: -------------------------------------------------------------------------------- 1 | name: Run Test 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | run-test: 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | operating-system: [ ubuntu-latest ] 18 | php-version: 19 | - "8.3" 20 | - "8.2" 21 | - "8.1" 22 | 23 | name: PHP ${{ matrix.php-version }} 24 | runs-on: ${{ matrix.operating-system }} 25 | 26 | steps: 27 | - uses: actions/checkout@v3 28 | 29 | - name: Validate composer.json and composer.lock 30 | run: composer validate --strict 31 | 32 | - name: Cache Composer packages 33 | id: composer-cache 34 | uses: actions/cache@v3 35 | with: 36 | path: vendor 37 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 38 | restore-keys: | 39 | ${{ runner.os }}-php-${{ matrix.php-version }} 40 | 41 | - name: Install dependencies 42 | run: composer install --prefer-dist --no-progress 43 | 44 | - name: Run test 45 | run: vendor/bin/phpunit 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.lock 3 | 4 | # PhpStorm IDE 5 | /.idea -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | setRiskyAllowed(true) 5 | ->setRules([ 6 | '@PSR2' => true, 7 | 'array_syntax' => ['syntax' => 'long'], 8 | 'no_extra_consecutive_blank_lines' => [ 9 | 'break', 'continue', 'extra', 'return', 'throw', 'use', 10 | 'parenthesis_brace_block', 'square_brace_block', 11 | 'curly_brace_block' 12 | ], 13 | 'binary_operator_spaces' => true, 14 | 'blank_line_after_namespace' => true, 15 | 'blank_line_after_opening_tag' => true, 16 | 'braces' => true, 17 | 'blank_line_before_return' => true, 18 | 'cast_spaces' => true, 19 | 'class_definition' => true, 20 | 'class_keyword_remove' => false, 21 | 'concat_space' => true, 22 | 'combine_consecutive_unsets' => true, 23 | 'declare_equal_normalize' => false, 24 | 'elseif' => true, 25 | 'encoding' => true, 26 | 'ereg_to_preg' => true, 27 | 'full_opening_tag' => true, 28 | 'function_declaration' => true, 29 | 'function_typehint_space' => true, 30 | 'hash_to_slash_comment' => true, 31 | 'indentation_type' => true, 32 | 'line_ending' => true, 33 | 'linebreak_after_opening_tag' => true, 34 | 'lowercase_cast' => true, 35 | 'lowercase_constants' => true, 36 | 'lowercase_keywords' => true, 37 | //'mb_str_functions' => false, 38 | 'method_argument_space' => true, 39 | 'method_separation' => true, 40 | 'modernize_types_casting' => true, 41 | 'native_function_casing' => true, 42 | 'new_with_braces' => true, 43 | //'no_alias_functions' => false, 44 | 'no_blank_lines_after_class_opening' => true, 45 | 'no_blank_lines_after_phpdoc' => false, 46 | 'no_blank_lines_before_namespace' => false, 47 | 'no_closing_tag' => true, 48 | 'no_empty_comment' => false, 49 | 'no_empty_phpdoc' => true, 50 | 'no_empty_statement' => true, 51 | 'no_extra_consecutive_blank_lines' => true, 52 | 'no_leading_import_slash' => true, 53 | 'no_leading_namespace_whitespace' => true, 54 | 'no_mixed_echo_print' => true, 55 | 'no_multiline_whitespace_around_double_arrow' => true, 56 | 'no_multiline_whitespace_before_semicolons' => true, 57 | 'no_php4_constructor' => true, 58 | 'no_short_bool_cast' => true, 59 | 'no_short_echo_tag' => true, 60 | 'no_singleline_whitespace_before_semicolons' => true, 61 | 'no_spaces_after_function_name' => true, 62 | 'no_spaces_around_offset' => true, 63 | 'no_spaces_inside_parenthesis' => true, 64 | 'no_trailing_comma_in_list_call' => true, 65 | 'no_trailing_comma_in_singleline_array' => true, 66 | 'no_trailing_whitespace' => true, 67 | 'no_trailing_whitespace_in_comment' => true, 68 | 'no_unneeded_control_parentheses' => true, 69 | 'no_unreachable_default_argument_value' => true, 70 | 'no_unused_imports' => true, 71 | 'no_useless_else' => true, 72 | 'no_useless_return' => true, 73 | 'no_whitespace_before_comma_in_array' => true, 74 | 'no_whitespace_in_blank_line' => true, 75 | 'normalize_index_brace' => true, 76 | 'not_operator_with_successor_space' => true, 77 | 'object_operator_without_whitespace' => true, 78 | 'ordered_class_elements' => true, 79 | 'ordered_imports' => true, 80 | 'php_unit_strict' => false, 81 | /* 82 | 'phpdoc_add_missing_param_annotation' => true, 83 | 'phpdoc_align' => true, 84 | 'phpdoc_annotation_without_dot' => true, 85 | 'phpdoc_indent' => true, 86 | 'phpdoc_inline_tag' => true, 87 | 'phpdoc_no_empty_return' => true, 88 | 'phpdoc_scalar' => true, 89 | */ 90 | 'protected_to_private' => true, 91 | 'psr4' => true, 92 | 'random_api_migration' => true, 93 | 'return_type_declaration' => false, 94 | 'self_accessor' => true, 95 | //'semicolon_after_instruction' => true, 96 | 'short_scalar_cast' => true, 97 | //'simplified_null_return' => false, 98 | 'single_blank_line_at_eof' => true, 99 | 'single_blank_line_before_namespace' => true, 100 | 'single_class_element_per_statement' => true, 101 | 'single_import_per_statement' => true, 102 | 'single_line_after_imports' => true, 103 | 'single_quote' => true, 104 | 'space_after_semicolon' => true, 105 | 'standardize_not_equals' => true, 106 | 'switch_case_semicolon_to_colon' => true, 107 | 'switch_case_space' => true, 108 | 'strict_comparison' => false, 109 | 'strict_param' => false, 110 | 'ternary_operator_spaces' => true, 111 | 'trailing_comma_in_multiline_array' => true, 112 | 'trim_array_spaces' => true, 113 | 'unary_operator_spaces' => true, 114 | 'visibility_required' => true, 115 | 'whitespace_after_comma_in_array' => true, 116 | ]) 117 | ->setFinder( 118 | PhpCsFixer\Finder::create() 119 | ->exclude('storage') 120 | ->in(__DIR__) 121 | ) 122 | ; -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | install: composer install 4 | 5 | script: vendor/bin/phpunit 6 | 7 | php: 8 | - "7.1" 9 | - "7.0" 10 | - "5.6" 11 | - "5.5" 12 | - "5.4" 13 | - "5.3" 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP ISO-639 2 | 3 | [![Run Test](https://github.com/matriphe/php-iso-639/actions/workflows/test-pipeline.yml/badge.svg?branch=master)](https://github.com/matriphe/php-iso-639/actions/workflows/test-pipeline.yml) 4 | [![Total Download](https://img.shields.io/packagist/dt/matriphe/iso-639.svg)](https://packagist.org/packages/matriphe/iso-639) 5 | [![Latest Stable Version](https://img.shields.io/packagist/v/matriphe/iso-639.svg)](https://packagist.org/packages/matriphe/iso-639) 6 | 7 | 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). 8 | 9 | ## Installation 10 | 11 | For PHP 8.1 or latest: 12 | 13 | ```shell 14 | composer require matriphe/iso-639 15 | ``` 16 | 17 | For older PHP version: 18 | 19 | ```shell 20 | composer require matriphe/iso-639:1.3 21 | ``` 22 | 23 | ## Usage Example 24 | 25 | ```php 26 | languageByCode1('en'); // English 35 | echo $iso->languageByCode1('id'); // Indonesian 36 | echo $iso->languageByCode1('jv'); // Javanese 37 | 38 | // Get native language name from ISO-639-1 code 39 | echo $iso->nativeByCode1('en'); // English 40 | echo $iso->nativeByCode1('id'); // Bahasa Indonesia 41 | echo $iso->nativeByCode1('jv'); // basa Jawa 42 | 43 | // Get language name from ISO-639-2t code 44 | echo $iso->languageByCode2t('eng'); // English 45 | echo $iso->languageByCode2t('ind'); // Indonesian 46 | echo $iso->languageByCode2t('jav'); // Javanese 47 | 48 | // Get native language name from ISO-639-2t code 49 | echo $iso->nativeByCode2t('eng'); // English 50 | echo $iso->nativeByCode2t('ind'); // Bahasa Indonesia 51 | echo $iso->nativeByCode2t('jav'); // basa Jawa 52 | 53 | // Get language name from ISO-639-2b code 54 | echo $iso->languageByCode2b('eng'); // English 55 | echo $iso->languageByCode2b('ind'); // Indonesian 56 | echo $iso->languageByCode2b('jav'); // Javanese 57 | 58 | // Get native language name from ISO-639-2b code 59 | echo $iso->nativeByCode2b('eng'); // English 60 | echo $iso->nativeByCode2b('ind'); // Bahasa Indonesia 61 | echo $iso->nativeByCode2b('jav'); // basa Jawa 62 | 63 | // Get language name from ISO-639-3 code 64 | echo $iso->languageByCode3('eng'); // English 65 | echo $iso->languageByCode3('ind'); // Indonesian 66 | echo $iso->languageByCode3('jav'); // Javanese 67 | 68 | // Get native language name from ISO-639-3 code 69 | echo $iso->nativeByCode3('eng'); // English 70 | echo $iso->nativeByCode3('ind'); // Bahasa Indonesia 71 | echo $iso->nativeByCode3('jav'); // basa Jawa 72 | 73 | // Get language array from ISO-639-2b code 74 | echo $iso->getLanguageByIsoCode2b('eng'); // ['en', 'eng', 'eng', 'eng', 'English', 'English'] 75 | echo $iso->getLanguageByIsoCode2b('ind'); // ['id', 'ind', 'ind', 'ind', 'Indonesian', 'Bahasa Indonesia'] 76 | echo $iso->getLanguageByIsoCode2b('jav'); // ['jv', 'jav', 'jav', 'jav', 'Javanese', 'basa Jawa'] 77 | ``` 78 | 79 | ## To Do 80 | 81 | * Convert language name to ISO-639 code 82 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "matriphe/iso-639", 3 | "description": "PHP library to convert ISO-639-1 code to language name.", 4 | "keywords": ["iso", "iso-639", "639", "lang", "language", "laravel"], 5 | "type": "library", 6 | "require-dev": { 7 | "phpunit/phpunit": ">=10" 8 | }, 9 | "license": "MIT", 10 | "authors": [ 11 | { 12 | "name": "Muhammad Zamroni", 13 | "email": "halo@matriphe.com" 14 | } 15 | ], 16 | "require": { 17 | "php": "8.*" 18 | }, 19 | "autoload": { 20 | "psr-4": { 21 | "Matriphe\\ISO639\\": "src/" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tests 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /resources/iso-639.csv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matriphe/php-iso-639/3b7855e794ba31cdde1b464f66de3d39779b7a9e/resources/iso-639.csv.gz -------------------------------------------------------------------------------- /resources/iso-639.sql.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matriphe/php-iso-639/3b7855e794ba31cdde1b464f66de3d39779b7a9e/resources/iso-639.sql.gz -------------------------------------------------------------------------------- /resources/wikipedia.csv: -------------------------------------------------------------------------------- 1 | Northwest Caucasian|Abkhaz|аҧсуа бызшәа, аҧсшәа|ab|abk|abk|abk|abks| 2 | Afro-Asiatic|Afar|Afaraf|aa|aar|aar|aar|aars| 3 | Indo-European|Afrikaans|Afrikaans|af|afr|afr|afr|afrs| 4 | Niger–Congo|Akan|Akan|ak|aka|aka|aka + 2||macrolanguage, Twi is [tw/twi], Fanti is [fat] 5 | Indo-European|Albanian|Shqip|sq|sqi|alb|sqi + 4||macrolanguage, "Albanian Phylozone" in 639-6 6 | Afro-Asiatic|Amharic|አማርኛ|am|amh|amh|amh|| 7 | Afro-Asiatic|Arabic|العربية|ar|ara|ara|ara + 30||macrolanguage, Standard Arabic is [arb] 8 | Indo-European|Aragonese|aragonés|an|arg|arg|arg|| 9 | Indo-European|Armenian|Հայերեն|hy|hye|arm|hye|| 10 | Indo-European|Assamese|অসমীয়া|as|asm|asm|asm|| 11 | Northeast Caucasian|Avaric|авар мацӀ, магӀарул мацӀ|av|ava|ava|ava|| 12 | Indo-European|Avestan|avesta|ae|ave|ave|ave||ancient 13 | Aymaran|Aymara|aymar aru|ay|aym|aym|aym + 2||macrolanguage 14 | Turkic|Azerbaijani|azərbaycan dili|az|aze|aze|aze + 2||macrolanguage 15 | Niger–Congo|Bambara|bamanankan|bm|bam|bam|bam|| 16 | Turkic|Bashkir|башҡорт теле|ba|bak|bak|bak|| 17 | Language isolate|Basque|euskara, euskera|eu|eus|baq|eus|| 18 | Indo-European|Belarusian|беларуская мова|be|bel|bel|bel|| 19 | Indo-European|Bengali, Bangla|বাংলা|bn|ben|ben|ben|| 20 | Indo-European|Bihari|भोजपुरी|bh|bih|bih|||Collective language code for Bhojpuri, Magahi, and Maithili 21 | Creole|Bislama|Bislama|bi|bis|bis|bis|| 22 | Indo-European|Bosnian|bosanski jezik|bs|bos|bos|bos|boss| 23 | Indo-European|Breton|brezhoneg|br|bre|bre|bre|| 24 | Indo-European|Bulgarian|български език|bg|bul|bul|bul|buls| 25 | Sino-Tibetan|Burmese|ဗမာစာ|my|mya|bur|mya|| 26 | Indo-European|Catalan|català|ca|cat|cat|cat|| 27 | Austronesian|Chamorro|Chamoru|ch|cha|cha|cha|| 28 | Northeast Caucasian|Chechen|нохчийн мотт|ce|che|che|che|| 29 | Niger–Congo|Chichewa, Chewa, Nyanja|chiCheŵa, chinyanja|ny|nya|nya|nya|| 30 | Sino-Tibetan|Chinese|中文 (Zhōngwén), 汉语, 漢語|zh|zho|chi|zho + 13||macrolanguage 31 | Turkic|Chuvash|чӑваш чӗлхи|cv|chv|chv|chv|| 32 | Indo-European|Cornish|Kernewek|kw|cor|cor|cor|| 33 | Indo-European|Corsican|corsu, lingua corsa|co|cos|cos|cos|| 34 | Algonquian|Cree|ᓀᐦᐃᔭᐍᐏᐣ|cr|cre|cre|cre + 6||macrolanguage 35 | Indo-European|Croatian|hrvatski jezik|hr|hrv|hrv|hrv|| 36 | Indo-European|Czech|čeština, český jazyk|cs|ces|cze|ces|| 37 | Indo-European|Danish|dansk|da|dan|dan|dan|| 38 | Indo-European|Divehi, Dhivehi, Maldivian|ދިވެހި|dv|div|div|div|| 39 | Indo-European|Dutch|Nederlands, Vlaams|nl|nld|dut|nld|| 40 | Sino-Tibetan|Dzongkha|རྫོང་ཁ|dz|dzo|dzo|dzo|| 41 | Indo-European|English|English|en|eng|eng|eng|engs| 42 | Constructed|Esperanto|Esperanto|eo|epo|epo|epo||constructed, initiated from L.L. Zamenhof, 1887 43 | Uralic|Estonian|eesti, eesti keel|et|est|est|est + 2||macrolanguage 44 | Niger–Congo|Ewe|Eʋegbe|ee|ewe|ewe|ewe|| 45 | Indo-European|Faroese|føroyskt|fo|fao|fao|fao|| 46 | Austronesian|Fijian|vosa Vakaviti|fj|fij|fij|fij|| 47 | Uralic|Finnish|suomi, suomen kieli|fi|fin|fin|fin|| 48 | Indo-European|French|français, langue française|fr|fra|fre|fra|fras| 49 | Niger–Congo|Fula, Fulah, Pulaar, Pular|Fulfulde, Pulaar, Pular|ff|ful|ful|ful + 9||macrolanguage 50 | Indo-European|Galician|galego|gl|glg|glg|glg|| 51 | South Caucasian|Georgian|ქართული|ka|kat|geo|kat|| 52 | Indo-European|German|Deutsch|de|deu|ger|deu|deus| 53 | Indo-European|Greek (modern)|ελληνικά|el|ell|gre|ell|ells| 54 | Tupian|Guaraní|Avañe'ẽ|gn|grn|grn|grn + 5||macrolanguage 55 | Indo-European|Gujarati|ગુજરાતી|gu|guj|guj|guj|| 56 | Creole|Haitian, Haitian Creole|Kreyòl ayisyen|ht|hat|hat|hat|| 57 | Afro-Asiatic|Hausa|(Hausa) هَوُسَ|ha|hau|hau|hau|| 58 | Afro-Asiatic|Hebrew (modern)|עברית|he|heb|heb|heb|| 59 | Niger–Congo|Herero|Otjiherero|hz|her|her|her|| 60 | Indo-European|Hindi|हिन्दी, हिंदी|hi|hin|hin|hin|hins| 61 | Austronesian|Hiri Motu|Hiri Motu|ho|hmo|hmo|hmo|| 62 | Uralic|Hungarian|magyar|hu|hun|hun|hun|| 63 | Constructed|Interlingua|Interlingua|ia|ina|ina|ina||constructed by International Auxiliary Language Association 64 | Austronesian|Indonesian|Bahasa Indonesia|id|ind|ind|ind||Covered by macrolanguage [ms/msa] 65 | Constructed|Interlingue|Originally called Occidental; then Interlingue after WWII|ie|ile|ile|ile||constructed by Edgar de Wahl, first published in 1922 66 | Indo-European|Irish|Gaeilge|ga|gle|gle|gle|| 67 | Niger–Congo|Igbo|Asụsụ Igbo|ig|ibo|ibo|ibo|| 68 | Eskimo–Aleut|Inupiaq|Iñupiaq, Iñupiatun|ik|ipk|ipk|ipk + 2||macrolanguage 69 | Constructed|Ido|Ido|io|ido|ido|ido|idos|constructed by De Beaufront, 1907, as variation of Esperanto 70 | Indo-European|Icelandic|Íslenska|is|isl|ice|isl|| 71 | Indo-European|Italian|italiano|it|ita|ita|ita|itas| 72 | Eskimo–Aleut|Inuktitut|ᐃᓄᒃᑎᑐᑦ|iu|iku|iku|iku + 2||macrolanguage 73 | Japonic|Japanese|日本語 (にほんご)|ja|jpn|jpn|jpn|| 74 | Austronesian|Javanese|basa Jawa|jv|jav|jav|jav|| 75 | Eskimo–Aleut|Kalaallisut, Greenlandic|kalaallisut, kalaallit oqaasii|kl|kal|kal|kal|| 76 | Dravidian|Kannada|ಕನ್ನಡ|kn|kan|kan|kan|| 77 | Nilo-Saharan|Kanuri|Kanuri|kr|kau|kau|kau + 3||macrolanguage 78 | Indo-European|Kashmiri|कश्मीरी, كشميري‎|ks|kas|kas|kas|| 79 | Turkic|Kazakh|қазақ тілі|kk|kaz|kaz|kaz|| 80 | Austroasiatic|Khmer|ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ|km|khm|khm|khm||a.k.a. Cambodian 81 | Niger–Congo|Kikuyu, Gikuyu|Gĩkũyũ|ki|kik|kik|kik|| 82 | Niger–Congo|Kinyarwanda|Ikinyarwanda|rw|kin|kin|kin|| 83 | Turkic|Kyrgyz|Кыргызча, Кыргыз тили|ky|kir|kir|kir|| 84 | Uralic|Komi|коми кыв|kv|kom|kom|kom + 2||macrolanguage 85 | Niger–Congo|Kongo|Kikongo|kg|kon|kon|kon + 3||macrolanguage 86 | Koreanic|Korean|한국어, 조선어|ko|kor|kor|kor|| 87 | Indo-European|Kurdish|Kurdî, كوردی‎|ku|kur|kur|kur + 3||macrolanguage 88 | Niger–Congo|Kwanyama, Kuanyama|Kuanyama|kj|kua|kua|kua|| 89 | Indo-European|Latin|latine, lingua latina|la|lat|lat|lat|lats|ancient 90 | Indo-European|Ladin|ladin, lingua ladina||||lld|| 91 | Indo-European|Luxembourgish, Letzeburgesch|Lëtzebuergesch|lb|ltz|ltz|ltz|| 92 | Niger–Congo|Ganda|Luganda|lg|lug|lug|lug|| 93 | Indo-European|Limburgish, Limburgan, Limburger|Limburgs|li|lim|lim|lim|| 94 | Niger–Congo|Lingala|Lingála|ln|lin|lin|lin|| 95 | Tai–Kadai|Lao|ພາສາລາວ|lo|lao|lao|lao|| 96 | Indo-European|Lithuanian|lietuvių kalba|lt|lit|lit|lit|| 97 | Niger–Congo|Luba-Katanga|Tshiluba|lu|lub|lub|lub|| 98 | Indo-European|Latvian|latviešu valoda|lv|lav|lav|lav + 2||macrolanguage 99 | Indo-European|Manx|Gaelg, Gailck|gv|glv|glv|glv|| 100 | Indo-European|Macedonian|македонски јазик|mk|mkd|mac|mkd|| 101 | Austronesian|Malagasy|fiteny malagasy|mg|mlg|mlg|mlg + 10||macrolanguage 102 | Austronesian|Malay|bahasa Melayu, بهاس ملايو‎|ms|msa|may|msa + 13||macrolanguage, Standard Malay is [zsm], Indonesian is [id/ind] 103 | Dravidian|Malayalam|മലയാളം|ml|mal|mal|mal|| 104 | Afro-Asiatic|Maltese|Malti|mt|mlt|mlt|mlt|| 105 | Austronesian|Māori|te reo Māori|mi|mri|mao|mri|| 106 | Indo-European|Marathi (Marāṭhī)|मराठी|mr|mar|mar|mar|| 107 | Austronesian|Marshallese|Kajin M̧ajeļ|mh|mah|mah|mah|| 108 | Mongolic|Mongolian|монгол|mn|mon|mon|mon + 2||macrolanguage 109 | Austronesian|Nauru|Ekakairũ Naoero|na|nau|nau|nau|| 110 | Dené–Yeniseian|Navajo, Navaho|Diné bizaad|nv|nav|nav|nav|| 111 | Niger–Congo|Northern Ndebele|isiNdebele|nd|nde|nde|nde|| 112 | Indo-European|Nepali|नेपाली|ne|nep|nep|nep|| 113 | Niger–Congo|Ndonga|Owambo|ng|ndo|ndo|ndo|| 114 | Indo-European|Norwegian Bokmål|Norsk bokmål|nb|nob|nob|nob||Covered by macrolanguage [no/nor] 115 | Indo-European|Norwegian Nynorsk|Norsk nynorsk|nn|nno|nno|nno||Covered by macrolanguage [no/nor] 116 | Indo-European|Norwegian|Norsk|no|nor|nor|nor + 2||macrolanguage, Bokmål is [nb/nob], Nynorsk is [nn/nno] 117 | Sino-Tibetan|Nuosu|ꆈꌠ꒿ Nuosuhxop|ii|iii|iii|iii||Standard form of Yi languages 118 | Niger–Congo|Southern Ndebele|isiNdebele|nr|nbl|nbl|nbl|| 119 | Indo-European|Occitan|occitan, lenga d'òc|oc|oci|oci|oci|| 120 | Algonquian|Ojibwe, Ojibwa|ᐊᓂᔑᓈᐯᒧᐎᓐ|oj|oji|oji|oji + 7||macrolanguage 121 | Indo-European|Old Church Slavonic, Church Slavonic, Old Bulgarian|ѩзыкъ словѣньскъ|cu|chu|chu|chu||ancient, in use by Orthodox Church 122 | Afro-Asiatic|Oromo|Afaan Oromoo|om|orm|orm|orm + 4||macrolanguage 123 | Indo-European|Oriya|ଓଡ଼ିଆ|or|ori|ori|ori|| 124 | Indo-European|Ossetian, Ossetic|ирон æвзаг|os|oss|oss|oss|| 125 | Indo-European|Panjabi, Punjabi|ਪੰਜਾਬੀ, پنجابی‎|pa|pan|pan|pan|| 126 | Indo-European|Pāli|पाऴि|pi|pli|pli|pli||ancient 127 | Indo-European|Persian (Farsi)|فارسی|fa|fas|per|fas + 2||macrolanguage 128 | Indo-European|Polish|język polski, polszczyzna|pl|pol|pol|pol|pols| 129 | Indo-European|Pashto, Pushto|پښتو|ps|pus|pus|pus + 3||macrolanguage 130 | Indo-European|Portuguese|português|pt|por|por|por|| 131 | Quechuan|Quechua|Runa Simi, Kichwa|qu|que|que|que + 44||macrolanguage 132 | Indo-European|Romansh|rumantsch grischun|rm|roh|roh|roh|| 133 | Niger–Congo|Kirundi|Ikirundi|rn|run|run|run|| 134 | Indo-European|Romanian|limba română|ro|ron|rum|ron||[mo] for Moldavian has been withdrawn, recommending [ro] also for Moldavian 135 | Indo-European|Russian|Русский|ru|rus|rus|rus|| 136 | Indo-European|Sanskrit (Saṁskṛta)|संस्कृतम्|sa|san|san|san||ancient, still spoken 137 | Indo-European|Sardinian|sardu|sc|srd|srd|srd + 4||macrolanguage 138 | Indo-European|Sindhi|सिन्धी, سنڌي، سندھی‎|sd|snd|snd|snd|| 139 | Uralic|Northern Sami|Davvisámegiella|se|sme|sme|sme|| 140 | Austronesian|Samoan|gagana fa'a Samoa|sm|smo|smo|smo|| 141 | Creole|Sango|yângâ tî sängö|sg|sag|sag|sag|| 142 | Indo-European|Serbian|српски језик|sr|srp|srp|srp||The ISO 639-2/T code srp deprecated the ISO 639-2/B code scc[1] 143 | Indo-European|Scottish Gaelic, Gaelic|Gàidhlig|gd|gla|gla|gla|| 144 | Niger–Congo|Shona|chiShona|sn|sna|sna|sna|| 145 | Indo-European|Sinhala, Sinhalese|සිංහල|si|sin|sin|sin|| 146 | Indo-European|Slovak|slovenčina, slovenský jazyk|sk|slk|slo|slk|| 147 | Indo-European|Slovene|slovenski jezik, slovenščina|sl|slv|slv|slv|| 148 | Afro-Asiatic|Somali|Soomaaliga, af Soomaali|so|som|som|som|| 149 | Niger–Congo|Southern Sotho|Sesotho|st|sot|sot|sot|| 150 | Indo-European|Spanish|español|es|spa|spa|spa|| 151 | Austronesian|Sundanese|Basa Sunda|su|sun|sun|sun|| 152 | Niger–Congo|Swahili|Kiswahili|sw|swa|swa|swa + 2||macrolanguage 153 | Niger–Congo|Swati|SiSwati|ss|ssw|ssw|ssw|| 154 | Indo-European|Swedish|svenska|sv|swe|swe|swe|| 155 | Dravidian|Tamil|தமிழ்|ta|tam|tam|tam|| 156 | Dravidian|Telugu|తెలుగు|te|tel|tel|tel|| 157 | Indo-European|Tajik|тоҷикӣ, toçikī, تاجیکی‎|tg|tgk|tgk|tgk|| 158 | Tai–Kadai|Thai|ไทย|th|tha|tha|tha|| 159 | Afro-Asiatic|Tigrinya|ትግርኛ|ti|tir|tir|tir|| 160 | Sino-Tibetan|Tibetan Standard, Tibetan, Central|བོད་ཡིག|bo|bod|tib|bod|| 161 | Turkic|Turkmen|Türkmen, Түркмен|tk|tuk|tuk|tuk|| 162 | Austronesian|Tagalog|Wikang Tagalog, ᜏᜒᜃᜅ᜔ ᜆᜄᜎᜓᜄ᜔|tl|tgl|tgl|tgl||Note: Filipino (Pilipino) has the code [fil] 163 | Niger–Congo|Tswana|Setswana|tn|tsn|tsn|tsn|| 164 | Austronesian|Tonga (Tonga Islands)|faka Tonga|to|ton|ton|ton|| 165 | Turkic|Turkish|Türkçe|tr|tur|tur|tur|| 166 | Niger–Congo|Tsonga|Xitsonga|ts|tso|tso|tso|| 167 | Turkic|Tatar|татар теле, tatar tele|tt|tat|tat|tat|| 168 | Niger–Congo|Twi|Twi|tw|twi|twi|twi||Covered by macrolanguage [ak/aka] 169 | Austronesian|Tahitian|Reo Tahiti|ty|tah|tah|tah||One of the Reo Mā`ohi (languages of French Polynesia) 170 | Turkic|Uyghur|ئۇيغۇرچە‎, Uyghurche|ug|uig|uig|uig|| 171 | Indo-European|Ukrainian|українська мова|uk|ukr|ukr|ukr|| 172 | Indo-European|Urdu|اردو|ur|urd|urd|urd|| 173 | Turkic|Uzbek|Oʻzbek, Ўзбек, أۇزبېك‎|uz|uzb|uzb|uzb + 2||macrolanguage 174 | Niger–Congo|Venda|Tshivenḓa|ve|ven|ven|ven|| 175 | Austroasiatic|Vietnamese|Việt Nam|vi|vie|vie|vie|| 176 | Constructed|Volapük|Volapük|vo|vol|vol|vol||constructed 177 | Indo-European|Walloon|walon|wa|wln|wln|wln|| 178 | Indo-European|Welsh|Cymraeg|cy|cym|wel|cym|| 179 | Niger–Congo|Wolof|Wollof|wo|wol|wol|wol|| 180 | Indo-European|Western Frisian|Frysk|fy|fry|fry|fry|| 181 | Niger–Congo|Xhosa|isiXhosa|xh|xho|xho|xho|| 182 | Indo-European|Yiddish|ייִדיש|yi|yid|yid|yid + 2||macrolanguage 183 | Niger–Congo|Yoruba|Yorùbá|yo|yor|yor|yor|| 184 | Tai–Kadai|Zhuang, Chuang|Saɯ cueŋƅ, Saw cuengh|za|zha|zha|zha + 16||macrolanguage 185 | Niger–Congo|Zulu|isiZulu|zu|zul|zul|zul|| -------------------------------------------------------------------------------- /src/ISO639.php: -------------------------------------------------------------------------------- 1 | languages; 212 | } 213 | 214 | /* 215 | * Get language name from ISO-639-1 (two-letters code) 216 | */ 217 | public function languageByCode1($code): string 218 | { 219 | $code = strtolower(trim($code)); 220 | 221 | foreach ($this->languages as $lang) { 222 | if ($lang[$this->indexIso639_1] === $code) { 223 | return $lang[$this->indexEnglishName]; 224 | } 225 | } 226 | 227 | return ''; 228 | } 229 | 230 | /* 231 | * Get native language name from ISO-639-1 (two-letters code) 232 | */ 233 | public function nativeByCode1($code): string 234 | { 235 | $code = strtolower(trim($code)); 236 | 237 | foreach ($this->languages as $lang) { 238 | if ($lang[$this->indexIso639_1] === $code) { 239 | return $lang[$this->indexNativeName]; 240 | } 241 | } 242 | 243 | return ''; 244 | } 245 | 246 | /* 247 | * Get language name from ISO-639-2/t (three-letter codes) terminologic 248 | */ 249 | public function languageByCode2t($code): string 250 | { 251 | $code = strtolower(trim($code)); 252 | 253 | foreach ($this->languages as $lang) { 254 | if ($lang[$this->indexIso639_2t] === $code) { 255 | return $lang[$this->indexEnglishName]; 256 | } 257 | } 258 | 259 | return ''; 260 | } 261 | 262 | /* 263 | * Get native language name from ISO-639-2/t (three-letter codes) terminologic 264 | */ 265 | public function nativeByCode2t($code): string 266 | { 267 | $code = strtolower(trim($code)); 268 | 269 | foreach ($this->languages as $lang) { 270 | if ($lang[$this->indexIso639_2t] === $code) { 271 | return $lang[$this->indexNativeName]; 272 | } 273 | } 274 | 275 | return ''; 276 | } 277 | 278 | /* 279 | * Get language name from ISO-639-2/b (three-letter codes) bibliographic 280 | */ 281 | public function languageByCode2b($code): string 282 | { 283 | $code = strtolower(trim($code)); 284 | 285 | foreach ($this->languages as $lang) { 286 | if ($lang[$this->indexIso639_2b] === $code) { 287 | return $lang[$this->indexEnglishName]; 288 | } 289 | } 290 | 291 | return ''; 292 | } 293 | 294 | /* 295 | * Get native language name from ISO-639-2/b (three-letter codes) bibliographic 296 | */ 297 | public function nativeByCode2b($code): string 298 | { 299 | $code = strtolower(trim($code)); 300 | 301 | foreach ($this->languages as $lang) { 302 | if ($lang[$this->indexIso639_2b] === $code) { 303 | return $lang[$this->indexNativeName]; 304 | } 305 | } 306 | 307 | return ''; 308 | } 309 | 310 | /* 311 | * Get language name from ISO-639-3 (three-letter codes) 312 | */ 313 | public function languageByCode3($code): string 314 | { 315 | $code = strtolower(trim($code)); 316 | 317 | foreach ($this->languages as $lang) { 318 | if ($lang[$this->indexIso639_3] === $code) { 319 | return $lang[$this->indexEnglishName]; 320 | } 321 | } 322 | 323 | return ''; 324 | } 325 | 326 | /* 327 | * Get native language name from ISO-639-3 (three-letter codes) 328 | */ 329 | public function nativeByCode3($code): string 330 | { 331 | $code = strtolower(trim($code)); 332 | 333 | foreach ($this->languages as $lang) { 334 | if ($lang[$this->indexIso639_3] === $code) { 335 | return $lang[$this->indexNativeName]; 336 | } 337 | } 338 | 339 | return ''; 340 | } 341 | 342 | /* 343 | * Get ISO-639-1 (two-letters code) from language name 344 | */ 345 | public function code1ByLanguage($language): string 346 | { 347 | $language_key = ucwords(strtolower($language)); 348 | 349 | foreach ($this->languages as $lang) { 350 | if (in_array($language_key, explode(', ', $lang[$this->indexEnglishName]))) { 351 | return $lang[$this->indexIso639_1]; 352 | } 353 | } 354 | 355 | return ''; 356 | } 357 | 358 | /* 359 | * Get ISO-639-2/t (three-letter codes) terminologic from language name 360 | */ 361 | public function code2tByLanguage($language): string 362 | { 363 | $language_key = ucwords(strtolower($language)); 364 | 365 | 366 | foreach ($this->languages as $lang) { 367 | if (in_array($language_key, explode(', ', $lang[$this->indexEnglishName]))) { 368 | return $lang[$this->indexIso639_2t]; 369 | } 370 | } 371 | 372 | return ''; 373 | } 374 | 375 | /* 376 | * Get ISO-639-2/b (three-letter codes) bibliographic from language name 377 | */ 378 | public function code2bByLanguage($language): string 379 | { 380 | $language_key = ucwords(strtolower($language)); 381 | 382 | foreach ($this->languages as $lang) { 383 | if (in_array($language_key, explode(', ', $lang[$this->indexEnglishName]))) { 384 | return $lang[$this->indexIso639_2b]; 385 | } 386 | } 387 | 388 | return ''; 389 | } 390 | 391 | /* 392 | * Get ISO-639-3 (three-letter codes) from language name 393 | */ 394 | public function code3ByLanguage($language): string 395 | { 396 | $language_key = ucwords(strtolower($language)); 397 | 398 | foreach ($this->languages as $lang) { 399 | if (in_array($language_key, explode(', ', $lang[$this->indexEnglishName]))) { 400 | return $lang[$this->indexIso639_3]; 401 | } 402 | } 403 | 404 | return ''; 405 | } 406 | 407 | /** 408 | * Gat language array from ISO-639-2/b (three-letter code) 409 | */ 410 | public function getLanguageByIsoCode2b(string $code): ?array 411 | { 412 | $code = strtolower(trim($code)); 413 | 414 | foreach ($this->languages as $lang) { 415 | if ($lang[$this->indexIso639_2b] === $code) { 416 | return $lang; 417 | } 418 | } 419 | 420 | return null; 421 | } 422 | 423 | /** 424 | * Get ISO-639-2t code from ISO-639-1 code 425 | */ 426 | public function code2tByCode1(string $code): string 427 | { 428 | $code = strtolower($code); 429 | 430 | $result = ''; 431 | 432 | foreach ($this->languages as $lang) { 433 | if($lang[0] === $code) { 434 | $result = $lang[1]; 435 | break; 436 | } 437 | } 438 | 439 | return $result; 440 | } 441 | 442 | } 443 | -------------------------------------------------------------------------------- /tests/ISO639Test.php: -------------------------------------------------------------------------------- 1 | iso = new ISO639(); 11 | } 12 | 13 | public function testLanguageISO6391() 14 | { 15 | $this->assertSame('English', $this->iso->languageByCode1('en')); 16 | $this->assertSame('French', $this->iso->languageByCode1('fr')); 17 | $this->assertSame('Spanish', $this->iso->languageByCode1('es')); 18 | $this->assertSame('Indonesian', $this->iso->languageByCode1('id')); 19 | $this->assertSame('Javanese', $this->iso->languageByCode1('jv')); 20 | $this->assertSame('Hindi', $this->iso->languageByCode1('hi')); 21 | $this->assertSame('Thai', $this->iso->languageByCode1('th')); 22 | $this->assertSame('Korean', $this->iso->languageByCode1('ko')); 23 | $this->assertSame('Japanese', $this->iso->languageByCode1('ja')); 24 | $this->assertSame('Chinese', $this->iso->languageByCode1('zh')); 25 | $this->assertSame('Russian', $this->iso->languageByCode1('ru')); 26 | $this->assertSame('Arabic', $this->iso->languageByCode1('ar')); 27 | $this->assertSame('Vietnamese', $this->iso->languageByCode1('vi')); 28 | $this->assertSame('Malay', $this->iso->languageByCode1('ms')); 29 | $this->assertSame('Sundanese', $this->iso->languageByCode1('su')); 30 | } 31 | 32 | public function testNativeISO6391() 33 | { 34 | $this->assertSame('English', $this->iso->nativeByCode1('en')); 35 | $this->assertSame('français, langue française', $this->iso->nativeByCode1('fr')); 36 | $this->assertSame('español', $this->iso->nativeByCode1('es')); 37 | $this->assertSame('Bahasa Indonesia', $this->iso->nativeByCode1('id')); 38 | $this->assertSame('basa Jawa', $this->iso->nativeByCode1('jv')); 39 | $this->assertSame('हिन्दी, हिंदी', $this->iso->nativeByCode1('hi')); 40 | $this->assertSame('ไทย', $this->iso->nativeByCode1('th')); 41 | $this->assertSame('한국어', $this->iso->nativeByCode1('ko')); 42 | $this->assertSame('日本語 (にほんご)', $this->iso->nativeByCode1('ja')); 43 | $this->assertSame('中文 (Zhōngwén), 汉语, 漢語', $this->iso->nativeByCode1('zh')); 44 | $this->assertSame('Русский', $this->iso->nativeByCode1('ru')); 45 | $this->assertSame('العربية', $this->iso->nativeByCode1('ar')); 46 | $this->assertSame('Việt Nam', $this->iso->nativeByCode1('vi')); 47 | $this->assertSame('bahasa Melayu, بهاس ملايو‎', $this->iso->nativeByCode1('ms')); 48 | $this->assertSame('Basa Sunda', $this->iso->nativeByCode1('su')); 49 | } 50 | 51 | public function testLanguageISO6392t() 52 | { 53 | $this->assertSame('English', $this->iso->languageByCode2t('eng')); 54 | $this->assertSame('French', $this->iso->languageByCode2t('fra')); 55 | $this->assertSame('Spanish', $this->iso->languageByCode2t('spa')); 56 | $this->assertSame('Indonesian', $this->iso->languageByCode2t('ind')); 57 | $this->assertSame('Javanese', $this->iso->languageByCode2t('jav')); 58 | $this->assertSame('Hindi', $this->iso->languageByCode2t('hin')); 59 | $this->assertSame('Thai', $this->iso->languageByCode2t('tha')); 60 | $this->assertSame('Korean', $this->iso->languageByCode2t('kor')); 61 | $this->assertSame('Japanese', $this->iso->languageByCode2t('jpn')); 62 | $this->assertSame('Chinese', $this->iso->languageByCode2t('zho')); 63 | $this->assertSame('Russian', $this->iso->languageByCode2t('rus')); 64 | $this->assertSame('Arabic', $this->iso->languageByCode2t('ara')); 65 | $this->assertSame('Vietnamese', $this->iso->languageByCode2t('vie')); 66 | $this->assertSame('Malay', $this->iso->languageByCode2t('msa')); 67 | $this->assertSame('Sundanese', $this->iso->languageByCode2t('sun')); 68 | } 69 | 70 | public function testNativeISO6392t() 71 | { 72 | $this->assertSame('English', $this->iso->nativeByCode2t('eng')); 73 | $this->assertSame('français, langue française', $this->iso->nativeByCode2t('fra')); 74 | $this->assertSame('español', $this->iso->nativeByCode2t('spa')); 75 | $this->assertSame('Bahasa Indonesia', $this->iso->nativeByCode2t('ind')); 76 | $this->assertSame('basa Jawa', $this->iso->nativeByCode2t('jav')); 77 | $this->assertSame('हिन्दी, हिंदी', $this->iso->nativeByCode2t('hin')); 78 | $this->assertSame('ไทย', $this->iso->nativeByCode2t('tha')); 79 | $this->assertSame('한국어', $this->iso->nativeByCode2t('kor')); 80 | $this->assertSame('日本語 (にほんご)', $this->iso->nativeByCode2t('jpn')); 81 | $this->assertSame('中文 (Zhōngwén), 汉语, 漢語', $this->iso->nativeByCode2t('zho')); 82 | $this->assertSame('Русский', $this->iso->nativeByCode2t('rus')); 83 | $this->assertSame('العربية', $this->iso->nativeByCode2t('ara')); 84 | $this->assertSame('Việt Nam', $this->iso->nativeByCode2t('vie')); 85 | $this->assertSame('bahasa Melayu, بهاس ملايو‎', $this->iso->nativeByCode2t('msa')); 86 | $this->assertSame('Basa Sunda', $this->iso->nativeByCode2t('sun')); 87 | } 88 | 89 | public function testLanguageISO6392b() 90 | { 91 | $this->assertSame('English', $this->iso->languageByCode2b('eng')); 92 | $this->assertSame('French', $this->iso->languageByCode2b('fre')); 93 | $this->assertSame('Spanish', $this->iso->languageByCode2b('spa')); 94 | $this->assertSame('Indonesian', $this->iso->languageByCode2b('ind')); 95 | $this->assertSame('Javanese', $this->iso->languageByCode2b('jav')); 96 | $this->assertSame('Hindi', $this->iso->languageByCode2b('hin')); 97 | $this->assertSame('Thai', $this->iso->languageByCode2b('tha')); 98 | $this->assertSame('Korean', $this->iso->languageByCode2b('kor')); 99 | $this->assertSame('Japanese', $this->iso->languageByCode2b('jpn')); 100 | $this->assertSame('Chinese', $this->iso->languageByCode2b('chi')); 101 | $this->assertSame('Russian', $this->iso->languageByCode2b('rus')); 102 | $this->assertSame('Arabic', $this->iso->languageByCode2b('ara')); 103 | $this->assertSame('Vietnamese', $this->iso->languageByCode2b('vie')); 104 | $this->assertSame('Malay', $this->iso->languageByCode2b('may')); 105 | $this->assertSame('Sundanese', $this->iso->languageByCode2b('sun')); 106 | } 107 | 108 | public function testNativeISO6392b() 109 | { 110 | $this->assertSame('English', $this->iso->nativeByCode2b('eng')); 111 | $this->assertSame('français, langue française', $this->iso->nativeByCode2b('fre')); 112 | $this->assertSame('español', $this->iso->nativeByCode2b('spa')); 113 | $this->assertSame('Bahasa Indonesia', $this->iso->nativeByCode2b('ind')); 114 | $this->assertSame('basa Jawa', $this->iso->nativeByCode2b('jav')); 115 | $this->assertSame('हिन्दी, हिंदी', $this->iso->nativeByCode2b('hin')); 116 | $this->assertSame('ไทย', $this->iso->nativeByCode2b('tha')); 117 | $this->assertSame('한국어', $this->iso->nativeByCode2b('kor')); 118 | $this->assertSame('日本語 (にほんご)', $this->iso->nativeByCode2b('jpn')); 119 | $this->assertSame('中文 (Zhōngwén), 汉语, 漢語', $this->iso->nativeByCode2b('chi')); 120 | $this->assertSame('Русский', $this->iso->nativeByCode2b('rus')); 121 | $this->assertSame('العربية', $this->iso->nativeByCode2b('ara')); 122 | $this->assertSame('Việt Nam', $this->iso->nativeByCode2b('vie')); 123 | $this->assertSame('bahasa Melayu, بهاس ملايو‎', $this->iso->nativeByCode2b('may')); 124 | $this->assertSame('Basa Sunda', $this->iso->nativeByCode2b('sun')); 125 | } 126 | 127 | public function testLanguageISO6393() 128 | { 129 | $this->assertSame('English', $this->iso->languageByCode3('eng')); 130 | $this->assertSame('French', $this->iso->languageByCode3('fra')); 131 | $this->assertSame('Spanish', $this->iso->languageByCode3('spa')); 132 | $this->assertSame('Indonesian', $this->iso->languageByCode3('ind')); 133 | $this->assertSame('Javanese', $this->iso->languageByCode3('jav')); 134 | $this->assertSame('Hindi', $this->iso->languageByCode3('hin')); 135 | $this->assertSame('Thai', $this->iso->languageByCode3('tha')); 136 | $this->assertSame('Korean', $this->iso->languageByCode3('kor')); 137 | $this->assertSame('Japanese', $this->iso->languageByCode3('jpn')); 138 | $this->assertSame('Chinese', $this->iso->languageByCode3('zho')); 139 | $this->assertSame('Russian', $this->iso->languageByCode3('rus')); 140 | $this->assertSame('Arabic', $this->iso->languageByCode3('ara')); 141 | $this->assertSame('Vietnamese', $this->iso->languageByCode3('vie')); 142 | $this->assertSame('Malay', $this->iso->languageByCode3('msa')); 143 | $this->assertSame('Sundanese', $this->iso->languageByCode3('sun')); 144 | } 145 | 146 | public function testNativeISO6393() 147 | { 148 | $this->assertSame('English', $this->iso->nativeByCode3('eng')); 149 | $this->assertSame('français, langue française', $this->iso->nativeByCode3('fra')); 150 | $this->assertSame('español', $this->iso->nativeByCode3('spa')); 151 | $this->assertSame('Bahasa Indonesia', $this->iso->nativeByCode3('ind')); 152 | $this->assertSame('basa Jawa', $this->iso->nativeByCode3('jav')); 153 | $this->assertSame('हिन्दी, हिंदी', $this->iso->nativeByCode3('hin')); 154 | $this->assertSame('ไทย', $this->iso->nativeByCode3('tha')); 155 | $this->assertSame('한국어', $this->iso->nativeByCode3('kor')); 156 | $this->assertSame('日本語 (にほんご)', $this->iso->nativeByCode3('jpn')); 157 | $this->assertSame('中文 (Zhōngwén), 汉语, 漢語', $this->iso->nativeByCode3('zho')); 158 | $this->assertSame('Русский', $this->iso->nativeByCode3('rus')); 159 | $this->assertSame('العربية', $this->iso->nativeByCode3('ara')); 160 | $this->assertSame('Việt Nam', $this->iso->nativeByCode3('vie')); 161 | $this->assertSame('bahasa Melayu, بهاس ملايو‎', $this->iso->nativeByCode3('msa')); 162 | $this->assertSame('Basa Sunda', $this->iso->nativeByCode3('sun')); 163 | } 164 | 165 | public function testISO6391Language() 166 | { 167 | $this->assertSame('en', $this->iso->code1ByLanguage('English')); 168 | $this->assertSame('fr', $this->iso->code1ByLanguage('French')); 169 | $this->assertSame('es', $this->iso->code1ByLanguage('Spanish')); 170 | $this->assertSame('id', $this->iso->code1ByLanguage('Indonesian')); 171 | $this->assertSame('jv', $this->iso->code1ByLanguage('Javanese')); 172 | $this->assertSame('hi', $this->iso->code1ByLanguage('Hindi')); 173 | $this->assertSame('th', $this->iso->code1ByLanguage('Thai')); 174 | $this->assertSame('ko', $this->iso->code1ByLanguage('Korean')); 175 | $this->assertSame('ja', $this->iso->code1ByLanguage('Japanese')); 176 | $this->assertSame('zh', $this->iso->code1ByLanguage('Chinese')); 177 | $this->assertSame('ru', $this->iso->code1ByLanguage('Russian')); 178 | $this->assertSame('ar', $this->iso->code1ByLanguage('Arabic')); 179 | $this->assertSame('vi', $this->iso->code1ByLanguage('Vietnamese')); 180 | $this->assertSame('ms', $this->iso->code1ByLanguage('Malay')); 181 | $this->assertSame('su', $this->iso->code1ByLanguage('Sundanese')); 182 | } 183 | 184 | public function testISO6392tLanguage() 185 | { 186 | $this->assertSame('eng', $this->iso->code2tByLanguage('English')); 187 | $this->assertSame('fra', $this->iso->code2tByLanguage('French')); 188 | $this->assertSame('spa', $this->iso->code2tByLanguage('Spanish')); 189 | $this->assertSame('ind', $this->iso->code2tByLanguage('Indonesian')); 190 | $this->assertSame('jav', $this->iso->code2tByLanguage('Javanese')); 191 | $this->assertSame('hin', $this->iso->code2tByLanguage('Hindi')); 192 | $this->assertSame('tha', $this->iso->code2tByLanguage('Thai')); 193 | $this->assertSame('kor', $this->iso->code2tByLanguage('Korean')); 194 | $this->assertSame('jpn', $this->iso->code2tByLanguage('Japanese')); 195 | $this->assertSame('zho', $this->iso->code2tByLanguage('Chinese')); 196 | $this->assertSame('rus', $this->iso->code2tByLanguage('Russian')); 197 | $this->assertSame('ara', $this->iso->code2tByLanguage('Arabic')); 198 | $this->assertSame('vie', $this->iso->code2tByLanguage('Vietnamese')); 199 | $this->assertSame('msa', $this->iso->code2tByLanguage('Malay')); 200 | $this->assertSame('sun', $this->iso->code2tByLanguage('Sundanese')); 201 | } 202 | 203 | public function testISO6392bLanguage() 204 | { 205 | $this->assertSame('eng', $this->iso->code2bByLanguage('English')); 206 | $this->assertSame('fre', $this->iso->code2bByLanguage('French')); 207 | $this->assertSame('spa', $this->iso->code2bByLanguage('Spanish')); 208 | $this->assertSame('ind', $this->iso->code2bByLanguage('Indonesian')); 209 | $this->assertSame('jav', $this->iso->code2bByLanguage('Javanese')); 210 | $this->assertSame('hin', $this->iso->code2bByLanguage('Hindi')); 211 | $this->assertSame('tha', $this->iso->code2bByLanguage('Thai')); 212 | $this->assertSame('kor', $this->iso->code2bByLanguage('Korean')); 213 | $this->assertSame('jpn', $this->iso->code2bByLanguage('Japanese')); 214 | $this->assertSame('chi', $this->iso->code2bByLanguage('Chinese')); 215 | $this->assertSame('rus', $this->iso->code2bByLanguage('Russian')); 216 | $this->assertSame('ara', $this->iso->code2bByLanguage('Arabic')); 217 | $this->assertSame('vie', $this->iso->code2bByLanguage('Vietnamese')); 218 | $this->assertSame('may', $this->iso->code2bByLanguage('Malay')); 219 | $this->assertSame('sun', $this->iso->code2bByLanguage('Sundanese')); 220 | } 221 | 222 | public function testISO6393Language() 223 | { 224 | $this->assertSame('eng', $this->iso->code3ByLanguage('English')); 225 | $this->assertSame('fra', $this->iso->code3ByLanguage('French')); 226 | $this->assertSame('spa', $this->iso->code3ByLanguage('Spanish')); 227 | $this->assertSame('ind', $this->iso->code3ByLanguage('Indonesian')); 228 | $this->assertSame('jav', $this->iso->code3ByLanguage('Javanese')); 229 | $this->assertSame('hin', $this->iso->code3ByLanguage('Hindi')); 230 | $this->assertSame('tha', $this->iso->code3ByLanguage('Thai')); 231 | $this->assertSame('kor', $this->iso->code3ByLanguage('Korean')); 232 | $this->assertSame('jpn', $this->iso->code3ByLanguage('Japanese')); 233 | $this->assertSame('zho', $this->iso->code3ByLanguage('Chinese')); 234 | $this->assertSame('rus', $this->iso->code3ByLanguage('Russian')); 235 | $this->assertSame('ara', $this->iso->code3ByLanguage('Arabic')); 236 | $this->assertSame('vie', $this->iso->code3ByLanguage('Vietnamese')); 237 | $this->assertSame('msa', $this->iso->code3ByLanguage('Malay')); 238 | $this->assertSame('sun', $this->iso->code3ByLanguage('Sundanese')); 239 | } 240 | 241 | public function testGetLanguageByIsoCode2B() 242 | { 243 | $result = ['en', 'eng', 'eng', 'eng', 'English', 'English']; 244 | $this->assertSame($result, $this->iso->getLanguageByIsoCode2b('eng')); 245 | $result = ['fr', 'fra', 'fre', 'fra', 'French', 'français, langue française']; 246 | $this->assertSame($result, $this->iso->getLanguageByIsoCode2b('fre')); 247 | $result = ['id', 'ind', 'ind', 'ind', 'Indonesian', 'Bahasa Indonesia']; 248 | $this->assertSame($result, $this->iso->getLanguageByIsoCode2b('ind')); 249 | 250 | $this->assertNull($this->iso->getLanguageByIsoCode2b('null')); 251 | } 252 | 253 | public function testCode2tByCode1() 254 | { 255 | $this->assertSame('fra', $this->iso->code2tByCode1('fr')); 256 | $this->assertSame('eng', $this->iso->code2tByCode1('en')); 257 | $this->assertSame('spa', $this->iso->code2tByCode1('es')); 258 | $this->assertSame('ind', $this->iso->code2tByCode1('id')); 259 | } 260 | 261 | } 262 | --------------------------------------------------------------------------------