Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Zend_Translate_Adapter Class Reference

Public Member Functions

 __construct ($options=array())
 Generates the adapter.
 
 addTranslation ($options=array())
 Add translations.
 
 setOptions (array $options=array())
 Sets new adapter options.
 
 getOptions ($optionKey=null)
 Returns the adapters name and it's options.
 
 getLocale ()
 Gets locale.
 
 setLocale ($locale)
 Sets locale.
 
 getList ()
 Returns the available languages from this adapter.
 
 getMessageId ($message, $locale=null)
 Returns the message id for a given translation If no locale is given, the actual language will be used.
 
 getMessageIds ($locale=null)
 Returns all available message ids from this adapter If no locale is given, the actual language will be used.
 
 getMessages ($locale=null)
 Returns all available translations from this adapter If no locale is given, the actual language will be used If 'all' is given the complete translation dictionary will be returned.
 
 isAvailable ($locale)
 Is the wished language available ?
 
 translate ($messageId, $locale=null)
 Translates the given string returns the translation.
 
 plural ($singular, $plural, $number, $locale=null)
 Translates the given string using plural notations Returns the translated string.
 
 _ ($messageId, $locale=null)
 Translates the given string returns the translation.
 
 isTranslated ($messageId, $original=false, $locale=null)
 Checks if a string is translated within the source or not returns boolean.
 
 toString ()
 Returns the adapter name.
 

Static Public Member Functions

static getCache ()
 Returns the set cache.
 
static setCache (Zend_Cache_Core $cache)
 Sets a cache for all Zend_Translate_Adapters.
 
static hasCache ()
 Returns true when a cache is set.
 
static removeCache ()
 Removes any set cache.
 
static clearCache ($tag=null)
 Clears all set cache data.
 

Public Attributes

const LOCALE_DIRECTORY = 'directory'
 Scans for the locale within the name of the directory integer.
 
const LOCALE_FILENAME = 'filename'
 Scans for the locale within the name of the file integer.
 

Protected Member Functions

 _loadTranslationData ($data, $locale, array $options=array())
 Load translation data.
 
 _log ($message, $locale)
 Logs a message when the log option is set.
 

Protected Attributes

 $_options
 
 $_translate = array()
 

Static Protected Attributes

static $_cache = null
 

Constructor & Destructor Documentation

__construct (   $options = array())

Generates the adapter.

Parameters
array | Zend_Config$optionsTranslation options for this adapter
Exceptions
Zend_Translate_Exception
Returns
void

Member Function Documentation

_ (   $messageId,
  $locale = null 
)

Translates the given string returns the translation.

Parameters
string$messageIdTranslation string
string | Zend_Locale$locale(optional) Locale/Language to use, identical with locale identifier,
See Also
Zend_Locale for more information
Returns
string
_loadTranslationData (   $data,
  $locale,
array  $options = array() 
)
abstractprotected

Load translation data.

Parameters
mixed$data
string | Zend_Locale$locale
array$options(optional)
Returns
array
_log (   $message,
  $locale 
)
protected

Logs a message when the log option is set.

Parameters
string$messageMessage to log
String$localeLocale to log
addTranslation (   $options = array())

Add translations.

This may be a new language or additional content for an existing language If the key 'clear' is true, then translations for the specified language will be replaced and added otherwise

Parameters
array | Zend_Config$optionsOptions and translations to be added
Exceptions
Zend_Translate_Exception
Returns
Zend_Translate_Adapter Provides fluent interface
static clearCache (   $tag = null)
static

Clears all set cache data.

Parameters
string$tagTag to clear when the default tag name is not used
Returns
void
static getCache ( )
static

Returns the set cache.

Returns
Zend_Cache_Core The set cache
getList ( )

Returns the available languages from this adapter.

Returns
array|null
getLocale ( )

Gets locale.

Returns
Zend_Locale|string|null
getMessageId (   $message,
  $locale = null 
)

Returns the message id for a given translation If no locale is given, the actual language will be used.

Parameters
string$messageMessage to get the key for
string | Zend_Locale$locale(optional) Language to return the message ids from
Returns
string|array|false
getMessageIds (   $locale = null)

Returns all available message ids from this adapter If no locale is given, the actual language will be used.

Parameters
string | Zend_Locale$locale(optional) Language to return the message ids from
Returns
array
getMessages (   $locale = null)

Returns all available translations from this adapter If no locale is given, the actual language will be used If 'all' is given the complete translation dictionary will be returned.

Parameters
string | Zend_Locale$locale(optional) Language to return the messages from
Returns
array
getOptions (   $optionKey = null)

Returns the adapters name and it's options.

Parameters
string | null$optionKeyString returns this option null returns all options
Returns
integer|string|array|null
static hasCache ( )
static

Returns true when a cache is set.

Returns
boolean
isAvailable (   $locale)

Is the wished language available ?

See Also
Zend_Locale
Parameters
string | Zend_Locale$localeLanguage to search for, identical with locale identifier,
See Also
Zend_Locale for more information
Returns
boolean
isTranslated (   $messageId,
  $original = false,
  $locale = null 
)

Checks if a string is translated within the source or not returns boolean.

Parameters
string$messageIdTranslation string
boolean$original(optional) Allow translation only for original language when true, a translation for 'en_US' would give false when it can be translated with 'en' only
string | Zend_Locale$locale(optional) Locale/Language to use, identical with locale identifier, see Zend_Locale for more information
Returns
boolean
plural (   $singular,
  $plural,
  $number,
  $locale = null 
)

Translates the given string using plural notations Returns the translated string.

See Also
Zend_Locale
Parameters
string$singularSingular translation string
string$pluralPlural translation string
integer$numberNumber for detecting the correct plural
string | Zend_Locale$locale(Optional) Locale/Language to use, identical with locale identifier,
See Also
Zend_Locale for more information
Returns
string
static removeCache ( )
static

Removes any set cache.

Returns
void
static setCache ( Zend_Cache_Core  $cache)
static

Sets a cache for all Zend_Translate_Adapters.

Parameters
Zend_Cache_Core$cacheCache to store to
setLocale (   $locale)

Sets locale.

Parameters
string | Zend_Locale$localeLocale to set
Exceptions
Zend_Translate_Exception
Returns
Zend_Translate_Adapter Provides fluent interface
setOptions ( array  $options = array())

Sets new adapter options.

Parameters
array$optionsAdapter options
Exceptions
Zend_Translate_Exception
Returns
Zend_Translate_Adapter Provides fluent interface
toString ( )
abstract

Returns the adapter name.

Returns
string
translate (   $messageId,
  $locale = null 
)

Translates the given string returns the translation.

See Also
Zend_Locale
Parameters
string | array$messageIdTranslation string, or Array for plural translations
string | Zend_Locale$locale(optional) Locale/Language to use, identical with locale identifier,
See Also
Zend_Locale for more information
Returns
string

Member Data Documentation

$_cache = null
staticprotected
$_options
protected
Initial value:
= array(
'clear' => false,
'content' => null,
'disableNotices' => false,
'ignore' => '.',
'locale' => 'auto',
'log' => null,
'logMessage' => "Untranslated message within '%locale%': %message%",
'logPriority' => 5,
'logUntranslated' => false,
'reload' => false,
'route' => null,
'scan' => null,
'tag' => 'Zend_Translate'
)
$_translate = array()
protected
const LOCALE_DIRECTORY = 'directory'

Scans for the locale within the name of the directory integer.

const LOCALE_FILENAME = 'filename'

Scans for the locale within the name of the file integer.