TIP_Locale

Introduction

Locale module

Source file
/Type/module/content/locale.php
Extends
TIP_Content

Provides a basic interface to the localization of short texts (less than 256 bytes).

Properties

locale : string

The locale identification string (such as 'en' or 'it')

access
protected

Methods

checkOptions (&$options)

&$options
lines
42 - 58
static
yes
access
protected

__construct ($options)

Constructor

$options
array
Properties values
lines
70 - 73
access
protected

Initializes a TIP_Locale instance.

$options inherits the TIP_Content properties, and add the following: * $options['locale']: the locale identification string (required)

get ($id, $prefix, $context, $cached) : string|null

Get a localized text

$id
string
The identifier
$prefix
string
The prefix
$context
array
A context associative array
$cached
bool
Whether to perform or not a cached read
lines
105 - 150
access
public

Given an $id and a $prefix, retrieves the localized text (in the locale specified by the 'locale' option of the main TIP_Application) binded to "$prefix.$id". This means the data object of TIP_Locale must have a series of rows with prefix.id values as the primary key.

The choice of splitting the key in $prefix and $id allows to perform a sort of cached read, that is, to avoid multiple queries, a single request for a specified prefix gets all the id of this prefix. If you are sure the other id are not used (such as for the TIP_Notify module) you can disable the cache by passig false to $cached.

The $context associative array contains a series of key=>value pairs that can be substituted in the localized text. The get() method will search in the localized text for any key enclosed by '|' and will put the corresponding value. For instance, if there is a 'size'=>200 in the $context array, the text 'Max allowed size is |size|...' will expand to 'Max allowed size is 200...'.

TIP_Locale was last modified by TiP on Mon 25 May 2009 06:22:25 PM CEST
Hosted by BerliOS Developer Logo