PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Internationalization » I18Nv2 » Manual

Class Summary I18Nv2

Class Summary I18Nv2 – I18Nv2 - Internationalization v2

I18Nv2 - Internationalization v2

The static I18Nv2 class currently provides routines for unified (ment as OS independent) locale setting, retrieving locale specific information like the "thousands separator" and automatic characterset conversion for output.

This documentation is outdated and needs an overhaul.

Intro

Intro – Introduction to I18Nv2

Preface

The work on I18Nv2 has actually started as a refactoring of I18N, but after some time I figured out that too many BC breaking changes were applied, so the release of a new major version was suggested.

Differences to I18N

I18N was modeled after Java OO practice and it provides a bunch of classes for each formatting action (numbers, currencies, dates).

I18Nv2 takes another approach and provides all formatting functionality within one class, which is I18Nv2_Locale.

I18Nv2_Locale is based upon PHPs builtin functionality of setlocale() , localeconv () and iconv related functions, while I18N completely depends on user contributed formatting rules.

I wouldn't say I18Nv2's approach is the better one, because it depends on the internationalization capabilities of the underlying operating system, but it's simpler and faster - though it is in need of user contributed date and time formatting rules.

I18N's translation functionality was dropped in favour of the new and shiny Translation2.

I18Nv2 still provides an HTTP negotiator to reveal the users preferred language/locale and charset.

I18Nv2 has translated lists of ISO country and language names for about 50 different languages. See I18Nv2_Country and I18Nv2_Language.

Examples

Examples – Usage example for I18Nv2

API Documentation

Please see PEARs API Documentation for details on the API provided by I18Nv2.

Setting a locale

Because Un*x and Windows use different locale codes, PHPs setLocale() is not easily portable - I18Nv2::setLocale() attempts to provide this portability.

With I18Nv2 you can use standard locale codes like 'en_US' on both, Linux and Windows, though the list is far not complete yet, so if you stumble over a not covered locale (I18Nv2::$locales in I18Nv2::_main()), just drop a mail to the maintainer with the missing locale and its corresponding Win32 code.

I18Nv2::setLocale()

<?php
require_once 'I18Nv2.php';

foreach (array('en_US', 'de', 'fr_CN') as $locale) {
    if (!$syslocale = I18Nv2::setLocale($locale)) {
        echo "Locale '$locale' not available!\n";
    } else {
        echo "Systems locale for '$locale': '$syslocale'\n";
    }
}
?>

Retrieving locale conventions

I18Nv2 holds locale conventions returned by localeConv() stored statically, so they are easily accessible through I18Nv2::getInfo(). Have a look at the documentation of PHPs localeConv() for all available information.

I18Nv2::getInfo()

<?php
require_once 'I18Nv2.php';

I18Nv2::setLocale('fr');

$dec_point = I18Nv2::getInfo('decimal_point');
echo "The decimal point for the french locale is '$dec_point'.\n";
echo "I18Nv2::getInfo() called without parameter returns all available information:\n";
print_r(I18Nv2::getInfo());
?>

Automatically transform output character set

I18Nv2 provides an easy way to utilize the ob_iconv_handler() through I18Nv2::autoConv().

I18Nv2::autoConv()

<?php
require_once 'I18Nv2.php';

// Writing a shell app that should also display nicely in a DOS box
if (I18Nv2_WIN) {
    I18Nv2::autoConv('CP850');
}

// output some latin1 stuff
echo "äüöß\n";
?>

Using I18Nv2_Locale

I18Nv2_Locale is a formatter object that provides functionality to format dates, times, numbers and currencies in locale dependent conventions.

I18Nv2_Locale

<?php
require_once 'I18Nv2.php';

$locale = &I18Nv2::createLocale('de_AT');

echo "Format a currency value of 2000: ",
    $locale->formatCurrency(2000, I18Nv2_CURRENCY_INTERNATIONAL), "\n";

echo "Format todays date:              ",
    $locale->formatDate(null, I18Nv2_DATETIME_FULL), "\n";

echo "Format current time:             ",
    $locale->formatTime(null, I18Nv2_DATETIME_SHORT), "\n";
