Login   Register  
PHP Classes
elePHPant
Icontem

File: php_localizator.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alexander Skakunov  >  HTTP Locale  >  php_localizator.php  >  Download  
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
Author: By
Last change: forgot the file extension
Date: 7 years ago
Size: 827 bytes
 

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>