Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/sokil/php-language
- Owner: sokil
- Created: 2014-05-26T14:24:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-05T06:18:19.000Z (about 8 years ago)
- Last Synced: 2024-10-09T23:09:10.234Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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');
```