?>

Using I18Nv2_Negotiator

I18Nv2 provides a language, charset and locale negotiator for HTTP.

I18Nv2_Negotiator

<?php
require_once 'I18Nv2/Negotiator.php';

$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en-US,en-GB,en;q=0.5,de';
$_SERVER['HTTP_ACCEPT_CHARSET']  = 'utf-8,iso-8859-1;q=0.5';

$neg = &new I18Nv2_Negotiator;

echo "User agents preferred language:                  ",
    $lang = $neg->getLanguageMatch(), "\n";

echo "User agents preferred country for language '$lang': ",
    $neg->getCountryMatch($lang), "\n";

echo "User agents preferred locale:                    ",
    $neg->getLocaleMatch(), "\n";

echo "User agents preferred charset:                   ",
    $neg->getCharsetMatch(), "\n";
?>

Using I18Nv2_Language

I18Nv2 provides translated lists of ISO language names.

I18Nv2_Language

<?php
require_once 'I18Nv2/Language.php';

$lang = &new I18Nv2_Language('it', 'iso-8859-1');

echo "Italian name for English: ",
    $lang->getName('en'), "\n";

echo "Italian name for French:  ",
    $lang->getName('fr'), "\n";
?>

Using I18Nv2_Country

I18Nv2 provides translated lists of ISO country names.

I18Nv2_Country

<?php
require_once 'I18Nv2/Country.php';

$country = &new I18Nv2_Country('de', 'iso-8859-1');

echo "German name for United States: ",
    $country->getName('us'), "\n";

echo "German name for Italia:        ",
    $country->getName('it'), "\n";
?>

Using I18Nv2_Country

I18Nv2 provides decorated classes for country and language lists.

I18Nv2_DecoratedList

<?php
require_once 'I18Nv2/Country.php';
require_once 'I18Nv2/DecoratedList/HtmlSelect.php';
require_once 'I18Nv2/DecoratedList/HtmlEntities.php';

$c = &new I18Nv2_Country('it', 'iso-8859-1');
$e = &new I18Nv2_DecoratedList_HtmlEntities($c);
$s = &new I18Nv2_DecoratedList_HtmlSelect($e);

// set some attributes
$s->attributes['select']['name'] = 'CountrySelect';
$s->attributes['select']['onchange'] = 'this.form.submit()';

// set a selected entry
$s->selected['DE'] = true;

// print a HTML safe select box
echo $s->getAllCodes();
?>

I18Nv2_CommonList::toDecoratedList()

<?php
require_once 'I18Nv2/Country.php';

$c = &new I18Nv2_Country('it', 'iso-8859-1');
$s = &$c->toDecoratedList('HtmlSelect');

// set some attributes
$s->attributes['select']['name'] = 'CountrySelect';
$s->attributes['select']['onchange'] = 'this.form.submit()';

// set a selected entry
$s->selected['IT'] = true;

// print a HTML select box
echo $s->getAllCodes();
?>

I18Nv2 Constants

I18Nv2 Constants – Constants defined in and used by I18Nv2

All Constants

Constants defined in Locale.php

Constants defined in I18Nv2/Locale.php
Name Value
I18Nv2_CURRENCY 20
I18Nv2_CURRENCY_INTERNATIONAL 22
I18Nv2_CURRENCY_LOCAL 21
I18Nv2_DATETIME 30
I18Nv2_DATETIME_DEFAULT 32
I18Nv2_DATETIME_FULL 35
I18Nv2_DATETIME_LONG 34
I18Nv2_DATETIME_MEDIUM 33
I18Nv2_DATETIME_SHORT 31
I18Nv2_NUMBER 10
I18Nv2_NUMBER_FLOAT 11
I18Nv2_NUMBER_INTEGER 12

I18Nv2::setLocale

I18Nv2::setLocale() – Set locale

Synopsis

require_once 'I18Nv2.php';

mixed I18Nv2::setLocale ( string $locale , int $cat = LC_ALL )

Description

Set environment to the specified locale.

Set a locale:

<?php
1  require_once 'I18Nv2.php';
2  I18Nv2::setLocale('en_GB');
?>

