开发者

Best practice for Zend Translate with images?

开发者 https://www.devze.com 2023-03-12 14:32 出处:网络
I\'m using Zend_Translate for a relatively small, bi-lingual sit开发者_如何学Pythone, and was wondering how best to handle language-specific images.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消