Post by mjalajel » Mon Jun 06, 2011 12:13 am

Hello,

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; ?>
Suggested Code

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'); ?>
Rationale
  • 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.
I can contribute the code needed, but I'm not sure if such change would be acceptable and how many people are dependent on the current format. Maybe this could be used in one of the upcoming major releases!

What do you think!
Last edited by mjalajel on Mon Jun 06, 2011 10:01 am, edited 1 time in total.

Newbie

Posts

Joined
Thu May 26, 2011 11:57 pm

Post by Xsecrets » Mon Jun 06, 2011 2:20 am

this is already being worked on some of the controllers are already passing all translations directly into the data array. Eventually all the controllers will be updated, but it's just going to take time to go through them all.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by mjalajel » Mon Jun 06, 2011 10:02 am

Is there any live examples in 1.5 that I can see?

Newbie

Posts

Joined
Thu May 26, 2011 11:57 pm

Post by Xsecrets » Mon Jun 06, 2011 12:09 pm

see this thread http://forum.opencart.com/viewtopic.php?f=24&t=19000
I know the change had been made in a few files in the later 1.4.x versions, but it may not be in 1.5 yet since it was started from earlier versions.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US
Who is online

Users browsing this forum: No registered users and 7 guests