Author Topic: How to switch a language using a script  (Read 15581 times)

Offline bakhtiyor

  • Jr. Member
  • **
  • Posts: 22
How to switch a language using a script
« on: September 11, 2011, 01:46:42 PM »
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

Offline bakhtiyor

  • Jr. Member
  • **
  • Posts: 22
How to switch a language using a script
« Reply #1 on: September 12, 2011, 01:11:15 PM »
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);

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
How to switch a language using a script
« Reply #2 on: September 14, 2011, 04:04:39 AM »
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)