protected function excelExport($locale)
{
- $class = get_class($this);
+ $class = get_class($this->getModelInstance());
- $alldata = json_decode($class::find(1)->getRawOriginal('content_translatable'), true);
+ $alldata = $class::getAllTranslations();
- $t = $class::find(1);
if ($locale === 'en') {
$ref = 'fr';
} else {
}
$row = 2;
+
foreach ($tref as $k => $v) {
- $str = base64_decode(explode('t_', $k)[1]);
$worksheet->setCellValueByColumnAndRow(1, $row, $k);
- $worksheet->setCellValueByColumnAndRow(2, $row, $str);
- $worksheet->setCellValueByColumnAndRow(3, $row, $v);
+ $worksheet->setCellValueByColumnAndRow(2, $row, $v['str']);
+ $worksheet->setCellValueByColumnAndRow(3, $row, $v['translation'] ?? $v['str']);
for ($i = 1; $i <= 3; $i++) {
$style = $worksheet->getStyleByColumnAndRow($i, $row);
$style = $worksheet->getStyleByColumnAndRow($i, $row);
$style->getAlignment()->setWrapText(true);
}
- $worksheet->setCellValueByColumnAndRow(4, $row, $tr[$k] ?? '');
+ $worksheet->setCellValueByColumnAndRow(4, $row, $tr[$k]['translation'] ?? '');
$row++;
}
$xls = $reader->load($file['tmp_name']);
$sheet = $xls->getActiveSheet();
- $existingTranslation = FluidbookTranslate::getFluidbookTranslation($locale);
+ $class = get_class($this->getModelInstance());
+
+ $existingTranslation = $class::getLocaleTranslations($locale);
$translations = [];
} elseif (!$updated) {
Alert::warning('No translation were updated')->flash();
} else {
- FluidbookTranslate::updateFluidbookTranslation($locale, $translations);
+ $class::updateTranslation($locale, $translations);
Alert::success('<b>' . $updated . ' translations</b> were updated (' . $count . ' total)')->flash();
}
return redirect($this->crud->route . '/1/edit/?locale=' . $locale);