/**
  * Import selected language into database and
  * create language cache file in account directory
  */
 protected function importLanguage($code)
 {
     $fileName = Gpf_Paths::getInstance()->getLanguageInstallDirectory() . Gpf_Application::getInstance()->getCode() . '_' . $code . '.csv';
     if (!Gpf_Io_File::isFileExists($fileName)) {
         return;
     }
     $importer = new Gpf_Lang_ImportLanguageTask($fileName, $code, false);
     $importer->run();
 }
 /**
  * Import language specified in parameter fileName
  *
  * @service language import
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Form
  */
 public function importLanguage(Gpf_Rpc_Params $params)
 {
     $form = new Gpf_Rpc_Form($params);
     //Read metadata of file
     $file = new Gpf_Io_Csv_Reader($form->getFieldValue("fileName"), ';', '"', array('source', 'translation', 'type', 'module', 'status', 'customer'));
     $file->setMaxLinesToRead(10);
     $language = new Gpf_Lang_CsvLanguage();
     $language->loadFromCsvFile($file);
     try {
         $importer = new Gpf_Lang_ImportLanguageTask($form->getFieldValue("fileName"), $language->getCode(), false);
         $importer->run();
     } catch (Gpf_Tasks_LongTaskInterrupt $e) {
         $form->addField('progress', 'PROGRESS');
         $form->setFieldError('progress', $e->getMessage());
         $form->setErrorMessage($e->getMessage());
         return $form;
     }
     $form->setInfoMessage($this->_('%s (%s) imported', $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_NAME), $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_ENG_NAME)));
     return $form;
 }
 /**
  * Import selected language into database and
  * create language cache file in account directory
  */
 protected function importLanguage()
 {
     $langCode = Gpf_Session::getInstance()->getAuthUser()->getLanguage();
     $fileName = Gpf_Paths::getInstance()->getLanguageInstallDirectory() . Gpf_Application::getInstance()->getCode() . '_' . $langCode . '.csv';
     $importer = new Gpf_Lang_ImportLanguageTask($fileName, $langCode);
     $importer->run($this->maxRunTime);
 }