Okies guy I think u all here rock ..but sleepy :P
I've done the translation my way
So I gave the Admin the possiblity to change the language from the BO
Wot I've done is creating a table configuration with 3 column
TABLE:CONFIGURATIONS
ID - COLUMN - VALUE
The in my admin_editlanguage I set the column to the language selected
from the editlanguage form!
Next easy as a piece of cake read the value in the BeforeFilter and
set the current language to the one read from the database :)
This is the source code in case this can help someone else
somewhere :)
//ADMIN EDIT LANGUAGE CONTROLLER ACTION
function admin_editlanguage() {
if (!empty($this->data)) {
$data['Configuration']['value']=$this->data['User']['lang'];
$data['Configuration']['id']=1;
$this->loadModel('Configuration');
if($this->Configuration->save($data)){
$this->Session->setFlash(__('The user interface
language has been
changed!', true));
$this->redirect($this->referer());
}else{
$this->Session->setFlash(__('The user interface
language couldn
\'t be changed!', true));
$this->redirect($this->referer());
}
}}
//ADMIN EDIT LANGUAGE FORM
<div class="users form">
<?php echo $this->Form-
>create('User',array('action'=>'editlanguage'));?>
<fieldset>
<legend><?php __('Admin Edit Lnguage'); ?></legend>
<?php
echo '<div class="input text"><label>'. __('Interface
Language',true).'</label>'.$this->Form->select('lang',array('fre'=>
__('French',true),'ita'=> __('Italian',true),'eng'=>
__('English',true)),null,array('empty'=> __('Select a
language',true),'class'=>'fullwidth')).'</div>';
?>
</fieldset>
<?php echo $this->Form->end(__('Submit', true));?>
</div>
<div class="actions">
<h3><?php __('Actions'); ?></h3>
<ul>
<li><?php //echo $this->Html->link(__('List Users', true),
array('action' => 'index'));?></li>
</ul>
</div>
//BEFORE FILTER
function beforeFilter() {
$this->loadModel('Configuration');
$id=$this->Configuration->read(null,1);
Configure::write('Config.language',$id['Configuration']['value']);}
Regards Abraham Boray {A|B}
On Oct 18, 1:40 pm, Abraham Boray <[email protected]> wrote:
> Thank uu :) that's does help a little bit :) butt I'm seekin' more
> explanation .. thank uu
>
> On Oct 18, 1:31 pm, Tilen Majerle <[email protected]> wrote:
>
>
>
>
>
>
>
> > yes, the best way in cakephp and settings is settings table in mysql and
> > Setting model, then from there modify, add, delete settings...i think the
> > best solution :D
> > --
> > Tilen Majerlehttp://majerle.eu
>
> > 2010/10/18 Abraham Boray <[email protected]>
>
> > > I'm workin' on a web site that requires an implementation of different
> > > languages
> > > I've done that using pot files .. for french and english
> > > version..works perfect!
>
> > > Wot I'm not able to do is to give the administrator the choice to
> > > change the web Site language from the back office;
> > > using :
> > > Configure::write('Config.language', 'fre'); //to change the lang to
> > > french
>
> > > Any ideas how to do this ..maybe a database driven solution ... or
> > > session ...!
> > > I'm thinkin' a database driven solution can be much easier 2
> > > implement ...
> > > still I'm seekin' some of u guys who have had experience with this!
>
> > > Thank u
> > > Regards
> > > Abraham Boray {A|B}
>
> > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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 protected]> > To unsubscribe from this group, send
> > > email
> > > to>[email protected]<cake-php%2bunsubscr...@googlegroup
> > > s.com>For more options, visit this group at
> > >http://groups.google.com/group/cake-php?hl=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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en