I am using PHP, Zend Framework and Zend_Translate (gettext adapter). To edit translations I use POEdit which utilizes xgettext to fetch strings to be translated.
POEdit (xgettext) will search for keywords to find strings to translate. So, if searching for the keyword
translate
'Text to translate'
echo translate('Text to translate');
function SomeZendFunction( $array ) {
return translate( $array['string'] );
}
...
echo SomeZendFunction( array('string'=>'Another text to translate') );
// translate('Another text to translate');
'Another text to translate'
translate
<?php // Dummy file, only accessed by POEdit when scanning for strings to translate
translate('Text to translate');
translate('Another text to translate');
translate('A third text to translate');
....
SomeZendFunction
I just got it! By creating a dummy function
function t($string) {
return $string;
}
echo SomeZendFunction( t('Another text to translate') );
I can add this t
function to the translate keywords in POEdit. Then I can embed all strings that will later on be translated by Zend into this Dummy function.
This way Zend will be allowed to translate it, and POEdit will recognize it as a string to translate.
If anyone has a better solution, please post it.