cognetif/site-language

This package is abandoned and no longer maintained. No replacement package was suggested.

Description

v0.1.3 2019-09-14 20:30 UTC

This package is auto-updated.

Last update: 2024-02-26 14:52:01 UTC


README

Build Status MIT LICENSE

This library will attempt to detect a best match between the browsers accepted language from $_SERVER['HTTP_ACCEPT_LANGUAGE'] and the provided array of website accepted languages. If no match can be found the default fallback will be returned. If the server accept languages includes a locale like fr-FR, the fr will be used to match.

Installation

Install with composer:

$ composer install cognetif/site-language

How to Use

use Cognetif\SiteLanguage\SiteLanguage;

$siteLanguage = new SiteLanguage();
$siteLanguage->setDefault('fr');
$siteLanguage->setAccepted(['en','fr']);

$languageToUse = $siteLanguage->get();

Run Tests

$ ./vendor/bin/phpunit

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Licence

MIT - See: LICENCE