Create new translation for an object in pure PHP

Author Message

Guillaume Marty

Wednesday 04 February 2009 8:48:47 am

Hi,

I'm a bit confused about how to create a new translation for an existing object in pure code.

I've not been able to create a new translation in the current version of the object (that is the way how the user interface works). Instead, a new version is created containing the new translation.

Here is my code:

$version = $contentObject->createNewVersionIn( $contentObjectTargetLanguage, $contentObjectSourceLanguage, false, true,  eZContentObjectVersion::STATUS_PUBLISHED );

foreach ( $contentObject->fetchDataMap() as $attribute_identifier => $attribute )
{
	$attribute->fromString( 'New attribute translation' );
	$attribute->store();
}

What am I doing wrong? Maybe it has something to do with createNewVersionIn()...
Please help!

Guillaume Marty

Friday 13 February 2009 8:15:10 am

Any help? Please!

How to create a new language of an object and save attributes the clean way?

nehal shah

Friday 29 April 2011 5:36:39 am

Hi,

I have the same problem.I want to add translation for the current version of the object through php. Here is my code.

$objectID = 6413;
$object = eZContentObject::fetch( $objectID );
$catalanVersion = $englishObject->createNewVersion( $object->CurrentVersion, true, 'hun-HU', 'eng-GB' );

$contentObjectAttributes = $catalanVersion->contentObjectAttributes();
$contentObjectAttributes[0]->setAttribute( 'data_text', 'Urinary System1');
$contentObjectAttributes[0]->store();
$contentObjectAttributes[1]->setAttribute( 'data_text', '202.59.12');
$contentObjectAttributes[1]->store();

but when i run this code it is showing error.

Please anyone has solution for adding translation through php?

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.