Saturday, January 23, 2010

Re: Change default language on the fly in a view

On Sat, Jan 23, 2010 at 9:38 AM, euromark <dereuromark@googlemail.com> wrote:
> or did you mean that you want to stay in "English"?
> and just load ONE static text in French? the rest of the page remains
> "English"?
> => no "language switch" used
>
> then john's approach would actually fit

Both __() & __d() use I18n::translate(), which checks
$_SESSION['Config']['language']. So you need to switch that in order
to switch the lang back and forth within the same view. A really basic
example:

$_SESSION['Config']['language'] = 'fr';
echo __('some text', true);
$_SESSION['Config']['language'] = 'en';

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: