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]);
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | node_types_build_translation-417532.patch | 664 bytes | vitorsdcs |
Comments
Comment #1
darren.ferguson commentedThis 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
Comment #2
darren.ferguson commentedComment #3
jhonatan.ambrosio commentedMoving 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)
Comment #4
vitorsdcs commentedComment #5
vitorsdcs commentedActually, 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.
Comment #6
vitorsdcs commentedPatch including OP's suggestion