Roundcube Community Forum

 

How to switch a language using a script

Started by bakhtiyor, September 11, 2011, 01:46:42 PM

Previous topic - Next topic

bakhtiyor

I have created a new skin and want to put two links there with the name of languages (in my case Russian and English). And I want to change  the interface for current user (not for the whole system) automatically when a user clicks on those links.

How can I do that? Is there and API or some methods?

Thanks

bakhtiyor

I have solved myself the problem:

  $customLanguage=$_GET['hl'];
  $rcmail = rcmail::get_instance();
  $rcmail->config->set('language', $customLanguage);
  $rcmail->load_language($customLanguage);
  $a=array("language"=>$customLanguage);
  $rcmail->user->save_prefs($a);

rosali

One improvement ... Do not use GET params directly. Use Roundcube's built-in function to get a secure param:

$customLanguage = get_input_value('hl', RCUBE_INPUT_GET);
Regards,
Rosali
__________________
MyRoundcube Project (commercial)