Jump to content

different view depending a language


grad

Recommended Posts

Hi,

I'm italian developer and I apologize to you for my non-perfect english.

I have a question: I would like to visualize different page for one product depending a language.

For example, in italian language I visualize a product in a determinate mode and in russian language in another one mode.

Thank you for your time,

see you later

 

grad

Link to comment
Share on other sites

go to the controllers/front/ProductController.php

 

this is a product page controller.

 

okay, you've got there function:

public function initContent()

at the end of this function you've got [ near the line 280 ]

$this->setTemplate(_PS_THEME_DIR_.'product.tpl');

 

instead this one use:

 

if ($this->context->cookie->id_lang==1){
 $this->setTemplate(_PS_THEME_DIR_.'product.tpl');
}
if ($this->context->cookie->id_lang==2){
 $this->setTemplate(_PS_THEME_DIR_.'product-fr.tpl');
}
if ($this->context->cookie->id_lang==3){
 $this->setTemplate(_PS_THEME_DIR_.'product-it.tpl');
}

 

where the:

$this->context->cookie->id_lang==1

1 - is an id of the language

$this->setTemplate(_PS_THEME_DIR_.'product.tpl');

product.tpl is a template file related to the language

 

as you can see, i use different templates for different id_lang values. just do the same. will work :-)

  • Like 1
Link to comment
Share on other sites

Thanks again! It's work!

Well, i have another question. Can I change some colors? If is possible, I think that the colors is in the css file, where is it?

For example:

In italian language i would like to see the "more info" bar in green while in brazilian i would like to see in green.

 

I attach an image that represent the "more info" bar.

 

Thanks,

grad

post-606448-0-64766400-1372233441_thumb.jpg

Link to comment
Share on other sites

well it is possible but everything depends on css styles.

in this case you have to create different styles for each language version

 

1) create new styles in global.css

2) change class="" etc. in the .tpl file for which you want to apply new style.

Link to comment
Share on other sites

  • 1 year later...

go to the controllers/front/ProductController.php

 

this is a product page controller.

 

okay, you've got there function:

public function initContent()
at the end of this function you've got [ near the line 280 ]

$this->setTemplate(_PS_THEME_DIR_.'product.tpl');
instead this one use:

 

if ($this->context->cookie->id_lang==1){
  $this->setTemplate(_PS_THEME_DIR_.'product.tpl');
}
if ($this->context->cookie->id_lang==2){
  $this->setTemplate(_PS_THEME_DIR_.'product-fr.tpl');
}
if ($this->context->cookie->id_lang==3){
  $this->setTemplate(_PS_THEME_DIR_.'product-it.tpl');
}
where the:

$this->context->cookie->id_lang==1

1 - is an id of the language

$this->setTemplate(_PS_THEME_DIR_.'product.tpl');

product.tpl is a template file related to the language

 

as you can see, i use different templates for different id_lang values. just do the same. will work :-)

 

Hi, I have an issue regarding this solution, I've changed the controller in order to have a different product.tpl page when a product is customizable.

if (is_array($customizationFields))
{
$this->setTemplate(_PS_THEME_DIR_.'custproduct.tpl');
}
else {
$this->setTemplate(_PS_THEME_DIR_.'product.tpl');
}
But when my custproduct.tpl page is displayed the portuguese translations arent't shown. the labels appear in english. Could you please help me out?
Kind regards,
Irina
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...