Basic adapter class for each translation source adapter

category Zend
package Zend_Translate
subpackage Zend_Translate_Adapter
copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Translates the given string returns the translation

_(string $messageId, string | \Zend_Locale $locale) : string

Parameters

$messageId

string

Translation string

$locale

string\Zend_Locale

(optional) Locale/Language to use, identical with locale identifier, @see Zend_Locale for more information

Returns

string

Generates the adapter

__construct(array | \Zend_Config $options) : void

Parameters

$options

array\Zend_Config

Translation options for this adapter

Exceptions

\Zend_Translate_Exception

Add translations

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

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

$options

array\Zend_Config

Options and translations to be added

Exceptions

\Zend_Translate_Exception

Returns

\Zend_Translate_AdapterProvides fluent interface

Clears all set cache data

clearCache(string $tag) : void

Parameters

$tag

string

Tag to clear when the default tag name is not used

Returns the set cache

getCache() : \Zend_Cache_Core

Returns

\Zend_Cache_CoreThe set cache

Returns the available languages from this adapter

getList() : array | null

Returns

arraynull

Gets locale

getLocale() : \Zend_Locale | string | null

Returns

\Zend_Localestringnull

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

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

Parameters

$message

string

Message to get the key for

$locale

string\Zend_Locale

(optional) Language to return the message ids from

Returns

stringarrayfalse

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

getMessageIds(string | \Zend_Locale $locale) : array

Parameters

$locale

string\Zend_Locale

(optional) Language to return the message ids from

Returns

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

getMessages(string | \Zend_Locale $locale) : array

Parameters

$locale

string\Zend_Locale

(optional) Language to return the messages from

Returns

array

Returns the adapters name and it's options

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

Parameters

$optionKey

stringnull

String returns this option null returns all options

Returns

integerstringarraynull

Returns true when a cache is set

hasCache() : boolean

Returns

boolean

Is the wished language available ?

isAvailable(string | \Zend_Locale $locale) : boolean

see \Zend_Locale
see \Zend_Locale

Parameters

$locale

string\Zend_Locale

Language to search for, identical with locale identifier,

Returns

boolean

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

isTranslated(string $messageId, boolean $original, string | \Zend_Locale $locale) : boolean

Parameters

$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

string\Zend_Locale

(optional) Locale/Language to use, identical with locale identifier, see Zend_Locale for more information

Returns

boolean

Translates the given string using plural notations Returns the translated string

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

see \Zend_Locale

Parameters

$singular

string

Singular translation string

$plural

string

Plural translation string

$number

integer

Number for detecting the correct plural

$locale

string\Zend_Locale

(Optional) Locale/Language to use, identical with locale identifier, @see Zend_Locale for more information

Returns

string

Removes any set cache

removeCache() : void

Sets a cache for all Zend_Translate_Adapters

setCache(Zend_Cache_Core $cache) 

Parameters

$cache

\Zend_Cache_Core

Cache to store to

Sets locale

setLocale(string | \Zend_Locale $locale) : \Zend_Translate_Adapter

Parameters

$locale

string\Zend_Locale

Locale to set

Exceptions

\Zend_Translate_Exception

Returns

\Zend_Translate_AdapterProvides fluent interface

Sets new adapter options

setOptions(array $options) : \Zend_Translate_Adapter

Parameters

$options

array

Adapter options

Exceptions

\Zend_Translate_Exception

Returns

\Zend_Translate_AdapterProvides fluent interface

Returns the adapter name

toString() : string

Returns

string

Translates the given string returns the translation

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

see \Zend_Locale

Parameters

$messageId

stringarray

Translation string, or Array for plural translations

$locale

string\Zend_Locale

(optional) Locale/Language to use, identical with locale identifier, @see Zend_Locale for more information

Returns

string

Load translation data

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

Parameters

$data

mixed

$locale

string\Zend_Locale

$options

array

(optional)

Returns

array

Logs a message when the log option is set

_log(string $message, String $locale) 

Parameters

$message

string

Message to log

$locale

String

Locale to log

Internal function for adding translation data

_addTranslationData($options) : \Zend_Translate_Adapter

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

see \Zend_Locale

Parameters

$options

Exceptions

\Zend_Translate_Exception

Returns

\Zend_Translate_AdapterProvides fluent interface

Internal method to check if the given cache supports tags

_getTagSupportForCache() 

 Properties

 

Internal cache for all adapters

$_cache : \Zend_Cache_Core

 

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 'logPriority' => priority which is used to write the log message '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

$_options : array

 

Translation table

$_translate : array

 

Shows if locale detection is in automatic level

$_automatic : boolean

 

Internal value to remember if cache supports tags

$_cacheTags : boolean

 

Internal value to see already routed languages

$_routed : \array()

 Constants

 

Scans for the locale within the name of the directory

LOCALE_DIRECTORY 

constant integer
 

Scans for the locale within the name of the file

LOCALE_FILENAME 

constant integer