Overview

Namespaces

  • None
  • PHP

Classes

  • i81n
  • Overview
  • Namespace
  • Class
  • Tree
  • Download

Class i81n

Library for internationalizing applications with PHP

Located at i81n.php
Methods summary
public
# __construct( string $lang = NULL, mixed $domain = '*' )

Class constructor.

Class constructor.

Parameters

$lang
string
$lang A string representing the language to be used.
$domain

Throws

Exception
public boolean
# setDomain( string $domain )

Sets the domain to be used for translation.

Sets the domain to be used for translation.

Each domain corresponds to an INI file with the translations. It is useful to create translations for separate modules.

Parameters

$domain
string
$domain The domain to be used for translation.

Returns

boolean

Throws

Exception
public string
# getDomain( )

Returns the currently configured domain.

Returns the currently configured domain.

Returns

string
public string
# getLang( )

Returns the language set in the LANG environment variable

Returns the language set in the LANG environment variable

Returns

string
public string
# setLang( string $lang )

Set the LANG environment variable.

Set the LANG environment variable.

Parameters

$lang
string
$lang A language code, such as en_US, en_GB, ...

Returns

string
Returns the contents of LANG after the change.
public string
# getLocaleDir( )

Returns the path for translation files.

Returns the path for translation files.

Returns

string
public string
# setLocaleDir( string $dirname )

Sets the path for translation files.

Sets the path for translation files.

Parameters

$dirname
string
$dirname The directory where the files are translation.

Returns

string
Returns the configured directory.

Throws

Exception
protected boolean
# parseLang( )

Mounts from the domain specified translation table.

Mounts from the domain specified translation table.

Returns

boolean

Throws

Exception
protected static string
# hash( string $msg )

Creates a hash for a message.

Creates a hash for a message.

Used to reference the messages in INI file translation.

Parameters

$msg
string
$msg The message to compute the hash

Returns

string
Returns the hash for the message
protected string
# searchInTranslateTable( string $hash )

Search through a translation of the original hash mesnagem.

Search through a translation of the original hash mesnagem.

Parameters

$hash
string
$hash The hash of the message to be sought in the translation table.

Returns

string
Returns the translated message or an empty string.
public string
# translate( string $msg )

Performs the translation of messages.

Performs the translation of messages.

Parameters

$msg
string
$string The message to be translated.

Returns

string
The translated message
protected static array
# parseFileSource( string $file, string $pattern = '->translate' )

Identifies a file source for messages used with i81n library (translate method) and creates an INI file translation.

Identifies a file source for messages used with i81n library (translate method) and creates an INI file translation.

Parameters

$file
string
$file Source file for the parser
$pattern
string
$pattern The search pattern of the messages to translate

Returns

array
Returns an array with the lines of the INI file translation

Throws

Exception
public static
# parseDir( mixed $configfile )
protected static
# getFileSources( mixed $sourcedir, mixed $recursive, mixed $exclude )
Properties summary
protected string $lang NULL
#

The language to be used

The language to be used

protected string $localeDir './locale'
#

The directory containing the translation INI files. The default is ./locale

The directory containing the translation INI files. The default is ./locale

protected array $translateTable array()
#

Holds the translation table.

Holds the translation table.

protected string $domain '*'
#

Specifies the domain to be used. Each INI file is a domain. For all domains, use * (default).

Specifies the domain to be used. Each INI file is a domain. For all domains, use * (default).

API documentation generated by ApiGen 2.8.0