My suggestion would be to separate translations from controllers and put them only in views.
Current Code:
Code: Select all
/* In Language File */
$_['text_overview'] = 'Overview';
/* In Controller: */
$this->load->language('common/home');
$this->data['text_overview'] = $this->language->get('text_overview');
/* In View: */
<?php echo $text_overview; ?>
Code: Select all
/* In Language File */
$_['text_overview'] = 'Overview';
/* In Controller: */
# NOTHING
/* In View: */
<?php $this->load->language('common/home'); ?>
<?php echo I18n::t('text_overview'); ?>
#OR this form to get one item without affecting the registry
<?php echo I18n::t('text_overview', 'common/home'); ?>
- I think it is very distracting to find 25 calls in the controller to get a translated item that (may) be used in the view
- Currently, It's somehow hard to trace back an item from a view file to a controller to the language file...
- Suggested method will offer more simplicity, flexibility and -more importantly- separation.
What do you think!