Parameter

string $locale

a valid locale like en_US or de_DE

integer $cat

the locale category - usually LC_ALL

Return value

Returns string used system locale or false on failure.

Note

This function should be called statically.

See

See also I18Nv2::setLocale() example, I18Nv2::getInfo(), I18Nv2::lastLocale(), PHPs setlocale().

I18Nv2::lastLocale

I18Nv2::lastLocale() – Get current/prior locale

Synopsis

require_once 'I18Nv2.php';

string I18Nv2::lastLocale ( int $prior = 0 , bool $full = false )

Description

Retrieve kinda history of locales that have been already set.

This only works, if I18Nv2::setLocale() has already been called.

Parameter

integer $prior

if 0, the current otherwise n prior to the current locale

boolean $full

whether to return the array with locale, language and actually used system locale

Return value

Returns mixed prior locale.

Note

This function should be called statically.

See

See also I18Nv2::setLocale().

I18Nv2::getInfo

I18Nv2::getInfo() – Get several locale specific information

Synopsis

require_once 'I18Nv2.php';

mixed I18Nv2::getInfo ( string $part = null )

Description

Get several locale specific information like thousands separator. The provided information debends on the local libc implementation and thus is not always reliable - especially on Microsoft Windows.

Retrieving specific locale information:

<?php
1  require_once 'I18Nv2.php';
2  $locale = I18Nv2::setLocale('en_US');
3  $thsep  = I18Nv2::getInfo('thousands_separator');
4  $point  = I18Nv2::getInfo('decimal_point');
?>

Parameter

string$part

specific part of locale information

Return value

Returns mixed locale specific information or array all available locale specific information if called without parameter.

Note

This function should be called statically.

See

See also I18Nv2::setLocale(), PHPs localeconv().

I18Nv2::autoConv

I18Nv2::autoConv() – Automatically transform output between character sets

Synopsis

require_once 'I18Nv2.php';

mixed I18Nv2::autoConv ( string $ocs = 'UTF-8' , string $ics = 'ISO-8859-1' )

Description

This method utilizes ob_iconv_handler(), so you should call it at the beginning of your script (prior to any output).

<?php
1   require_once 'I18Nv2.php';
2   I18Nv2::autoConv('iso-8859-1', 'utf-8');
3   // ...
?>

Parameter

string $ocs

desired output character set

string $ics

current intput character set

Return value

Returns TRUE on success, PEAR_Error on failure.

Returns PEAR_Error if output buffering couldn't be started.

Note

This function should be called statically.

See

See also PHPs ob_iconv_handler().

I18Nv2::createLocale

I18Nv2::createLocale() – Create an I18Nv2_Locale object

Synopsis

require_once 'I18Nv2.php';

object I18Nv2_Locale &I18Nv2::createLocale ( string $locale = null )

Description

Create a new I18Nv2_Locale object with the specified locale.

Parameter

string $locale

a locale like en_US or de_DE

Return value

Returns new object I18Nv2_Locale.

Note

This function should be called statically.

See

See also I18Nv2_Locale.

I18Nv2::createNegotiator

I18Nv2::createNegotiator() – Create an I18Nv2_Negotiator object

Synopsis

require_once 'I18Nv2.php';

object I18Nv2_Negotiator &I18Nv2::createNegotiator ( string $defLang = 'en' , string $defCharset = 'iso-8859-1' )

Description

Create a new I18Nv2_Negotiator object with the specified default language and default character set.

Parameter

string $defLang

default language

string $defCharset

default character set

Return value

Returns new object I18Nv2_Negotiator.

Note

This function should be called statically.

See

See also I18Nv2_Negotiator.

I18Nv2::langs2locales

I18Nv2::langs2locales() – Transform languages to locales

Synopsis

require_once 'I18Nv2.php';

array I18Nv2::langs2locales ( array $languages )

Description

Transforms language codes like en-US and de-DE to locale codes like en_US and de_DE.

Parameter

array $languages

array of language codes

Return value

Returns array transformed language codes as locale codes.

Note

This function should be called statically.

See

See also I18Nv2::locales2langs().

