https://github.com/sokil/php-language
Choose language of site from browser or cookie
https://github.com/sokil/php-language
Last synced: 3 months 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 (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-09-05T06:18:19.000Z (almost 9 years ago)
- Last Synced: 2025-02-04T00:45:14.443Z (5 months 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');
```