Translate/Adapter/Tbx.php
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 [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Translate
- Version
- $Id: Tbx.php 24649 2012-02-26 03:37:54Z adamlundrigan $
\Zend_Translate_Adapter_Tbx
Basic adapter class for each translation source adapter
- Parent(s)
- \Zend_Translate_Adapter
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants

LOCALE_DIRECTORY
= 'directory'
Scans for the locale within the name of the directory
Inherited from: \Zend_Translate_Adapter::LOCALE_DIRECTORY- Constant
- integer
- Inherited_from
- \Zend_Translate_Adapter::LOCALE_DIRECTORY

LOCALE_FILENAME
= 'filename'
Scans for the locale within the name of the file
Inherited from: \Zend_Translate_Adapter::LOCALE_FILENAME- Constant
- integer
- Inherited_from
- \Zend_Translate_Adapter::LOCALE_FILENAME
Properties


boolean $_automatic = true
Shows if locale detection is in automatic level
Inherited from: \Zend_Translate_Adapter::$$_automatictrue
Details- Type
- boolean
- Inherited_from
- \Zend_Translate_Adapter::$$_automatic


\Zend_Cache_Core $_cache = null
null
Details- Type
- \Zend_Cache_Core
- Inherited_from
- \Zend_Translate_Adapter::$$_cache


boolean $_cacheTags = false
Internal value to remember if cache supports tags
Inherited from: \Zend_Translate_Adapter::$$_cacheTagsfalse
Details- Type
- boolean
- Inherited_from
- \Zend_Translate_Adapter::$$_cacheTags


array $_options = 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')
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
Inherited from: \Zend_Translate_Adapter::$$_optionsarray('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')
Details- Type
- array
- Inherited_from
- \Zend_Translate_Adapter::$$_options


\array() $_routed = array()
Internal value to see already routed languages
Inherited from: \Zend_Translate_Adapter::$$_routedarray()
Details- Type
- \array()
- Inherited_from
- \Zend_Translate_Adapter::$$_routed


array $_translate = array()
array()
Details- Type
- array
- Inherited_from
- \Zend_Translate_Adapter::$$_translate
Methods


_(string $messageId, string | \Zend_Locale $locale = null) : string
Translates the given string returns the translation
Inherited from: \Zend_Translate_Adapter::_()Name | Type | Description |
---|---|---|
$messageId | string | Translation string |
$locale | string | \Zend_Locale | (optional) Locale/Language to use, identical with locale identifier, @see Zend_Locale for more information |
Type | Description |
---|---|
string |


__construct(array | \Zend_Config $options = array()) : void
Name | Type | Description |
---|---|---|
$options | array | \Zend_Config | Translation options for this adapter |
Exception | Description |
---|---|
\Zend_Translate_Exception |


_addTranslationData( $options = array()) : \Zend_Translate_Adapter
Internal function for adding translation data
Inherited from: \Zend_Translate_Adapter::_addTranslationData()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
Name | Type | Description |
---|---|---|
$options |
Type | Description |
---|---|
\Zend_Translate_Adapter | Provides fluent interface |
Exception | Description |
---|---|
\Zend_Translate_Exception |
- See
- \global\Zend_Locale


_getTagSupportForCache() : void
Internal method to check if the given cache supports tags
Inherited from: \Zend_Translate_Adapter::_getTagSupportForCache()

_loadTranslationData(string $filename, string $locale, $options = array()) : array
Load translation data (TBX file reader)
Name | Type | Description |
---|---|---|
$filename | string | TBX file to add, full path must be given for access |
$locale | string | Locale has no effect for TBX because TBX defines all languages within the source file |
$options |
Type | Description |
---|---|
array |
Exception | Description |
---|---|
\Zend_Translation_Exception |


_log(string $message, String $locale) : void
Name | Type | Description |
---|---|---|
$message | string | Message to log |
$locale | String | Locale to log |


addTranslation(array | \Zend_Config $options = array()) : \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
Name | Type | Description |
---|---|---|
$options | array | \Zend_Config | Options and translations to be added |
Type | Description |
---|---|
\Zend_Translate_Adapter | Provides fluent interface |
Exception | Description |
---|---|
\Zend_Translate_Exception |


clearCache(string $tag = null) : void
Name | Type | Description |
---|---|---|
$tag | string | Tag to clear when the default tag name is not used |


getList() : array | null
Returns the available languages from this adapter
Inherited from: \Zend_Translate_Adapter::getList()Type | Description |
---|---|
array | null |


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
Inherited from: \Zend_Translate_Adapter::getMessageId()Name | Type | Description |
---|---|---|
$message | string | Message to get the key for |
$locale | string | \Zend_Locale | (optional) Language to return the message ids from |
Type | Description |
---|---|
string | array | false |


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
Inherited from: \Zend_Translate_Adapter::getMessageIds()Name | Type | Description |
---|---|---|
$locale | string | \Zend_Locale | (optional) Language to return the message ids from |
Type | Description |
---|---|
array |


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
Inherited from: \Zend_Translate_Adapter::getMessages()Name | Type | Description |
---|---|---|
$locale | string | \Zend_Locale | (optional) Language to return the messages from |
Type | Description |
---|---|
array |


getOptions(string | null $optionKey = null) : integer | string | array | null
Returns the adapters name and it's options
Inherited from: \Zend_Translate_Adapter::getOptions()Name | Type | Description |
---|---|---|
$optionKey | string | null | String returns this option null returns all options |
Type | Description |
---|---|
integer | string | array | null |


isAvailable(string | \Zend_Locale $locale) : boolean
Name | Type | Description |
---|---|---|
$locale | string | \Zend_Locale | Language to search for, identical with locale identifier, |
Type | Description |
---|---|
boolean |
- See
- \global\Zend_Locale
- See
- \global\Zend_Locale


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
Inherited from: \Zend_Translate_Adapter::isTranslated()Name | Type | Description |
---|---|---|
$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 |
Type | Description |
---|---|
boolean |


plural(string $singular, string $plural, integer $number, string | \Zend_Locale $locale = null) : string
Translates the given string using plural notations Returns the translated string
Inherited from: \Zend_Translate_Adapter::plural()Name | Type | Description |
---|---|---|
$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 |
Type | Description |
---|---|
string |
- See
- \global\Zend_Locale


setCache(\Zend_Cache_Core $cache) : void
Sets a cache for all Zend_Translate_Adapters
Inherited from: \Zend_Translate_Adapter::setCache()Name | Type | Description |
---|---|---|
$cache | \Zend_Cache_Core | Cache to store to |


setLocale(string | \Zend_Locale $locale) : \Zend_Translate_Adapter
Name | Type | Description |
---|---|---|
$locale | string | \Zend_Locale | Locale to set |
Type | Description |
---|---|
\Zend_Translate_Adapter | Provides fluent interface |
Exception | Description |
---|---|
\Zend_Translate_Exception |


setOptions(array $options = array()) : \Zend_Translate_Adapter
Name | Type | Description |
---|---|---|
$options | array | Adapter options |
Type | Description |
---|---|
\Zend_Translate_Adapter | Provides fluent interface |
Exception | Description |
---|---|
\Zend_Translate_Exception |


translate(string | array $messageId, string | \Zend_Locale $locale = null) : string
Translates the given string returns the translation
Inherited from: \Zend_Translate_Adapter::translate()Name | Type | Description |
---|---|---|
$messageId | string | array | 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 |
Type | Description |
---|---|
string |
- See
- \global\Zend_Locale