Prepares PHP's built-in gettext extension using the specified locale (not at all related to Yii's translation system)
Yii 1.1 or above
Extract this package under protected/extensions/
Define the component and preload in protected/config/main.php:
...
'preload'=>array('gettext','log'),
...
'components'=>array(
'gettext'=>array(
'class' => 'ext.gettext.components.GetText',
// specify language_locale, could be based on domain name, URI, cookie, etc
'language' => 'fr_ca', // means french_canada
),
...
Use gettext functions such as _($message) whenever displaying or defining a message:
<?php echo _('All Rights Reserved.') ?>
<?php echo CHtml::submitButton(_('Login')); ?>
<?php printf(_('Copyright © %d %s.'), date('Y'), Yii::app()->name) ?><br/>
// php 5.4+ or shorttags allows this shorthand:
<?=_('All Rights Reserved.')?>
Use a PO editor such as poedit to scan for new messages and create new translations.
Be the first person to leave a comment
Please login to leave your comment.