detect_browser_locale() public static méthode

Determines the locale best matching the given list of browser locales
public static detect_browser_locale ( mixed $domain = null ) : string
$domain mixed Domain to determine the locales for. If null, the global list be returned. If true, then the current domain will be used.
Résultat string The matching locale, or null if none could be determined
 /**
  * For incoming traffic to the site root, determine if they should be redirected to any locale.
  *
  * @return string|null The locale to redirect to, or null
  */
 protected function getRedirectLocale()
 {
     // Redirection interfere with flushing, so don't redirect
     if (isset($_GET['flush'])) {
         return null;
     }
     // Don't redirect if the user has clicked a link on the locale menu
     if ($this->knownReferrer()) {
         return null;
     }
     // Redirect if this user has previously viewed a page in any locale
     if (Fluent::config()->remember_locale && ($locale = Fluent::get_persist_locale())) {
         return $locale;
     }
     // Detect locale from browser Accept-Language header
     if (Fluent::config()->detect_locale && ($locale = Fluent::detect_browser_locale())) {
         return $locale;
     }
 }
 /**
  * Test browser detection of locale
  */
 public function testDetectBrowserLocale()
 {
     $this->withBrowserHTTPLanguage('en-us;q=1,en;q=0.50', function ($test) {
         $test->assertEquals('en_US', Fluent::detect_browser_locale());
     });
     $this->withBrowserHTTPLanguage('fr,en', function ($test) {
         $test->assertEquals('fr_CA', Fluent::detect_browser_locale());
     });
     $this->withBrowserHTTPLanguage('en,fr-ca', function ($test) {
         $test->assertEquals('en_NZ', Fluent::detect_browser_locale());
     });
     $this->withBrowserHTTPLanguage('en-nz,fr,en', function ($test) {
         $test->assertEquals('en_NZ', Fluent::detect_browser_locale());
     });
     $this->withBrowserHTTPLanguage('fr-fr,en,fr', function ($test) {
         $test->assertEquals('en_NZ', Fluent::detect_browser_locale());
     });
     $this->withBrowserHTTPLanguage('fr-fr,en-uk,ms', function ($test) {
         $test->assertEmpty(Fluent::detect_browser_locale());
     });
 }