public function importAction()
{
$this->checkPermission("translations");
$admin = $this->getParam("admin");
$merge = $this->getParam("merge");
$tmpFile = $_FILES["Filedata"]["tmp_name"];
$overwrite = $merge ? false : true;
if ($admin) {
$delta = Translation\Admin::importTranslationsFromFile($tmpFile, $overwrite, Tool\Admin::getLanguages());
} else {
$delta = Translation\Website::importTranslationsFromFile($tmpFile, $overwrite, $this->getUser()->getAllowedLanguagesForEditingWebsiteTranslations());
}
$result = ["success" => true];
if ($merge) {
$enrichedDelta = [];
foreach ($delta as $item) {
$lg = $item["lg"];
$item["lgname"] = \Zend_Locale::getTranslation($lg, "language");
$item["icon"] = "/admin/misc/get-language-flag?language=" . $lg;
$item["current"] = $item["text"];
$enrichedDelta[] = $item;
}
$result["delta"] = base64_encode(json_encode($enrichedDelta));
}
$this->_helper->json($result, false);
// set content-type to text/html, otherwise (when application/json is sent) chrome will complain in
// Ext.form.Action.Submit and mark the submission as failed
$this->getResponse()->setHeader("Content-Type", "text/html");
}