I18Nv2::locales2langs

I18Nv2::locales2langs() – Transform locales to languages

Synopsis

require_once '/I18Nv2.php';

array I18Nv2::locales2langs ( array $locales )

Description

Transforms locale codes like en_US and de_DE to language codes like en-US and de-DE.

Parameter

array $locales

array of locale codes

Return value

Returns array transformed loclae codes as language codes.

Note

This function should be called statically.

See

See also I18Nv2::langs2locales().

Class Summary I18Nv2_Locale

Class Summary I18Nv2_Locale – I18Nv2_Locale

I18Nv2_Locale

Represents a specific locale and provides routines for formatting date and time, numbers and currency.

I18Nv2_Locale::I18Nv2_Locale

I18Nv2_Locale::I18Nv2_Locale() – Constructor

Synopsis

require_once 'I18Nv2/Locale.php';

object I18Nv2_Locale::I18Nv2_Locale ( string $locale = null )

Description

Instantiate a new I18Nv2_Locale object with the specified locale.

Parameter

string $locale

the desired locale like en_US or de_DE

Return value

Returns new object I18Nv2_Locale.

I18Nv2_Locale::initialize

I18Nv2_Locale::initialize() – Initialize

Synopsis

require_once 'I18Nv2/Locale.php';

void I18Nv2_Locale::initialize ( )

Description

Initializes the I18Nv2_Locale object.

This method gets aumatically called by the constructor.

Note

This function can not be called statically.

I18Nv2_Locale::loadExtension

I18Nv2_Locale::loadExtension() – Loads corresponding locale extension

Synopsis

require_once 'I18Nv2/Locale.php';

void I18Nv2_Locale::loadExtension ( )

Description

Load available locale extensions.

This method gets called autmatically by the constructor.

Note

This function can not be called statically.

I18Nv2_Locale::setLocale

I18Nv2_Locale::setLocale() – Set locale

Synopsis

require_once 'I18Nv2/Locale.php';

mixed I18Nv2_Locale::setLocale ( string $locale )

Description

Transforms the I18Nv2_Locale object to the specified locale.

Parameter

string $locale

the locale like en_US or de_DE

Return value

Returns TRUE on success, PEAR_Error on failure.

Returns a PEAR_Error if the supplied locale was invalid.

Note

This function can not be called statically.

I18Nv2_Locale::setDefaults

I18Nv2_Locale::setDefaults() – Set defaults

Synopsis

require_once 'I18Nv2/Locale.php';

void I18Nv2_Locale::setDefaults ( )

Description

Reset used formats to the default values.

Note

This function can not be called statically.

I18Nv2_Locale::setCustomFormat

I18Nv2_Locale::setCustomFormat() – Set custom format

Synopsis

require_once 'I18Nv2/Locale.php';

void I18Nv2_Locale::setCustomFormat ( mixed $type = null , mixed $format = null )

Description

Set a custom format.

If $format is omitted, the custom format for $type will be discarded - if both vars are omitted all custom formats will be discarded.

Parameter

mixed $type

the I18Nv2 format category for which to set the custom format

mixed $format

the custom format

Return value

Returns TRUE on success, PEAR_Error on failure.

Note

This function can not be called statically.

I18Nv2_Locale::setCurrencyFormat

I18Nv2_Locale::setCurrencyFormat() – Set currency format

Synopsis

require_once 'I18Nv2/Locale.php';

mixed I18Nv2_Locale::setCurrencyFormat ( int $format , bool $custom = false )

Description

Set the currency format to use.

Either I18Nv2_CURRENCY_LOCAL, I18Nv2_CURRENCY_INTERNATIONAL or a custom currency format.

Parameter

integer $format

a I18Nv2_CURRENCY constant

boolean $custom

whether to use a defined custom format

Return value

Returns TRUE on success, PEAR_Error on failure.

Note

This function can not be called statically.

I18Nv2_Locale::setDateFormat

I18Nv2_Locale::setDateFormat() – Set date format

Synopsis

require_once 'I18Nv2/Locale.php';

mixed I18Nv2_Locale::setDateFormat ( int $format , bool $custom = false )

