PHP Classes
elePHPant
Icontem

File: LanguageDetect.sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Daniel Costa  >  Language Detect  >  LanguageDetect.sample.php  >  Download  
File: LanguageDetect.sample.php
Role: Example script
Content type: text/plain
Description: Sample file
Class: Language Detect
Detect the idioms supported by the user browser
Author: By
Last change:
Date: 7 years ago
Size: 691 bytes
 

Contents

Class file image Download
<?php
/**
 *
 * Language Detect Sample
 * Author: Daniel Costa - http://danielcosta.info
 *
 * Feel free to rate my class at phpclasses.org
 *
 */

require 'LanguageDetect.php';

$language = ''; // presented here just for explanation
var_dump($language); // $language is blank;

/**
 * Put your site languages accepted here
 */
$acceptedLanguages = array('en', 'pt');

$languages = new LanguageDetect();
$checkLanguages = $languages->getLanguagesList($acceptedLanguages,$foundLanguages = array());
if (
$checkLanguages) {
   
$language = key($foundLanguages);
} else {
   
$language = $acceptedLanguages[0];
}

var_dump($language); // preferred language was set;

?>