Hello all,
I redid the code for the translations. This time it's more dynamic, so you don't have to go back and add more code when you want a different language. You will have to make all your default english version go between [english][/english] (changed from {} because the home store page didn't like them) tags though.
You'll be adding this code just under the foreach statement listed in the method above in the following functions (search, category, new_products, manufacturer, details) in the /controllers/products.php
//setup for translations
// get the language selected, if not selected set to default
$langSelected = $this->session->userdata('user_language_set');
if ($langSelected =='') {
$langSelected = 'english'; //set this to whatever language you want to default to.
}
$transBeginTag = '/.*\['. $langSelected . '\]/';
$transEndTag = '/\[\/'.$langSelected.'\].*/';
// set things up for default language replacements by clearing out other languages in the description area
$data['product_overview'] = preg_replace($transBeginTag, "", $data['product_overview']);
$data['product_overview'] = preg_replace($transEndTag, "", $data['product_overview']);
$data['product_description_1'] = preg_replace($transBeginTag, "", $data['product_description_1']);
$data['product_description_1'] = preg_replace($transEndTag, "", $data['product_description_1']);
$data['product_description_2'] = preg_replace($transBeginTag, "", $data['product_description_2']);
$data['product_description_2'] = preg_replace($transEndTag, "", $data['product_description_2']);
Secondly, for the homepage or store page (which was a real pain to figure out), you'll need to modify /models/products_model.php (can't seem to do it at the controller level, oh well) about line 1124, add the following code:
//setup for translations
// get the language selected, if not selected set to default
$langSelected = $this->session->userdata('user_language_set');
if ($langSelected =='') {
$langSelected = 'english'; //set this to whatever language you want to default to.
}
$transBeginTag = '/.*\['. $langSelected . '\]/';
$transEndTag = '/\[\/'.$langSelected.'\].*/';
// set things up for default language replacements by clearing out other languages in the description area
$row['product_overview'] = preg_replace($transBeginTag, "", $row['product_overview']);
$row['product_overview'] = preg_replace($transEndTag, "", $row['product_overview']);
Post if you have problems.
One thing of note that I forgot to mention earlier is that you'll want to block all your translations of a single language together.For example:
[english] English goes here.[/english]
[spanish]Espanol goes here [/spanish]
[english] english 2nd phrase [/english]
Only the "english 2nd phrase" will show up if english is the selected language.