Description

Set the date format to use.

Either a I18Nv2_DATETIME constant or a custom date format.

Parameter

integer $format

a I18Nv2_DATETIME constant

boolean $custom

whether to use a defined custom format

Return value

Returns TRUE on success, PEAR_Error on failure.

Note

This function can not be called statically.

I18Nv2_Locale::setNumberFormat

I18Nv2_Locale::setNumberFormat() – Set number format

Synopsis

require_once 'I18Nv2/Locale.php';

mixed I18Nv2_Locale::setNumberFormat ( int $format , bool $custom = false )

Description

Set the number format to use.

Either a I18Nv2_NUMBER constant or a custom number format.

Parameter

integer $format

a I18Nv2_NUMBER constant

boolean $custom

whether to use a defined custom format

Return value

Returns TRUE on success, PEAR_Error on failure.

Note

This function can not be called statically.

I18Nv2_Locale::setTimeFormat

I18Nv2_Locale::setTimeFormat() – Set time format

Synopsis

require_once 'I18Nv2/Locale.php';

mixed I18Nv2_Locale::setTimeFormat ( int $format , bool $custom = false )

Description

Set a time format to use.

Either a I18Nv2_DATETIME constant or a custom time format.

Parameter

integer $format

a I18Nv2_DATETIME constant

boolean $custom

whether to use a defined custom format

Return value

Returns TRUE on success, PEAR_Error on failure.

Note

This function can not be called statically.

I18Nv2_Locale::formatDate

I18Nv2_Locale::formatDate() – Format a date

Synopsis

require_once 'I18Nv2/Locale.php';

string I18Nv2_Locale::formatDate ( int $timestamp = null )

Description

Format a date corresponding to the current locale.

Parameter

integer $timestamp

timestamp which should be formatted

Return value

Returns string formatted date.

Note

This function can not be called statically.

I18Nv2_Locale::formatTime

I18Nv2_Locale::formatTime() – Format a time

Synopsis

require_once 'I18Nv2/Locale.php';

string I18Nv2_Locale::formatTime ( int $timestamp = null )

Description

Format a time corresponding to the current locale.

Parameter

integer $timestamp

timestamp which should be formatted

Return value

Returns string formatted time.

Note

This function can not be called statically.

I18Nv2_Locale::formatNumber

I18Nv2_Locale::formatNumber() – Format a number

Synopsis

require_once 'I18Nv2/Locale.php';

string I18Nv2_Locale::formatNumber ( numeric $value )

Description

Format a number corresponding to the current locale.

Parameter

numeric $value

numeric value which should be formatted

Return value

Returns string formatted number.

Note

This function can not be called statically.

I18Nv2_Locale::formatCurrency

I18Nv2_Locale::formatCurrency() – Format currency

Synopsis

require_once 'I18Nv2/Locale.php';

string I18Nv2_Locale::formatCurrency ( numeric $value )

Description

Format a currecy value corresponding to the current locale.

Parameter

numeric $value

numeric value which should be formatted

Return value

Returns string formatted currency value.

Note

This function can not be called statically.

I18Nv2_Locale::date

I18Nv2_Locale::date() – Get local date

Synopsis

require_once 'I18Nv2/Locale.php';

string I18Nv2_Locale::date ( int $timestamp = null )

Description

Get the local date as returned by strftime('%x').

Parameter

integer $timestamp

timestamp which should be formatted

Return value

Returns string local date.

Note

This function can not be called statically.

I18Nv2_Locale::time

I18Nv2_Locale::time() – Get local time

Synopsis

require_once 'I18Nv2/Locale.php';

string I18Nv2_Locale::time ( int $timestamp = null )

Description

Get the local textual representation of a time as returned by strftime('%X').

Parameter

integer $timestamp

timestamp which should be formatted

Return value

Returns string formatted time.

Note

This function can not be called statically.

I18Nv2_Locale::dayName

I18Nv2_Locale::dayName() – Get local day name

Synopsis

require_once 'I18Nv2/Locale.php';

mixed I18Nv2_Locale::dayName ( int $weekday , bool $short = false )

Description

