PHP Classes

File: php_localizator.php

Recommend this page to a friend!
  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: 16 years ago
Size: 827 bytes


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
$this->php_locale = strtolower($this->language) . ( empty($this->country) ? '' : '_'.$this->country );
$locale = new PHPLocalizator();

    <title>HTTPLocale usage example</title>
    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/>