Forums / Developer / Creating translated content / Comment42834
Sebastiaan van der Vliet
Tuesday 12 April 2005 12:55:38 am
Hello,
One of our developers has done an import script once for different translations, but for an ezp 3.2 installation. I do not know if the script is still useful, but I have posted the translation part of it below. If you want the complete script, please let me know.
Kind regards,Sebastiaan
print( "Starting article import\n\r" ); include_once( "lib/ezutils/classes/ezdebug.php" ); include_once( "lib/ezutils/classes/ezmodule.php" ); eZModule::setGlobalPathList( array( "kernel" ) ); include_once( 'lib/ezutils/classes/ezexecution.php' ); include_once( 'kernel/classes/ezcontentobjecttreenode.php' ); include_once( 'kernel/classes/ezcontentobject.php' ); include_once( "lib/ezxml/classes/ezxml.php" ); include_once( 'lib/ezlocale/classes/ezdatetime.php' ); include_once( 'import_text2xml.php' ); [.. code for publishing object in default language removed from this example...] $ContentObject->store(); // ******************** FRENCH TRANSLATION // Create French language translation by duplicating all English attributes $originalContentAttributes =& $version->contentObjectAttributes(); unset( $translateContentAttributes ); $translateContentAttributes = array(); foreach ( array_keys( $originalContentAttributes ) as $contentAttributeKey ) { $originalContentAttribute =& $originalContentAttributes[$contentAttributeKey]; //print_r($originalContentAttributes); $contentAttribute =& $originalContentAttribute->translateTo( 'fre-FR' ); //print_r($contentAttribute); $contentAttribute->sync(); //print "Created French version\n"; $contentObject->store(); // Translate text fields into French print "Doing French translation\n"; $translateContentAttributes =& $version->contentObjectAttributes( 'fre-FR' ); // Title - first attribute in the article class $translateContentAttributes[0]->setAttribute( 'data_text', $articleNameFR ); $translateContentAttributes[0]->store(); // Subtitle - second attribute in the article class $translateContentAttributes[1]->setAttribute( 'data_text', $articleSubtitleFR ); $translateContentAttributes[1]->store(); // Intro $converter = new text2xml( $articleContentFR, $translateContentAttributes[3] ); $converter->validateText( $introtext, $translateContentAttributes[3] ); $translateContentAttributes[3]->setAttribute( 'data_int', EZ_XMLTEXT_VERSION_TIMESTAMP ); $translateContentAttributes[3]->store(); // body $converter->validateText( $articleContentFR, $translateContentAttributes[4] ); $translateContentAttributes[4]->setAttribute( 'data_int', EZ_XMLTEXT_VERSION_TIMESTAMP ); $translateContentAttributes[4]->store(); $contentObject->store();
Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.