Get the local textual representation of a weekday.

Parameter

integer $weekday

numerical representation of weekday (0 = Sunday, 1 = Monday, ...)

boolean $short

whether to return the abbreviation

Return value

Returns string name of weekday on success or PEAR_Error on failure.

Note

This function can not be called statically.

I18Nv2_Locale::monthName

I18Nv2_Locale::monthName() – Get local month name

Synopsis

require_once 'I18Nv2/Locale.php';

mixed I18Nv2_Locale::monthName ( int $month , bool $short = false )

Description

Get the local textual representation of a month.

Parameter

integer $month

numerical representation of month (0 = January, 1 = February, ...)

boolean $short

whether to return the abbreviation

Return value

Returns string name of month on success or PEAR_Error on failure.

Note

This function can not be called statically.

Class Summary I18Nv2_Negotiator

Class Summary I18Nv2_Negotiator – I18Nv2_Negotiator

I18Nv2_Negotiator

Provides basic negotiation of user preferred locale, language and characterset.

I18Nv2_Negotiator::I18Nv2_Negotiator

I18Nv2_Negotiator::I18Nv2_Negotiator() – Constructor

Synopsis

require_once 'I18N/Negotiator.php';

object I18Nv2_Negotiator I18Nv2_Negotiator::I18Nv2_Negotiator ( string $defaultLanguage = 'en' , string $defaultCharset = 'iso-8859-1' , string $defaultCountry = '' )

Description

Find language code, country code, charset code, and dialect or variant of locale setting in HTTP request headers.

Parameter

string $defaultLanguage

default language

string $defaultCharset

default character set

string $defaultCountry

default country

Return value

Returns object I18Nv2_Negotiator.

I18Nv2_Negotiator::getCharsetMatch

I18Nv2_Negotiator::getCharsetMatch() – Get character set match

Synopsis

require_once 'I18Nv2/Negotiator.php';

string I18Nv2_Negotiator::getCharsetMatch ( array $charsets = null )

Description

Get a matching character set.

Parameter

array $charsets

array of character sets

Return value

Returns string matched character set.

Note

This function can not be called statically.

I18Nv2_Negotiator::getCountryMatch

I18Nv2_Negotiator::getCountryMatch() – Get country match

Synopsis

require_once 'I18Nv2/Negotiator.php';

string I18Nv2_Negotiator::getCountryMatch ( string $lang , array $countries = null )

Description

Get a matching country code.

Parameter

string $lang

language code

array $countries

array of country codes

Return value

Returns string matching country.

Note

This function can not be called statically.

I18Nv2_Negotiator::getLanguageMatch

I18Nv2_Negotiator::getLanguageMatch() – Get language match

Synopsis

require_once 'I18Nv2/Negotiator.php';

string I18Nv2_Negotiator::getLanguageMatch ( array $langs = null )

Description

Get a matching language code.

Parameter

array $langs

array of language codes

Return value

Returns string matching language code.

Note

This function can not be called statically.

I18Nv2_Negotiator::getLocaleMatch

I18Nv2_Negotiator::getLocaleMatch() – Get locale match

Synopsis

require_once 'I18Nv2/Negotiator.php';

string I18Nv2_Negotiator::getLocaleMatch ( array $langs = null , array $countries = null )

Description

Get a matching locale code.

This method is a combination of I18Nv2::getLanguageMatch() and I18Nv2::getCountryMatch()

Parameter

array $langs

array of language codes

array $countries

array of country codes

Return value

Returns string matching locale code.

Note

This function can not be called statically.

I18Nv2_Negotiator::getVariantInfo

I18Nv2_Negotiator::getVariantInfo() – Return variant info for passed parameter.

Synopsis

require_once '/Negotiator.php';

string I18Nv2_Negotiator::getVariantInfo ( string $lang )

Description

This package is not documented yet.

Parameter

string $lang

Throws

throws no exceptions thrown

Note

This function can not be called statically.

I18Nv2_Negotiator::singleI18NCountry

I18Nv2_Negotiator::singleI18NCountry() – Create the Country helper object

Synopsis

require_once 'I18Nv2/Negotiator.php';

