Detector - Logaty

Detect Language's Last updated: 26/12/2021

Detect visitors Browser or Country Language in easy! .

Introduction Learn About Logaty Detecting Languages

LOGATY Allow you to detect visitor language for his browser language.
to beginning detect visitor language you need to take a look on detect configuration ./Config/options.php
you can see :
detect_browser_lang to enable detecting browser language.
true mean enabled , false mean disabled.

Detect Browser Language

get visitor browser language
first thing you need to make sure is (detect browser language) enabled. "detect_browser_lang" => true
if detected language is not enabled in your website, this method will return default language in website

How to Use :

<?php
    echo logaty()->detect->browser();
    // return browser language code-2-digits
   


for example if browser language is arabic the method will be return (ar), and if browser language is english the method will be return (en).

<?php
    $browserLanguage = logaty()->detect->browser;

    if($browserLanguage != logaty()->current())
    {
        showModal([
            'type'     => 'browser',
            'language' => $browserLanguage,
        ]);
    }

    // showModal function
    function showModal($options = [])
    {
        if(!isset($_SESSION['detect']))
        {
            $_SESSION['detect'] = true;
            // show modal or message box or do what you want
        }
    }


logaty()->current() return current language in your website.
you can check (Helpers) section to learn more about logaty()->current()

Detect Country Language

Removed Since V3.0.0

get visitor country language
first thing you need to make sure is (detect country language) enabled. "detect_country_lang" => true
if detected language is not enabled in your website, this method will return default language in website

How to Use :

 // removed since version 3.0.0

logaty()->current() return current language in your website.
you can check (Helpers) section to learn more about logaty()->current()