API Documentation

Zend/Translate/Adapter.php

Show: inherited
Table of Contents

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.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Translate  
Subpackage
Zend_Translate_Adapter  
Version
$Id: Adapter.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Translate_Adapter

Package: Zend\Translate\Zend\Translate\Adapter

Basic adapter class for each translation source adapter

Children
\Zend_Translate_Adapter_Xliff
\Zend_Translate_Adapter_Array
\Zend_Translate_Adapter_XmlTm
\Zend_Translate_Adapter_Tmx
\Zend_Translate_Adapter_Qt
\Zend_Translate_Adapter_Csv
\Zend_Translate_Adapter_Ini
\Zend_Translate_Adapter_Tbx
\Zend_Translate_Adapter_Gettext
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

Constant  LOCALE_DIRECTORY = 'directory'

Scans for the locale within the name of the directory

Constant
integer  
Constant  LOCALE_FILENAME = 'filename'

Scans for the locale within the name of the file

Constant
integer  

Properties

Propertyprivateboolean  $_automatic= 'true'

Shows if locale detection is in automatic level

Default valuetrueDetails
Type
boolean
Propertyprotected\Zend_Cache_Core  $_cache= 'null'
static

Internal cache for all adapters

Default valuenullDetails
Type
\Zend_Cache_Core
Propertyprivateboolean  $_cacheTags= 'false'
static

Internal value to remember if cache supports tags

Default valuefalseDetails
Type
boolean
Propertyprotectedarray  $_options= 'array( 'clear' => false'

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

Default valuearray( 'clear' => falseDetails
Type
array
Propertyprivate\array()  $_routed= 'array()'

Internal value to see already routed languages

Default valuearray()Details
Type
\array()
Propertyprotectedarray  $_translate= 'array()'

Translation table

Default valuearray()Details
Type
array

Methods

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

Translates the given string returns the translation

Parameters
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

Returns
Type Description
string
methodpublic__construct( array|\Zend_Config $options = array() ) : void

Generates the adapter

Parameters
Name Type Description
$options array|\Zend_Config

Translation options for this adapter

Throws
Exception Description
\Zend_Translate_Exception
methodprivate_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

Parameters
Name Type Description
$options
Returns
Type Description
\Zend_Translate_Adapter Provides fluent interface
Throws
Exception Description
\Zend_Translate_Exception
Details
See
\Zend_Locale  
methodprivate_getTagSupportForCache( ) : void
static

Internal method to check if the given cache supports tags

methodprotected_loadTranslationData( mixed $data, string|\Zend_Locale $locale, array $options = array() ) : array
abstract

Load translation data

Parameters
Name Type Description
$data mixed
$locale string|\Zend_Locale
$options array

(optional)

Returns
Type Description
array
methodprotected_log( string $message, String $locale ) : void

Logs a message when the log option is set

Parameters
Name Type Description
$message string

Message to log

$locale String

Locale to log

methodpublicaddTranslation( 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

Parameters
Name Type Description
$options array|\Zend_Config

Options and translations to be added

Returns
Type Description
\Zend_Translate_Adapter Provides fluent interface
Throws
Exception Description
\Zend_Translate_Exception
methodpublicclearCache( string $tag = null ) : void
static

Clears all set cache data

Parameters
Name Type Description
$tag string

Tag to clear when the default tag name is not used

methodpublicgetCache( ) : \Zend_Cache_Core
static

Returns the set cache

Returns
Type Description
\Zend_Cache_Core The set cache
methodpublicgetList( ) : array|null

Returns the available languages from this adapter

Returns
Type Description
array|null
methodpublicgetLocale( ) : \Zend_Locale|string|null

Gets locale

Returns
Type Description
\Zend_Locale|string|null
methodpublicgetMessageId( 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

Parameters
Name Type Description
$message string

Message to get the key for

$locale string|\Zend_Locale

(optional) Language to return the message ids from

Returns
Type Description
string|array|false
methodpublicgetMessageIds( 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

Parameters
Name Type Description
$locale string|\Zend_Locale

(optional) Language to return the message ids from

Returns
Type Description
array
methodpublicgetMessages( 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

Parameters
Name Type Description
$locale string|\Zend_Locale

(optional) Language to return the messages from

Returns
Type Description
array
methodpublicgetOptions( string|null $optionKey = null ) : integer|string|array|null

Returns the adapters name and it's options

Parameters
Name Type Description
$optionKey string|null

String returns this option null returns all options

Returns
Type Description
integer|string|array|null
methodpublichasCache( ) : boolean
static

Returns true when a cache is set

Returns
Type Description
boolean
methodpublicisAvailable( string|\Zend_Locale $locale ) : boolean

Is the wished language available ?

Parameters
Name Type Description
$locale string|\Zend_Locale

Language to search for, identical with locale identifier,

Returns
Type Description
boolean
Details
See
\Zend_Locale  
See
\Zend_Locale  
methodpublicisTranslated( string $messageId, boolean $original = false, string|\Zend_Locale $locale = null ) : boolean

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

Parameters
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

Returns
Type Description
boolean
methodpublicplural( string $singular, string $plural, integer $number, string|\Zend_Locale $locale = null ) : string

Translates the given string using plural notations Returns the translated string

Parameters
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

Returns
Type Description
string
Details
See
\Zend_Locale  
methodpublicremoveCache( ) : void
static

Removes any set cache

methodpublicsetCache( \Zend_Cache_Core $cache ) : void
static

Sets a cache for all Zend_Translate_Adapters

Parameters
Name Type Description
$cache \Zend_Cache_Core

Cache to store to

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

Sets locale

Parameters
Name Type Description
$locale string|\Zend_Locale

Locale to set

Returns
Type Description
\Zend_Translate_Adapter Provides fluent interface
Throws
Exception Description
\Zend_Translate_Exception
methodpublicsetOptions( array $options = array() ) : \Zend_Translate_Adapter

Sets new adapter options

Parameters
Name Type Description
$options array

Adapter options

Returns
Type Description
\Zend_Translate_Adapter Provides fluent interface
Throws
Exception Description
\Zend_Translate_Exception
methodpublictoString( ) : string
abstract

Returns the adapter name

Returns
Type Description
string
methodpublictranslate( string|array $messageId, string|\Zend_Locale $locale = null ) : string

Translates the given string returns the translation

Parameters
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

Returns
Type Description
string
Details
See
\Zend_Locale  
Documentation was generated by DocBlox 0.15.1.