Property labels got from the entity module are left untranslated just after a cache flush

Created on 22 March 2024, over 1 year ago
Updated 22 May 2024, about 1 year ago

This is the continuation of #2296833: Translate field properties used in entity_get_property_info()

When running for instance code below just after a cache flush, the property's label is left untranslated.

<?php
$wrapper = entity_metadata_wrapper('node', NULL, array('bundle' => 'page));
$property_info = $wrapper->getPropertyInfo('field_example');
echo $property_info['label'];
?>

The only stable workaround I've found so far is to run this code before displaying the label of a field:

<?php
$wrapper = entity_metadata_wrapper('node', NULL, array('bundle' => 'my_node_type'));
$property_info = $wrapper->getPropertyInfo('my_field_name');
if ($instance = field_info_instance('node', 'my_field_name', 'my_node_type')) {
  $property_info['label'] = i18n_field_translate_property($instance, 'label');
}
?>
💬 Support request
Status

Needs review

Version

1.0

Component

Documentation

Created by

🇫🇷France anrikun

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024