Thursday, October 23, 2014

Re: Different languages in one page.

Hi Salines,

thanks, but the getting the dynamic localized data based on the wished language i have already sorted, that is not the problem.

what i need is my "static" translations in view file __('sample')  so at the end only the profile.ctp  is using the "esp" but the rest of elements, layout etc is using the original 'eng' .po file.

so what i need is to change the locale on the fly for the "static" content, before the profile.ctp is rendered but when the action view ( profile.ctp) render is finished and before the layout renderings starts change the locale back to original 'EN'

maybe image is more than words

martin.

On Thursday, October 23, 2014 11:56:33 AM UTC+2, Salines wrote:
For example, your default language and layout is in English, but you want to show the translation of dynamic content. 

Start from these ideas: 



Then in your view method:

public function view($id = null)
{
  if(isset($this->passedArgs['translate'])){
    $this->Profile->locale = $this->passedArgs['translate'];
 }
$options = array(
 // your options here
)
$profile = $this -> Profile -> find('first', $options);
$this->set('profile', $profile);
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: