API Documentation

Translate/Adapter.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Translate
subpackage
Zend_Translate_Adapter
version
$Id: Adapter.php 22586 2010-07-16 20:12:01Z thomas $
Classes
Zend_Translate_Adapter

Description

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Zend_Translate_Adapter

category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Translate
subpackage
Zend_Translate_Adapter
Constants
LOCALE_DIRECTORY
LOCALE_FILENAME
Properties
$_automatic
$_routed
$_cache
$_cacheTags
$_options
$_translate
Methods
__construct
addTranslation
setOptions
getOptions
getLocale
setLocale
getList
getMessageId
getMessageIds
getMessages
isAvailable
_loadTranslationData
_addTranslationData
translate
plural
_log
_
isTranslated
getCache
setCache
hasCache
removeCache
clearCache
toString
_getTagSupportForCache

Description

Basic adapter class for each translation source adapter

Constants

LOCALE_DIRECTORY

 LOCALE_DIRECTORY = 'directory'

Scans for the locale within the name of the directory

Details

value
directory
constant
integer

LOCALE_FILENAME

 LOCALE_FILENAME = 'filename'

Scans for the locale within the name of the file

Details

value
filename
constant
integer

Properties

$_automatic

boolean $_automatic = 'true'

Shows if locale detection is in automatic level

Details

$_automatic
boolean
visibility
private
default
true
final
false
static
false

$_cache

Zend_Cache_Core $_cache = 'null'

Internal cache for all adapters

Details

$_cache
Zend_Cache_Core
visibility
protected
default
null
final
false
static
true

$_cacheTags

boolean $_cacheTags = 'false'

Internal value to remember if cache supports tags

Details

$_cacheTags
boolean
visibility
private
default
false
final
false
static
true

$_options

array $_options = 'array'

Array with all options, each adapter can have own additional options 'clear' => when true, clears already loaded translations when adding new files 'content' => content to translate or file or directory with content 'disableNotices' => when true, omits notices from being displayed 'ignore' => a prefix for files and directories which are not being added 'locale' => the actual set locale to use 'log' => a instance of Zend_Log where logs are written to 'logMessage' => message to be logged 'logUntranslated' => when true, untranslated messages are not logged 'reload' => reloads the cache by reading the content again 'scan' => searches for translation files using the LOCALE constants 'tag' => tag to use for the cache

Details

$_options
array
visibility
protected
default
array
final
false
static
false

$_routed

array() $_routed = 'array'

Internal value to see already routed languages

Details

$_routed
array()
visibility
private
default
array
final
false
static
false

$_translate

array $_translate = 'array'

Translation table

Details

$_translate
array
visibility
protected
default
array
final
false
static
false

Methods

_

_( string $messageId, string|Zend_Locale $locale = null ) : string

Translates the given string returns the translation

Arguments
$messageId
string
Translation string
$locale
stringZend_Locale
(optional) Locale/Language to use, identical with locale identifier, @see Zend_Locale for more information
Output
string
Details
visibility
public
final
false
static
false

__construct

__construct( array|Zend_Config $options = array ) : void

Generates the adapter

Arguments
$options
arrayZend_Config
Translation options for this adapter
Details
visibility
public
final
false
static
false
throws

_addTranslationData

_addTranslationData(  $options = array ) : Zend_Translate_Adapter

Internal function for adding translation data

This may be a new language or additional data for an existing language If the options 'clear' is true, then the translation data for the specified language is replaced and added otherwise

Arguments
$options
Output
Zend_Translate_Adapter
Provides fluent interface
Details
visibility
private
final
false
static
false
see
Zend_Locale
throws

_getTagSupportForCache

_getTagSupportForCache( ) :

Internal method to check if the given cache supports tags

Details
visibility
private
final
false
static
true

_loadTranslationData

_loadTranslationData( mixed $data, string|Zend_Locale $locale, array $options = array ) : array

Load translation data

Arguments
$data
mixed
$locale
stringZend_Locale
$options
array
(optional)
Output
array
Details
visibility
protected
final
false
static
false

_log

_log( string $message, String $locale ) :

Logs a message when the log option is set

Arguments
$message
string
Message to log
$locale
String
Locale to log
Details
visibility
protected
final
false
static
false

addTranslation

addTranslation( array|Zend_Config $options = array ) : Zend_Translate_Adapter

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

Arguments
$options
arrayZend_Config
Options and translations to be added
Output
Zend_Translate_Adapter
Provides fluent interface
Details
visibility
public
final
false
static
false
throws

clearCache

clearCache( string $tag = null ) : void

Clears all set cache data

Arguments
$tag
string
Tag to clear when the default tag name is not used
Details
visibility
public
final
false
static
true

getCache

getCache( ) : Zend_Cache_Core

Returns the set cache

Output
Zend_Cache_Core
The set cache
Details
visibility
public
final
false
static
true

getList

getList( ) : array

Returns the available languages from this adapter

Output
array
Details
visibility
public
final
false
static
false

getLocale

getLocale( ) : Zend_Locale|string|null

Gets locale

Output
Zend_Locale|string|null
Details
visibility
public
final
false
static
false

getMessageId

getMessageId( string $message, string|Zend_Locale $locale = null ) : string|array|false

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

Arguments
$message
string
Message to get the key for
$locale
stringZend_Locale
(optional) Language to return the message ids from
Output
string|array|false
Details
visibility
public
final
false
static
false

getMessageIds

getMessageIds( string|Zend_Locale $locale = null ) : array

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

Arguments
$locale
stringZend_Locale
(optional) Language to return the message ids from
Output
array
Details
visibility
public
final
false
static
false

getMessages

getMessages( string|Zend_Locale $locale = null ) : array

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

Arguments
$locale
stringZend_Locale
(optional) Language to return the messages from
Output
array
Details
visibility
public
final
false
static
false

getOptions

getOptions( string|null $optionKey = null ) : integer|string|array|null

Returns the adapters name and it's options

Arguments
$optionKey
stringnull
String returns this option null returns all options
Output
integer|string|array|null
Details
visibility
public
final
false
static
false

hasCache

hasCache( ) : boolean

Returns true when a cache is set

Output
boolean
Details
visibility
public
final
false
static
true

isAvailable

isAvailable( string|Zend_Locale $locale ) : boolean

Is the wished language available ?

Arguments
$locale
stringZend_Locale
Language to search for, identical with locale identifier, @see Zend_Locale for more information
Output
boolean
Details
visibility
public
final
false
static
false
see
Zend_Locale

isTranslated

isTranslated( string $messageId, boolean $original = false, string|Zend_Locale $locale = null ) : boolean

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

Arguments
$messageId
string
Translation string
$original
boolean
(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
$locale
stringZend_Locale
(optional) Locale/Language to use, identical with locale identifier, see Zend_Locale for more information
Output
boolean
Details
visibility
public
final
false
static
false

plural

plural( string $singular, string $plural, integer $number, string|Zend_Locale $locale = null ) : string

Translates the given string using plural notations Returns the translated string

Arguments
$singular
string
Singular translation string
$plural
string
Plural translation string
$number
integer
Number for detecting the correct plural
$locale
stringZend_Locale
(Optional) Locale/Language to use, identical with locale identifier, @see Zend_Locale for more information
Output
string
Details
visibility
public
final
false
static
false
see
Zend_Locale

removeCache

removeCache( ) : void

Removes any set cache

Details
visibility
public
final
false
static
true

setCache

setCache( Zend_Cache_Core $cache ) :

Sets a cache for all Zend_Translate_Adapters

Arguments
$cache
Zend_Cache_Core
Cache to store to
Details
visibility
public
final
false
static
true

setLocale

setLocale( string|Zend_Locale $locale ) : Zend_Translate_Adapter

Sets locale

Arguments
$locale
stringZend_Locale
Locale to set
Output
Zend_Translate_Adapter
Provides fluent interface
Details
visibility
public
final
false
static
false
throws

setOptions

setOptions( array $options = array ) : Zend_Translate_Adapter

Sets new adapter options

Arguments
$options
array
Adapter options
Output
Zend_Translate_Adapter
Provides fluent interface
Details
visibility
public
final
false
static
false
throws

toString

toString( ) : string

Returns the adapter name

Output
string
Details
visibility
public
final
false
static
false

translate

translate( string|array $messageId, string|Zend_Locale $locale = null ) : string

Translates the given string returns the translation

Arguments
$messageId
stringarray
Translation string, or Array for plural translations
$locale
stringZend_Locale
(optional) Locale/Language to use, identical with locale identifier, @see Zend_Locale for more information
Output
string
Details
visibility
public
final
false
static
false
see
Zend_Locale
Documentation was generated by DocBlox.