PHP Classes
elePHPant
Icontem

File: README.md

Recommend this page to a friend!
  Classes of Josantonius  >  PHP Language Code  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Language Code
Get the name of language from code and vice-versa
Author: By
Last change: Updated to 1.1.3 version
Date: 13 days ago
Size: 3,959 bytes
 

Contents

Class file image Download

PHP LanguageCode library

Latest Stable Version Total Downloads Latest Unstable Version License Travis

Spanish version

List of 217 language codes: ISO 639-1.

Installation

The preferred way to install this extension is through composer.

To install PHP LanguageCode library, simply:

$ composer require Josantonius/LanguageCode

The previous command will only install the necessary files, if you prefer to download the entire source code (including tests, vendor folder, exceptions not used, docs...) you can use:

$ composer require Josantonius/LanguageCode --prefer-source

Or you can also clone the complete repository with Git:

$ git clone https://github.com/Josantonius/PHP-LanguageCode.git

Requirements

This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher.

Quick Start and Examples

To use this class, simply:

require __DIR__ . '/vendor/autoload.php';

use Josantonius\LanguageCode\LanguageCode;

Available Methods

Available methods in this library:

LanguageCode::getLanguageFromCode();
LanguageCode::getCodeFromLanguage();
LanguageCode::getAll();

Usage

Example of use for this library:

<?php
require __DIR__ . '/vendor/autoload.php';

use Josantonius\LanguageCode\LanguageCode;

LanguageCode::getLanguageFromCode('es');

/string(7) "Spanish"/

LanguageCode::getLanguageFromCode('abcd');

/string(9) "undefined"/

LanguageCode::getCodeFromLanguage('spanish');

/string(2) "es"/

LanguageCode::getCodeFromLanguage('abcd');

/string(9) "undefined"/

LanguageCode::getAll();

/*
array(217) {
  ["aa"]=>
  string(4) "Afar"
  ["ab"]=>
  string(9) "Abkhazian"
  ["af"]=>
  string(9) "Afrikaans"
  ["am"]=>
  string(7) "Amharic"
  ["ar"]=>
  string(6) "Arabic"
  (...)
*/

Tests

To run tests simply:

$ git clone https://github.com/Josantonius/PHP-LanguageCode.git

$ cd PHP-LanguageCode

$ phpunit

? TODO

  • [x] Create tests
  • [ ] Improve documentation

Contribute

  1. Check for open issues or open a new issue to start a discussion around a bug or feature.
  2. Fork the repository on GitHub to start making your changes.
  3. Write one or more tests for the new feature or that expose the bug.
  4. Make code changes to implement the feature or fix the bug.
  5. Send a pull request to get your changes merged and published.

This is intended for large and long-lived objects.

Repository

All files in this repository were created and uploaded automatically with Reposgit Creator.

License

This project is licensed under MIT license. See the LICENSE file for more info.

Copyright

2017 Josantonius, josantonius.com

If you find it useful, let me know :wink:

You can contact me on Twitter or through my email.