Third Party Contributions > Languages (Translations)

How to switch a language using a script

(1/1)

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);

Navigation

[0] Message Index

Go to full version