PHP Classes
Icontem

File: php_localizator.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alexander Skakunov  >  HTTP Locale  >  php_localizator.php  
File: php_localizator.php
Role: Example script
Content type: text/plain
Description: example for gettext
Class: HTTP Locale
Get the idiom and country of the user browser
 

Contents

Class file image Download
<?
include "HTTPLocale.class.php";

/*
Q: I would like to know how to use it with gettext(), since it needs values such as ru_RU, en_US, en_AU, en, pl....etc
A: you can do like this (see below)
*/

class PHPLocalizator extends HTTPLocale
{
  var 
$php_locale;
  function 
PHPLocalizator()
  {
    
parent::HTTPLocale();
    
$this->php_locale strtolower($this->language) . ( empty($this->country) ?  '' '_'.$this->country );
  }
}
$locale = new PHPLocalizator();

?>
<html>
  <head>
    <title>HTTPLocale usage example</title>
  </head>
  
  <body>
  <br/><br/>
    Your browser language is <?=$locale->language?><br/>
    Your browser country is <?=( empty($locale->country) ?  '[not defined]' $locale->country );?> <hr/>
    Your PHP locale is <?=$locale->php_locale?> <hr/>
  </body>
</html>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products