object &I18Nv2_Negotiator::singleI18NCountry ( )

Description

Singleton for I18Nv2_Country.

Return value

Returns object I18Nv2_Country.

Note

This function can not be called statically.

I18Nv2_Negotiator::singleI18NLanguage

I18Nv2_Negotiator::singleI18NLanguage() – Create the Language helper object

Synopsis

require_once 'I18Nv2/Negotiator.php';

object &I18Nv2_Negotiator::singleI18NLanguage ( )

Description

Singleton for I18Nv2_Language.

Return value

Returns object I18Nv2_Language.

Note

This function can not be called statically.

Class Summary I18Nv2_Country

Class Summary I18Nv2_Country – I18Nv2_Country

I18Nv2_Country

List of two letter country code to country name mapping.

I18Nv2_Country::I18Nv2_Country

I18Nv2_Country::I18Nv2_Country() – Constructor

Synopsis

require_once 'I18Nv2/Country.php';

object I18Nv2_Country I18Nv2_Country::I18Nv2_Country ( )

Description

Instantiate a new I18Nv2_Country object.

Return value

Returns object I18Nv2_Country.

I18Nv2_Country::getAllCodes

I18Nv2_Country::getAllCodes() – Get all codes

Synopsis

require_once 'I18Nv2/Country.php';

array I18Nv2_Country::getAllCodes ( )

Description

Get all country codes as associative array indexed by their two letter codes.

Return value

Returns array all country codes.

Note

This function can not be called statically.

I18Nv2_Country::getName

I18Nv2_Country::getName() – Get country name

Synopsis

require_once 'I18Nv2/Country.php';

string I18Nv2_Country::getName ( string $code )

Description

Get the corresponding country name of the supplied two letter country code.

Parameter

string $code

two letter country code

Return value

Returns string country name.

Note

This function can not be called statically.

I18Nv2_Country::isValidCode

I18Nv2_Country::isValidCode() – Check if country code is valid

Synopsis

require_once 'I18Nv2/Country.php';

bool I18Nv2_Country::isValidCode ( string $code )

Description

Check if the supplied two letter country code is valid.

Parameter

string $code

two letter country code

Return value

Returns boolean whether the two letter country code is valid.

Note

This function can not be called statically.

Class Summary I18Nv2_Language

Class Summary I18Nv2_Language – I18Nv2_Language

I18Nv2_Language

List of ISO-639-1 two letter resp. ISO-639-2 three letter language code to language name mapping.

I18Nv2_Language::I18Nv2_Language

I18Nv2_Language::I18Nv2_Language() – Constructor

Synopsis

require_once 'I18Nv2/Language.php';

object object I18Nv2_Language I18Nv2_Language::I18Nv2_Language ( bool $threeLetters = false )

Description

Instantiate a new I18Nv2_Language object.

Parameter

boolean $threeLetters

whether to use ISO-639-2 three letters or ISO-639-1 two letters language code format.

Return value

Returns new object I18Nv2_Language object.

I18Nv2_Language::getAllCodes

I18Nv2_Language::getAllCodes() – Get all codes

Synopsis

require_once 'I18Nv2/Language.php';

array I18Nv2_Language::getAllCodes ( )

Description

Get all language codes as associative array indexed by their two/three letter codes.

Return value

Returns array all language codes.

Note

This function can not be called statically.

I18Nv2_Language::getName

I18Nv2_Language::getName() – Return name of the language for language code

Synopsis

require_once 'I18Nv2/Language.php';

string I18Nv2_Language::getName ( string $code )

Description

Get the language name for the two/three letter language code.

Parameter

string $code

two/three letter language code

Return value

Returns string name of the language.

Note

This function can not be called statically.

I18Nv2_Language::isValidCode

I18Nv2_Language::isValidCode() – Check if language code is valid

Synopsis

require_once 'I18Nv2/Language.php';

boolean I18Nv2_Language::isValidCode ( string $code )

Description

Check if the supplied two/three letter language code is valid.

Parameter

string $code

two/three letter language code

Return value

Returns boolean whether the two/three letter language code is valid.

Note

This function can not be called statically.