I'm using Zend_Translate for a relatively small, bi-lingual sit开发者_如何学Pythone, and was wondering how best to handle language-specific images.
Quick example of how I'm using it:
Bootstrap.php
$translate = new Zend_Translate('array',
APPLICATION_PATH . '/../languages/',
null,
array('scan' => Zend_Translate::LOCALE_FILENAME,
'locale' => $locale->getLanguage())
);
index.phtml
<?php echo $this->translate('home.intro'); ?>
message.en.php
return array(
'home.intro' => 'Welcome!'
);
Is it normally best to place the whole img tag into the translation array, ready to echo out with $this->translate from the view:
'home.banner' => '<img src="/images/en/banner.png" alt="Welcome" />'
or to just have the alt value:
'home.banner.alt' => 'Welcome'
and then in the view (if we pre-set a 'lang' property):
<img src="/images/<?php echo $lang; ?>/banner.png"
alt="<?php echo $this->translate('home.banner.alt'); ?>" />
Or is there a better "Zend" way of doing it?
the better way :
<img src="/images/<?php echo $lang; ?>/banner.png"
alt="<?php echo $this->translate('home.banner.alt'); ?>" />
but you could use csv file than php array for translation
精彩评论