/** * @param $id_lang_thelia_1 * @return Lang * @throws ImportException */ public function getT2Lang($id_lang_thelia_1) { $lang = null; if (!isset($this->lang_cache[$id_lang_thelia_1])) { if ($id_lang_thelia_1 > 0) { $obj = $this->t1db->query_obj("select * from lang where id=?", array($id_lang_thelia_1)); } else { $obj = $this->t1db->query_obj("select * from lang order by id asc limit 1"); } if ($obj == false || $obj == null) { throw new ImportException(Translator::getInstance()->trans("Failed to find a Thelia 1 lang for id '%id'", array("%id" => $id_lang_thelia_1), ImportT1::DOMAIN)); } if (isset($obj->code)) { $lang = LangQuery::create()->findOneByCode(strtolower($obj->code)); } else { $lang = LangQuery::create()->filterByLocale("fr_FR")->findOneByTitle($obj->description); } if ($lang === null) { // If the lang id is not zero, create it in T2 if ($id_lang_thelia_1 > 0) { $lang = new Lang(); if (isset($obj->code)) { $lang->setTitle($obj->description)->setCode($obj->code)->setLocale("{$obj->code}" . "_" . strtoupper($obj->code)); } else { $lang->setTitle("Imported Thelia lang {$id_lang_thelia_1}")->setCode("")->setLocale(""); } $lang->setDatetimeFormat('d/m/Y H:i:s')->setDecimals(2)->setDecimalSeparator('.')->setThousandsSeparator(' ')->setTimeFormat('H:i:s')->setDateFormat('d/m/Y')->save(); Tlog::getInstance()->addInfo("Created Thelia 2 lang from Thelia 1 lang ID={$id_lang_thelia_1}"); } throw new ImportException(Translator::getInstance()->trans("Failed to find a Thelia 2 lang for Thelia 1 lang id %id", array("%id" => $id_lang_thelia_1), ImportT1::DOMAIN)); } $this->lang_cache[$id_lang_thelia_1] = $lang; } return $this->lang_cache[$id_lang_thelia_1]; }