2017 © Pedro Peláez
 

library languagecode

List of 217 language codes: ISO 639-1.

image

josantonius/languagecode

List of 217 language codes: ISO 639-1.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 33 % Grown

The README.md

PHP LanguageCode library

Latest Stable Version License Total Downloads CI CodeCov PSR1 PSR4 PSR12, (*1)

Translations: Español, (*2)

PHP library to get language name from code., (*3)



Requirements

Operating System: Linux | Windows., (*4)

PHP versions: 8.0 | 8.1 | 8.2., (*5)

Installation

The preferred way to install this extension is through Composer., (*6)

To install PHP LanguageCode library, simply:, (*7)

composer require josantonius/language-code

The previous command will only install the necessary files, if you prefer to download the entire source code you can use:, (*8)

composer require josantonius/language-code --prefer-source

You can also clone the complete repository with Git:, (*9)

clone https://github.com/josantonius/php-language-code.git

Available Classes

LanguageCode Class

Josantonius\LanguageCode\LanguageCode, (*10)

Get all language codes as array:, (*11)

public static function all(): array;

Get language code from language name:, (*12)

public static function getCode(string $languageName): string|null;

Get language name from language code:, (*13)

public static function getName(string $languageCode): string|null;

LanguageCodeCollection Class

Josantonius\LanguageCode\LanguageCodeCollection, (*14)

Get all language codes as array:, (*15)

public static function all(): array

Get language code from language name:, (*16)

public static function getCode(string $languageName): string|null

Get language name from language code:, (*17)

public static function getName(string $languageCode): string|null

Usage

Example of use for this library:, (*18)

Get all language codes as array

use Josantonius\LanguageCode\LanguageCode;

$languageCode = new LanguageCode();

$languageCode->all();
use Josantonius\LanguageCode\LanguageCodeCollection;

LanguageCodeCollection::all();

Result:, (*19)

[
    'aa' => 'Afar',
    'ab' => 'Abkhazian',
    'af' => 'Afrikaans',
    'am' => 'Amharic',
    'ar' => 'Arabic',
    'ar-ae' => 'Arabic (U.A.E.)',
    'ar-bh' => 'Arabic (Bahrain)',
    'ar-dz' => 'Arabic (Algeria)',
    'ar-eg' => 'Arabic (Egypt)',
    'ar-iq' => 'Arabic (Iraq)',
    (...)
]

Get language code from language name

use Josantonius\LanguageCode\LanguageCode;

$languageCode = new LanguageCode();

$languageCode->getCode('Spanish'); // es
use Josantonius\LanguageCode\LanguageCodeCollection;

LanguageCodeCollection::getCode('Turkish'); // tr

Get language name from language code

use Josantonius\LanguageCode\LanguageCode;

$languageCode = new LanguageCode();

$languageCode->getName('eo'); // Esperanto
use Josantonius\LanguageCode\LanguageCodeCollection;

LanguageCodeCollection::getName('de'); // German

List in JSON format

Go to the resource., (*20)

Tests

To run tests you just need composer and to execute the following:, (*21)

git clone https://github.com/josantonius/php-language-code.git
cd php-language-code

composer install

Run unit tests with PHPUnit:, (*22)

composer phpunit

Run code standard tests with PHPCS:, (*23)

composer phpcs

Run PHP Mess Detector tests to detect inconsistencies in code style:, (*24)

composer phpmd

Run all previous tests:, (*25)

composer tests

TODO

  • [ ] Add new feature
  • [ ] Improve tests
  • [ ] Improve documentation
  • [ ] Improve English translation in the README file
  • [ ] Refactor code for disabled code style rules (see phpmd.xml and phpcs.xml)

Changelog

Detailed changes for each release are documented in the release notes., (*26)

Contribution

Please make sure to read the Contributing Guide, before making a pull request, start a discussion or report a issue., (*27)

Thanks to all contributors! :heart:, (*28)

If this project helps you to reduce your development time, you can sponsor me to support my open source work :blush:, (*29)

License

This repository is licensed under the MIT License., (*30)

Copyright © 2017-present, Josantonius, (*31)

The Versions

06/01 2018

dev-master

9999999-dev

List of 217 language codes: ISO 639-1.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

language php hhvm iso 639-1 language code

06/01 2018

1.1.6

1.1.6.0

List of 217 language codes: ISO 639-1.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

language php hhvm iso 639-1 language code

12/11 2017

1.1.5

1.1.5.0

List of 217 language codes: ISO 639-1.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

language php hhvm iso 639-1 language code

01/11 2017

1.1.4

1.1.4.0

List of 217 language codes: ISO 639-1.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

language php hhvm iso 639-1 language code

14/09 2017

1.1.3

1.1.3.0

List of 217 language codes: ISO 639-1.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

language php hhvm iso 639-1 language code

18/07 2017

1.1.2

1.1.2.0

List of 217 language codes: ISO 639-1.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

language php hhvm iso 639-1 language code

18/03 2017

1.1.1

1.1.1.0

List of 217 language codes: ISO 639-1.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

language php hhvm iso 639-1 language code

12/01 2017

1.0.0

1.0.0.0

List of 217 language codes: ISO 639-1.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

language php hhvm iso 639-1 language code