When you want to add translations then you have probably already used the scan option from Zend_Translate.
It allows you to search complete directory structures for translations.
The scan option has two ways how it can be used.
LOCALE_FILENAME and LOCALE_DIRECTORY.
They define how the language will be detected out of the directory and filename.
LOCALE_FILENAME means that the locale/language this translation file will be added to, will be detected by looking within the filename. And LOCALE_DIRECTORY does the same for the directory where this file has been detected.
\dir\en\translation.xxx <= locale as directory "en" \dir_en\translation.xxx <= locale as directory "en" \dir\en_translation.xxx <= locale as filename "en" \dir\translation.en.xxx <= locale as filename "en"
Simple as is and for most of you nothing new.
But sometimes you may need to exclude some of the files and directories within the structure you are searching.
Therefor you can use the ignore option.
As with 1.10.3 this option accepts 3 syntax to be used.
You can use a single string… per default it is set to “.” which means that all files and directories beginning with “.” are ignored. For example all SVN directories begin with “.” and are per default ignored. All files within this path will not be added.
array('ignore' => '.'); <= default for ignoring all SVN directories array('ignore' => 'test'); <= ignores all directories and files beginning with 'test'
The second line would ignore “\dir\test\en.mo” or “\dir\testme.mo” but it would accept “\dir\mytest.mo” as the later doe s not begin with “test”. You may want to change this option. But be aware that, when you overwrite the “.”, all SVN directories will be searched. So don’t do this when you are working on or with SVN.
As second syntax you can use an array. This allows you to search for several syntax. But also using an array means, like using strings, that the directory or file has to begin with this pattern.
array('ignore' => array('.', 'test'); <= ignores SVN directories AND also those beginning with 'test'
Still there could be a problem… the directory or filename could have a syntax where it does not begin with a string. Here you have to use the third syntax. It allows you to use regular expressions to search for files and directories which have to be ignored.
array('ignore' => array('regex' => '/test/u', 'regex_2' => '/delete$/u');
The above example would ignore all files and directories which contain test anywhere within their name, and also all files and directories which end with delete.
This should give you enough flexibility to add only those translations which you need and ignore all others.
I hope you find this feature useful. More to come soon…
I18N Team Leader, Zend Framework
Zend Framework Advisory Board Member
Zend Certified Engineer for Zend Framework