Search code examples
phpjavascriptroundcube

How to change language of UI for current user in Roundcube using a script


I am using Roundcube as a webmail client and need to write a script in order to change language of UI for current user.

Does anybody have any idea of how to do that? I know that there is a table users which has a field language. The problem consists on how to get current username using a script.


Solution

  • To change the language:

    // Define $customLanguage as the result of a SQL query or session
    // A valid value looks like "en_GB"
    $customLanguage = $_SESSION["language"]
    
    $rcmail = rcmail::get_instance();
    $rcmail->config->set('language', $customLanguage);
    $rcmail->load_language($customLanguage);
    $rcmail->user->save_prefs(array("language"=>$customLanguage));
    //...rest of script...