original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Install language packs provided
  
  @param string|array $langs array of langcodes or individual langcodes
  @param bool $updating true if updating the langpacks
  @return int false if an error encountered or
  @throws \moodle_exception when error is encountered installing langpack
docstring_tokens: Install language packs provided