Skip to content

Commit

Permalink
fix: exclude non-localized element titles
Browse files Browse the repository at this point in the history
  • Loading branch information
shnsumit committed Jan 21, 2022
1 parent 8f67056 commit 7c19c2c
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/services/ElementTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ class ElementTranslator
public function toTranslationSource(Element $element, $sourceSite=null)
{
$source = array();

// if ($element instanceof Element || $element instanceof Tag || $element instanceof Category) {

if ($element instanceof Element) {
if ($element->title) {
if ($element->title && $element->getIsTitleTranslatable()) {
$source['title'] = $element->title;
}
if ($element->slug) {
Expand All @@ -43,7 +42,7 @@ public function toTranslationSource(Element $element, $sourceSite=null)

$source = array_merge($source, $fieldSource);
}

return $source;
}

Expand Down Expand Up @@ -72,14 +71,14 @@ public function getTargetData($content, $nonNested = false) {

while ($parts) {
$key = array_shift($parts);

if (!isset($container[$key])) {
$container[$key] = array();
}

$container =& $container[$key];
}

$container = $value;
} else {
$targetData[$name] = $value;
Expand All @@ -100,7 +99,7 @@ public function getTargetDataFromXml($xml, $nonNested = false)

$contents = $dom->getElementsByTagName('content');


foreach ($contents as $content) {
$name = (string) $content->getAttribute('resname');
$value = (string) $content->nodeValue;
Expand All @@ -109,7 +108,7 @@ public function getTargetDataFromXml($xml, $nonNested = false)
$targetData[$name] = $value;
continue;
}

if (strpos($name, '.') !== false) {
$parts = explode('.', $name);
$container =& $targetData;
Expand Down Expand Up @@ -140,7 +139,7 @@ public function toPostArrayFromTranslationTarget(Element $element, $sourceSite,
foreach($element->getFieldLayout()->getFields() as $key => $layoutField) {
$field = Craft::$app->fields->getFieldById($layoutField->id);
$fieldHandle = $field->handle;

$fieldType = $field;

$translator = Translations::$plugin->fieldTranslatorFactory->makeTranslator($fieldType);
Expand Down

0 comments on commit 7c19c2c

Please sign in to comment.