public function install_languagepacks($langs, $updating = false) {
        global $CFG;

        $this->installer->set_queue($langs);
        $results = $this->installer->run();

        $updatedpacks = 0;

        foreach ($results as $langcode => $langstatus) {
            switch ($langstatus) {
                case \lang_installer::RESULT_DOWNLOADERROR:
                    $a       = new \stdClass();
                    $a->url  = $this->installer->lang_pack_url($langcode);
                    $a->dest = $CFG->dataroot.'/lang';
                    $this->errors[] = get_string('remotedownloaderror', 'error', $a);
                    throw new \moodle_exception('remotedownloaderror', 'error', $a);
                    break;
                case \lang_installer::RESULT_INSTALLED:
                    $updatedpacks++;
                    if ($updating) {
                        event\langpack_updated::event_with_langcode($langcode)->trigger();
                        $this->info[] = get_string('langpackupdated', 'tool_langimport', $langcode);
                    } else {
                        $this->info[] = get_string('langpackinstalled', 'tool_langimport', $langcode);
                        event\langpack_imported::event_with_langcode($langcode)->trigger();
                    }
                    break;
                case \lang_installer::RESULT_UPTODATE:
                    $this->info[] = get_string('langpackuptodate', 'tool_langimport', $langcode);
                    break;
            }
        }

        return $updatedpacks;
    }