PHP code example of unicate / language-detection
1. Go to this page and download the library: Download unicate/language-detection library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
unicate / language-detection example snippets
ailable Languages: First entry is assumed to be the default language.
$availableLang = ['en', 'de', 'fr'];
// All methods chained. The last method that detects a language wins.
$langDetection = new \Unicate\LanguageDetection\LanguageDetection($availableLang);
$lang = $langDetection->byHeader()->byCookie()->byUri()->byParam()->getLang();
// Only by Param ?lang=en
$langDetection = new \Unicate\LanguageDetection\LanguageDetection($availableLang);
$lang = $langDetection->byParam()->getLang();
// Only by Uri /shop/en/article/3453452
$langDetection = new \Unicate\LanguageDetection\LanguageDetection($availableLang);
$lang = $langDetection->byUri()->getLang();