{"id":15046089,"url":"https://github.com/josantonius/php-language-code","last_synced_at":"2025-07-19T17:06:59.494Z","repository":{"id":53382824,"uuid":"78793519","full_name":"josantonius/php-language-code","owner":"josantonius","description":"PHP library to get language name from language code","archived":false,"fork":false,"pushed_at":"2022-09-29T17:41:48.000Z","size":1168,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T10:25:29.977Z","etag":null,"topics":["composer","iso639-1","language-code","language-codes","php"],"latest_commit_sha":null,"homepage":"https://josantonius.dev","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/josantonius.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["Josantonius"]}},"created_at":"2017-01-12T22:41:48.000Z","updated_at":"2022-11-17T22:42:42.000Z","dependencies_parsed_at":"2022-09-05T01:00:20.145Z","dependency_job_id":null,"html_url":"https://github.com/josantonius/php-language-code","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josantonius%2Fphp-language-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josantonius%2Fphp-language-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josantonius%2Fphp-language-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/josantonius%2Fphp-language-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/josantonius","download_url":"https://codeload.github.com/josantonius/php-language-code/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238207646,"owners_count":19434095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer","iso639-1","language-code","language-codes","php"],"created_at":"2024-09-24T20:52:41.574Z","updated_at":"2025-02-10T23:31:37.086Z","avatar_url":"https://github.com/josantonius.png","language":"PHP","funding_links":["https://github.com/sponsors/Josantonius"],"categories":[],"sub_categories":[],"readme":"# PHP LanguageCode library\n\n[![Latest Stable Version](https://poser.pugx.org/josantonius/language-code/v/stable)](https://packagist.org/packages/josantonius/language-code)\n[![License](https://poser.pugx.org/josantonius/language-code/license)](LICENSE)\n[![Total Downloads](https://poser.pugx.org/josantonius/language-code/downloads)](https://packagist.org/packages/josantonius/language-code)\n[![CI](https://github.com/josantonius/php-language-code/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/josantonius/php-language-code/actions/workflows/ci.yml)\n[![CodeCov](https://codecov.io/gh/josantonius/php-language-code/branch/main/graph/badge.svg)](https://codecov.io/gh/josantonius/php-language-code)\n[![PSR1](https://img.shields.io/badge/PSR-1-f57046.svg)](https://www.php-fig.org/psr/psr-1/)\n[![PSR4](https://img.shields.io/badge/PSR-4-9b59b6.svg)](https://www.php-fig.org/psr/psr-4/)\n[![PSR12](https://img.shields.io/badge/PSR-12-1abc9c.svg)](https://www.php-fig.org/psr/psr-12/)\n\n**Translations**: [Español](.github/lang/es-ES/README.md)\n\nPHP library to get language name from code.\n\n---\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Available Classes](#available-classes)\n  - [LanguageCode Class](#languagecode-class)\n  - [LanguageCodeCollection Class](#languagecodecollection-class)\n- [Usage](#usage)\n- [List in JSON format](#list-in-json-format)\n- [Tests](#tests)\n- [TODO](#todo)\n- [Changelog](#changelog)\n- [Contribution](#contribution)\n- [Sponsor](#sponsor)\n- [License](#license)\n\n---\n\n## Requirements\n\nOperating System: Linux | Windows.\n\nPHP versions: 8.0 | 8.1 | 8.2.\n\n## Installation\n\nThe preferred way to install this extension is through [Composer](http://getcomposer.org/download/).\n\nTo install **PHP LanguageCode library**, simply:\n\n```console\ncomposer require josantonius/language-code\n```\n\nThe previous command will only install the necessary files,\nif you prefer to **download the entire source code** you can use:\n\n```console\ncomposer require josantonius/language-code --prefer-source\n```\n\nYou can also **clone the complete repository** with Git:\n\n```console\nclone https://github.com/josantonius/php-language-code.git\n```\n\n## Available Classes\n\n### LanguageCode Class\n\n`Josantonius\\LanguageCode\\LanguageCode`\n\nGet all language codes as array:\n\n```php\npublic static function all(): array;\n```\n\nGet language code from language name:\n\n```php\npublic static function getCode(string $languageName): string|null;\n```\n\nGet language name from language code:\n\n```php\npublic static function getName(string $languageCode): string|null;\n```\n\n### LanguageCodeCollection Class\n\n`Josantonius\\LanguageCode\\LanguageCodeCollection`\n\nGet all language codes as array:\n\n```php\npublic static function all(): array\n```\n\nGet language code from language name:\n\n```php\npublic static function getCode(string $languageName): string|null\n```\n\nGet language name from language code:\n\n```php\npublic static function getName(string $languageCode): string|null\n```\n\n## Usage\n\nExample of use for this library:\n\n### Get all language codes as array\n\n```php\nuse Josantonius\\LanguageCode\\LanguageCode;\n\n$languageCode = new LanguageCode();\n\n$languageCode-\u003eall();\n```\n\n```php\nuse Josantonius\\LanguageCode\\LanguageCodeCollection;\n\nLanguageCodeCollection::all();\n```\n\nResult:\n\n```php\n[\n    'aa' =\u003e 'Afar',\n    'ab' =\u003e 'Abkhazian',\n    'af' =\u003e 'Afrikaans',\n    'am' =\u003e 'Amharic',\n    'ar' =\u003e 'Arabic',\n    'ar-ae' =\u003e 'Arabic (U.A.E.)',\n    'ar-bh' =\u003e 'Arabic (Bahrain)',\n    'ar-dz' =\u003e 'Arabic (Algeria)',\n    'ar-eg' =\u003e 'Arabic (Egypt)',\n    'ar-iq' =\u003e 'Arabic (Iraq)',\n    (...)\n]\n```\n\n### Get language code from language name\n\n```php\nuse Josantonius\\LanguageCode\\LanguageCode;\n\n$languageCode = new LanguageCode();\n\n$languageCode-\u003egetCode('Spanish'); // es\n```\n\n```php\nuse Josantonius\\LanguageCode\\LanguageCodeCollection;\n\nLanguageCodeCollection::getCode('Turkish'); // tr\n```\n\n### Get language name from language code\n\n```php\nuse Josantonius\\LanguageCode\\LanguageCode;\n\n$languageCode = new LanguageCode();\n\n$languageCode-\u003egetName('eo'); // Esperanto\n```\n\n```php\nuse Josantonius\\LanguageCode\\LanguageCodeCollection;\n\nLanguageCodeCollection::getName('de'); // German\n```\n\n## List in JSON format\n\n[Go to the resource](https://gist.github.com/josantonius/b455e315bc7f790d14b136d61d9ae469).\n\n## Tests\n\nTo run [tests](tests) you just need [composer](http://getcomposer.org/download/)\nand to execute the following:\n\n```console\ngit clone https://github.com/josantonius/php-language-code.git\n```\n\n```console\ncd php-language-code\n\n```\n\n```console\ncomposer install\n```\n\nRun unit tests with [PHPUnit](https://phpunit.de/):\n\n```console\ncomposer phpunit\n```\n\nRun code standard tests with [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer):\n\n```console\ncomposer phpcs\n```\n\nRun [PHP Mess Detector](https://phpmd.org/) tests to detect inconsistencies in code style:\n\n```console\ncomposer phpmd\n```\n\nRun all previous tests:\n\n```console\ncomposer tests\n```\n\n## TODO\n\n- [ ] Add new feature\n- [ ] Improve tests\n- [ ] Improve documentation\n- [ ] Improve English translation in the README file\n- [ ] Refactor code for disabled code style rules (see phpmd.xml and phpcs.xml)\n\n## Changelog\n\nDetailed changes for each release are documented in the\n[release notes](https://github.com/josantonius/php-language-code/releases).\n\n## Contribution\n\nPlease make sure to read the [Contributing Guide](.github/CONTRIBUTING.md), before making a pull\nrequest, start a discussion or report a issue.\n\nThanks to all [contributors](https://github.com/josantonius/php-language-code/graphs/contributors)! :heart:\n\n## Sponsor\n\nIf this project helps you to reduce your development time,\n[you can sponsor me](https://github.com/josantonius#sponsor) to support my open source work :blush:\n\n## License\n\nThis repository is licensed under the [MIT License](LICENSE).\n\nCopyright © 2017-present, [Josantonius](https://github.com/josantonius#contact)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosantonius%2Fphp-language-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjosantonius%2Fphp-language-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjosantonius%2Fphp-language-code/lists"}