When creating a multi-language drupal site, node "name", "description", "title_label" and "body_label" do not get translated when they are coming from the database.

As an example : When accessing "Create content" in other languages you always get the same untranslated text from the database for "page" and "story".

The problem is existing in the "node.module" of version 5.x and 6.x, it could be corrected easily by modifying the function "_node_types_build()".

Replacing this section :

    if (!isset($_node_types[$type_object->type]) || $type_object->modified) {
      $_node_types[$type_object->type] = $type_object;
      $_node_names[$type_object->type] = $type_object->name;

      if ($type_object->type != $type_object->orig_type) {
        unset($_node_types[$type_object->orig_type]);
        unset($_node_names[$type_object->orig_type]);
      }
    }

With something like this :

    if (!isset($_node_types[$type_object->type]) || $type_object->modified) {
//Begining of modification for allowing translation from database node object.
      $type_object->name = t($type_object->name);
      $type_object->description = t($type_object->description);
      $type_object->title_label = t($type_object->title_label);
      $type_object->body_label = t($type_object->body_label);
//End of modification
      $_node_types[$type_object->type] = $type_object;
      $_node_names[$type_object->type] = $type_object->name;

      if ($type_object->type != $type_object->orig_type) {
        unset($_node_types[$type_object->orig_type]);
        unset($_node_names[$type_object->orig_type]);
      }
    }

Comments

darren.ferguson’s picture

This is a core issue in Drupal i unfortunately can't change it, however i will be looking at getting each seperate content field from the node type and translate each field based off that, this is going to be a future release of this module and not currently supported in this release

darren.ferguson’s picture

Status: Active » Closed (fixed)
jhonatan.ambrosio’s picture

Project: Node Translation » Drupal core
Version: 6.x-1.0 » 6.28
Component: Code » node system
Status: Closed (fixed) » Needs work

Moving to Drupal core queue since this is a core issue and doesn't seem to be fixed until the last D6 release (6.28).

I have a multilingual website and the content types are named in English in the DB. When I'm using the website in another language, node_get_types() statically caches the names in English (because _node_types_build() doesn't translate them)

Then, node_submit_form function (in node.pages.inc) gets the type of the node being added/updated by calling node_get_types() and does NOT translate it. So the node type in the message "@type %title has been created/updated" does not get translated to the correct language.

It could be fixed the way OP suggested or using t() function when calling node_get_types('name', $node)

vitorsdcs’s picture

Priority: Normal » Major
vitorsdcs’s picture

Actually, the content type name can be translated when hook_node_info is invoked. However, if the content type was modified by an admin, _node_types_build() will override its properties (name, description, title, body) with values from the database. It means that the translation will work depending on whether the content type was modified or not. IMO it should try to translate even if it was modified.

vitorsdcs’s picture

Status: Needs work » Needs review
StatusFileSize
new664 bytes

Patch including OP's suggestion

Status: Needs review » Needs work

The last submitted patch, node_types_build_translation-417532.patch, failed testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.