Basic adapter class for each translation source adapter

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

 Methods

Translates the given string returns the translation

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

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(string|array|\Zend_Config $options = array()) : void
Inherited

Parameters

$options

stringarray\Zend_Config

Translation options for this adapter

Exceptions

\Zend_Translate_Exception

Add translations

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

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 = null) : void
InheritedStatic

Parameters

$tag

string

Tag to clear when the default tag name is not used

Returns the set cache

getCache() : \Zend_Cache_Core
InheritedStatic

Returns

\Zend_Cache_CoreThe set cache

Returns the available languages from this adapter

getList() : array | null
Inherited

Returns

arraynull

Gets locale

getLocale() : \Zend_Locale | string | null
Inherited

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 = null) : string | array | false
Inherited

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 = null) : array
Inherited

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 = null) : array
Inherited

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 = null) : integer | string | array | null
Inherited

Parameters

$optionKey

stringnull

String returns this option null returns all options

Returns

integerstringarraynull

Returns true when a cache is set

hasCache() : boolean
InheritedStatic

Returns

boolean

Is the wished language available ?

isAvailable(string|\Zend_Locale $locale) : boolean
Inherited
see

Parameters

$locale

string\Zend_Locale

Language to search for, identical with locale identifier, @see Zend_Locale for more information

Returns

boolean

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

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

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 = null) : string
Inherited
see

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
InheritedStatic

Sets a cache for all Zend_Translate_Adapters

setCache(\Zend_Cache_Core $cache) 
InheritedStatic

Parameters

$cache

\Zend_Cache_Core

Cache to store to

Sets locale

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

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 = array()) : \Zend_Translate_Adapter
Inherited

Parameters

$options

array

Adapter options

Exceptions

\Zend_Translate_Exception

Returns

\Zend_Translate_AdapterProvides fluent interface

Returns the adapter name

toString() : string
inherited_from \Zend_Translate_Adapter::toString()

Returns

string

Returns the adapter name

toString() : string
Inherited

Returns

string

Translates the given string returns the translation

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

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

Internal method, called by xml element handler for content

_contentElement(resource $file, string $data) 

Parameters

$file

resource

File handler

$data

string

Elements content

Internal method, called by xml element handler at end

_endElement(resource $file, string $name) 

Parameters

$file

resource

File handler

$name

string

Elements name

Internal method, detects the encoding of the xml file

_findEncoding($filename) : string

Parameters

$filename

Returns

stringEncoding

Load translation data (TMX file reader)

_loadTranslationData(string $filename, string $locale, array $options = array()) : array
inherited_from \Zend_Translate_Adapter::_loadTranslationData()

Parameters

$filename

string

TMX file to add, full path must be given for access

$locale

string

Locale has no effect for TMX because TMX defines all languages within the source file

$options

Exceptions

\Zend_Translation_Exception

Returns

array

Load translation data

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

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) 
Inherited

Parameters

$message

string

Message to log

$locale

String

Locale to log

Internal method, called by xml element handler at start

_startElement(resource $file, string $name, array $attrib) 

Parameters

$file

resource

File handler

$name

string

Elements name

$attrib

array

Attributes for this element

Internal function for adding translation data

_addTranslationData($options = array()) : \Zend_Translate_Adapter
Inherited

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

Parameters

$options

Exceptions

\Zend_Translate_Exception

Returns

\Zend_Translate_AdapterProvides fluent interface

Internal method to check if the given cache supports tags

_getTagSupportForCache() 
InheritedStatic

 Properties

 

Internal cache for all adapters

$_cache : \Zend_Cache_Core

Default

null
Static
 

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

Default

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')
 

Translation table

$_translate : array

Default

array()
 

Shows if locale detection is in automatic level

$_automatic : boolean

Default

true
 

Internal value to remember if cache supports tags

$_cacheTags : boolean

Default

false
Static
 

$_content

$_content 

Default

null
 

$_data

$_data 

Default

array()
 

$_file

$_file 

Default

false
 

Internal value to see already routed languages

$_routed : \array()

Default

array()
 

$_seg

$_seg 

Default

null
 

$_srclang

$_srclang 

Default

null
 

$_tu

$_tu 

Default

null
 

$_tuv

$_tuv 

Default

null
 

$_useId

$_useId 

Default

true

 Constants

 

Scans for the locale within the name of the directory

LOCALE_DIRECTORY = 'directory' 
constant integer
 

Scans for the locale within the name of the file

LOCALE_FILENAME = 'filename' 
constant integer