有没有办法在TYPO3 9中通过extbase创建域对象翻译?

问题描述 投票:1回答:1

我正在将一些带有JSON的产品导入我的TYPO3扩展程序。

我在使用ImportService进行翻译时出现问题,因为我从TYPO3 8升级到TYPO3 9.看来,尽管设置了_localizedUid和_versionedUid,但数据库中的l10n_parent无法设置。

/**
 * @param DomainObjectInterface $object
 * @param $targetLanguageUid
 * @return DomainObjectInterface|null
 */
public function translate($object, $targetLanguageUid)
{
    /** @var AbstractDomainObject $objectCopy */
    $objectCopy = new $this->objectType;
    $properties = ObjectAccess::getGettableProperties($object);
    foreach ($properties as $propertyName => $propertyValue) {
        ObjectAccess::setProperty($objectCopy, $propertyName, $propertyValue);
    }
    $objectCopy->_setProperty('_localizedUid', $object->getUid());
    $objectCopy->_setProperty('_languageUid', $targetLanguageUid);
    $objectCopy->_setProperty('_versionedUid', $object->getUid());
    return $objectCopy;
}

预期结果:数据库中的l10n_parent是例如403(原始对象的uid) 实际结果:数据库中的l10n_parent为0

typo3 translation extbase typo3-9.x
1个回答
0
投票

在处理TYPO3内部数据结构时,建议使用DataHandler。在您的情况下,您只需要提供配置数组并正确设置localize字段。您可以在自己的脚本中使用此端口作为后端范围,documentation中提供了示例。在导入脚本中,您必须首先使用默认语言创建记录,然后为其创建每个翻译。

© www.soinside.com 2019 - 2024. All rights reserved.