Any way to create objects in a specific lenguage?

Author Message

Pablo C. Vergara Castro

Friday 26 August 2005 1:01:51 am

Hi to all.

I have a Web site with different siteaccess several of this have different RegionalSettings, but want that one of the objects that the user can create will be always in Spanish (that is the language by defect) independently of which the user is in siteaccess in English.

Then my question is, exists some way so that when adding object the system can select in what language will be created?

For example: The user is in the English siteaccess and want to white an information request but independently the siteaccess the system may create this object in Spanish.

I know the way to do this using diferent siteacces one of this with Locale=eng-US but whit ContentObjectLocale=esl-ES but I want to know if are any way to do that with other way.

Lex 007

Friday 26 August 2005 1:16:15 am

Hi,

Yes, this is possible programatically.

To set the language as spanish, first do :

eZContentObject::setDefaultLanguage( $language );

Then create your objetct (code taken from the forum, to create a folder) :

$folderClassID=1;
  
  $class =& eZContentClass::fetch( $folderClassID );
  $folderContentObject =& $class->instantiate( $user->id(), $sectionID );
  
  // Create a node for the object in the tree.
  $nodeAssignment =& eZNodeAssignment::create( array(
                         'contentobject_id' => $folderContentObject->attribute( 'id' ),
                         'contentobject_version' => 1,
                         'parent_node' => $userNodeID,
                         'sort_field' => 2, //Published
                         'sort_order' => 1, //Descending
                         'is_main' => 1));
  $nodeAssignment->store();
    
  // Set a status for the content object version
  $folderContentObjectVersion =& $folderContentObject->version($folderContentObject->attribute( 'current_version' ) );
  $folderContentObjectVersion->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT);
  $folderContentObjectVersion->store();

  // Set the title of the folder.
  $folderContentObjectAttributes =& $folderContentObjectVersion->contentObjectAttributes();
  foreach ($folderContentObjectAttributes as $folderAttribute)
  {
    // Each attribute has an attribute called 'identifier' that identifies it.    

    if ($folderAttribute->attribute("contentclass_attribute_identifier") == "title")
    {
      $folderAttribute->setAttribute("data_text",$folderTitle);
      $folderAttribute->store();
    }
  }
      
  // Now publish the object.
  $operationResult = eZOperationHandler::execute( 'content', 'publish',
                          array( 'object_id' => $folderContentObject->attribute( 'id' ),
                                 'version' => $folderContentObject->attribute('current_version' ) ) );
  
  return;

Finally, reset the language to english :

eZContentObject::setDefaultLanguage( $defaultLanguage );

Hope it helps.

Lex

Pablo C. Vergara Castro

Friday 26 August 2005 1:36:56 am

Well well well...thanks Lex... buut...this way is a low level solution (exactly "php level" solution) and I looking for a "template level" solution, any way like putting a input hidden field to change the object language.

I dont have so much time to create an extension to do the solution you write. I think that this things would be solved in the new ez versions.

Well... if you or somebody know a "template level" solution I will be really thankfull.

Greetings.

David Eriksson

Friday 26 August 2005 2:12:23 am

I believe something like this is under development for a future version.

http://ez.no/community/developer/specs/improved_content_multilangue_support

/David

Xavier Dutoit

Friday 26 August 2005 9:48:15 am

Another problem you're going to have:

If you're on the spanish interface and try to edit an article that isn't translated (ie. you see the english version), then you're going to have an empty screen and lots of error messages (it tries to edit the spanish attributes, but don't find them, as they don't exist).

If anyone has a solution...

X+

http://www.sydesy.com

Bertrand Dunogier

Sunday 28 August 2005 10:53:55 am

That's the main issue of the current multilanguage implementation... I think this is going to be addressed before 4.0 (3.8 or 3.7), don't remember, with the suppression of the so-called default language.

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

eZ debug

Timing: Jan 31 2025 03:44:44
Script start
Timing: Jan 31 2025 03:44:44
Module start 'layout'
Timing: Jan 31 2025 03:44:44
Module start 'content'
Timing: Jan 31 2025 03:44:44
Module end 'content'
Timing: Jan 31 2025 03:44:44
Script end

Main resources:

Total runtime0.0243 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 588.2656151.2266
Module start 'layout' 0.00590.0035 739.4922220.7188
Module start 'content' 0.00950.0132 960.21091,005.8672
Module end 'content' 0.02270.0016 1,966.078137.9922
Script end 0.0242  2,004.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002912.1470140.0002
Check MTime0.00124.8091140.0001
Mysql Total
Database connection0.00072.746110.0007
Mysqli_queries0.002811.413830.0009
Looping result0.00000.061910.0000
Template Total0.00124.810.0012
Template load0.00103.982510.0010
Template processing0.00020.816710.0002
Override
Cache load0.00072.865010.0007
General
dbfile0.00239.411880.0003
String conversion0.00000.040340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs