Skip to content

Commit

Permalink
mediaが翻訳できない問題と必要ないオブジェクトの処理を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
1000-x-t30 committed Nov 26, 2024
1 parent d089b38 commit b1f7ca2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function buildEntryData($entry, $targetField, $detail = true)
];
if ($detail) {
$item['fields'] = $this->buildFieldData($eid, $targetField);
$item['units'] = $this->buildUnitDate($eid);
$item['units'] = $this->buildUnitData($eid);
}
return $item;
}
Expand Down Expand Up @@ -347,7 +347,7 @@ protected function buildFieldData($eid, $targetField)
* @param int $eid
* @return array
*/
protected function buildUnitDate($eid)
protected function buildUnitData($eid)
{
$item = [];
$units = loadColumn($eid);
Expand Down
6 changes: 4 additions & 2 deletions src/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ protected function buildEntry(&$model, $entry)
$current->setField1($new->table);
break;
case 'media':
$current->setField2($new->caption);
$current->setField3($new->alt);
break;
case 'image':
$current->setField1($new->caption);
$current->setField4($new->alt);
Expand All @@ -137,8 +140,7 @@ protected function buildEntry(&$model, $entry)
$current->setField1($new->caption);
break;
}
$newId = $current->generateNewIdTrait();
$current->setId($newId);
$current->setTempId(uniqueString());
$model->units[$i] = $current;
break;
}
Expand Down
46 changes: 0 additions & 46 deletions src/POST/GoogleTranslate/CreateEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,29 +132,6 @@ protected function addToTranslationUnits($units, $googleTranslate)
$googleTranslate->addText('unit_caption_' . $i, $unit['caption']);
break;
}
} elseif (is_object($unit)) {
$type = detectUnitTypeSpecifier($unit->getType());
switch ($type) {
case 'text':
$tagType = $this->getTextUnitFormat($unit->getTag());
if ($tagType === 'html') {
$googleTranslate->addHtml('unit_text_' . $i, $this->newLineEscape($unit->getText()));
} elseif ($tagType === 'text') {
$googleTranslate->addText('unit_text_' . $i, $unit->getText());
}
break;
case 'table':
$googleTranslate->addHtml('unit_table_' . $i, $unit->getTable());
break;
case 'media':
case 'image':
$googleTranslate->addText('unit_caption_' . $i, $unit->getCaption());
$googleTranslate->addText('unit_alt_' . $i, $unit->getAlt());
break;
case 'file':
$googleTranslate->addText('unit_caption_' . $i, $unit->getCaption());
break;
}
}
}
}
Expand Down Expand Up @@ -189,29 +166,6 @@ protected function getTranslationUnits(&$units, $googleTranslate)
$unit['caption'] = $googleTranslate->getText('unit_caption_' . $i);
break;
}
} elseif (is_object($unit)) {
$type = detectUnitTypeSpecifier($unit->getType());
switch ($type) {
case 'text':
$tagType = $this->getTextUnitFormat($unit->getTag());
if ($tagType === 'html') {
$unit->setText($this->newLineUnEscape($googleTranslate->getHtml('unit_text_' . $i)));
} elseif ($tagType === 'text') {
$unit->setText($googleTranslate->getText('unit_text_' . $i));
}
break;
case 'table':
$unit->setTable($googleTranslate->getHtml('unit_table_' . $i));
break;
case 'media':
case 'image':
$unit->setCaption($googleTranslate->getText('unit_caption_' . $i));
$unit->setAlt($googleTranslate->getText('unit_alt_' . $i));
break;
case 'file':
$unit->setCaption($googleTranslate->getText('unit_caption_' . $i));
break;
}
}
}
}
Expand Down

0 comments on commit b1f7ca2

Please sign in to comment.