Options can be used with all adapters. Of course the options are different for all adapters. You can set options when you create the adapter. Actually there is one option which is available to all adapters: 'clear' sets if translation data should be added to existing one or not. Standard behaviour is to add new translation data to existing one. But the translation data is only cleared for the selected language. So other languages remain untouched.
You can set options temporarily by giving them to
addTranslation(). And you can use the method
setOptions() to set options permanent.
Example 950. Using translation options
<?php
// define ':' as separator for the translation source files
$translate = new Zend_Translate(
array(
'adapter' => 'csv',
'content' => '/path/to/mytranslation.csv',
'locale' => 'de',
'delimiter' => ':'
)
);
...
// clear the defined language and use new translation data
$translate->addTranslation(
array(
'content' => '/path/to/new.csv',
'locale' => 'fr',
'clear' => true
)
);
Here you can find all available options for the different adapters with a description of their usage:
Table 166. Options for translation adapters
| Option | Adapter | Description | Default value |
|---|---|---|---|
| adapter |
Zend_Translate only |
Defines the adapter which will be used for the translation. This option
can only be given when a new instance of
Zend_Translate is created. When it is set
afterwards, then it will be ignored
|
Must be set as it has no default value |
| clear | all |
If set to TRUE, the already read translations will
be cleared. This can be used instead of creating a new instance when
reading new translation data
|
FALSE |
| cache | all |
Sets a cache for the translation adapter. This must be a instance of
Zend_Cache_Core
|
Per default no cache is set |
| content | all | Sets the content for the translation adapter. This could be an array, a filename or a directory. Which type of content is supported depends on the used adapter | The default value depends on the used adapter |
| disableNotices | all |
If set to TRUE, all notices regarding not available
translations will be disabled. You should set this option to
TRUE in production environment
|
FALSE |
| ignore | all | All directories and files beginning with this prefix will be ignored when searching for files. This value defaults to '.' which leads to the behavior that all hidden files will be ignored. Setting this value to 'tmp' would mean that directories and files like 'tmpImages' and 'tmpFiles' would be ignored as well as all subsequent directories. This option also accepts an array which can be used when you want to ignore more than one prefix. | . |
| log | all |
An instance of Zend_Log where untranslated
messages and notices will be written to
|
NULL |
| logMessage | all | The message which will be written into the log | Untranslated message within '%locale%': %message% |
| logPriority | all | The priority which is used to write the message into the log | 5 |
| logUntranslated | all |
When this option is set to TRUE, all message IDs
which can not be translated will be written into the attached log
|
FALSE |
| reload | all |
When this option is set to TRUE, then files are
reloaded into the cache. This option can be used to recreate the cache,
or to add translations to already cached data after the cache has
already been created.
|
FALSE |
| route | all | This option allows to use reroute from non existing translations to other languages. See the Rerouting Section for details about this option. | NULL |
| scan | all |
If set to NULL, no scanning of the directory
structure will be done. If set to
Zend_Translate::LOCALE_DIRECTORY the
locale will be detected within the directory. If set to
Zend_Translate::LOCALE_FILENAME the locale will
be detected within the filename. See this chapter
for details
|
NULL |
| tag | all | Sets an individual tag which is used for the attached cache. Using this option allows to use and clear the cache for single instances. When this option is not set, the attached cache is used for all instances combined | Zend_Translate |
| delimiter | Csv | Defines which sign is used as delimiter for separating source and translation | ; |
| enclosure | Csv | Defines the enclosure character to be used. Defaults to a doublequote | " |
| length | Csv | Defines the maximum length of a csv line. When set to 0 it will be detected automatically | 0 |
| useId | Xliff and Tmx |
If you set this option to FALSE, then the source
string will be used as message Id. The default for this option is
TRUE, which means that the Id from the trans-unit
element will be used as message Id
|
TRUE |
When you want to have self defined options, you are also able to use them within all
adapters. The setOptions() method can be used to define your
option. setOptions() needs an array with the options you want
to set. If an given option exists it will be signed over. You can define as much options
as needed as they will not be checked by the adapter. Just make sure not to overwrite
any existing option which is used by an adapter.
To return the option you can use the getOptions() method. When
getOptions() is called without a parameter it will return all
options set. When the optional parameter is given you will only get the specified
option.




