Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sokil/php-language

Choose language of site from browser or cookie
https://github.com/sokil/php-language

Last synced: 23 days ago
JSON representation

Choose language of site from browser or cookie

Awesome Lists containing this project

README

        

php-language
============

Library to work with languages and localization on site. This library able to get prefered language from browser settings and store chosen option to cookie.

Prefered language goes from cookies, or if not specified - from browser. If language not listed in preffered - use default value.

Example of usage:

```php

// define supported languages
$language = new \Sokil\Language([
'uk' => ['caption' => 'Ukraininan', 'locale' => 'uk_UA.UTF-8'],
'en' => ['caption' => 'English', 'locale' => 'en_UK.UTF-8'],
], 'uk');

echo $language->getLanguage();

// if language chosed from list and must be set as system with writing to cookie
$language->setLanguage('uk');
```