File: core/detect_visitor_language.php

Recommend this page to a friend!
  Classes of mohammad anzawi  >  PHP Multilingual Support Library  >  core/detect_visitor_language.php  >  Download  
File: core/detect_visitor_language.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Multilingual Support Library
Translate texts for Web sites from JSON or DB
Author: By
Last change:
Date: 4 years ago
Size: 1,022 bytes
 

 

Contents

Class file image Download
<?php

if(!isset($_SESSION["logaty_detected_language"]))
{
   
$detect = new \PHPtricks\Logaty\Detect();

    if(
config("options/detect_country_lang"))
    {
       
$language = $detect->country();
        if(
$language != currentLang())
        {
           
// do what you want
            // you can redirect him to his language version
            // or any thing you want
            // for example here I want to show him a message

            // check if his language is supported and enabled
           
if(in_array($language, enabledLanguagesList()))
            {
               
// show him a message or redirect
           
}
        }
    }
    elseif (
config("options/detect_browser_lang"))
    {
       
$language = $detect->browser();
        if(
$language != currentLang())
        {
           
// do what you want
            // you can redirect him to his language version
            // or any thing you want
            // for example here I want to show him a message

            // check if his language is supported and enabled
           
if(in_array($language, enabledLanguagesList()))
            {
               
// show him a message or redirect
           
}

        }
    }

   
$_SESSION["logaty_detected_language"] = true;
}


For more information send a message to info at phpclasses dot org.