Forums / Developer / Any way to create objects in a specific lenguage?

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.

eZ debug

Timing: Jan 18 2025 16:17:03
Script start
Timing: Jan 18 2025 16:17:03
Module start 'content'
Timing: Jan 18 2025 16:17:04
Module end 'content'
Timing: Jan 18 2025 16:17:04
Script end

Main resources:

Total runtime0.7080 sec
Peak memory usage4,096.0000 KB
Database Queries209

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.9609180.8125
Module start 'content' 0.00510.5765 769.7734685.7031
Module end 'content' 0.58160.1263 1,455.4766341.0547
Script end 0.7080  1,796.5313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.5898210.0002
Check MTime0.00150.2162210.0001
Mysql Total
Database connection0.00050.075910.0005
Mysqli_queries0.629688.92382090.0030
Looping result0.00230.31932070.0000
Template Total0.679796.020.3398
Template load0.00210.292620.0010
Template processing0.677695.702220.3388
Template load and register function0.00010.016210.0001
states
state_id_array0.00040.057510.0004
state_identifier_array0.00140.191820.0007
Override
Cache load0.00180.2536360.0000
Sytem overhead
Fetch class attribute can translate value0.00140.193260.0002
Fetch class attribute name0.00170.240180.0002
XML
Image XML parsing0.00170.243560.0003
class_abstraction
Instantiating content class attribute0.00000.002780.0000
General
dbfile0.00220.3136330.0001
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs