Roundcube Community Forum

Third Party Contributions => Languages (Translations) => Topic started by: bakhtiyor on September 11, 2011, 01:46:42 PM

Title: How to switch a language using a script
Post by: bakhtiyor 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
Title: How to switch a language using a script
Post by: bakhtiyor 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);
Title: How to switch a language using a script
Post by: rosali 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);