diff --git a/includes/common.inc b/includes/common.inc index bce818d..7fe20b4 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -7796,7 +7796,14 @@ function entity_language($entity_type, $entity) { } else { // @todo The right value for D8 should be LANGUAGE_NONE, we cannot use it - // here to preserve backward compatibility. + // here to preserve backward compatibility. In fact this function has been + // introduced very late in the D7 life cycle as the proper default value for + // field_attach_form(). By returning LANGUAGE_NONE when no language + // information is available, we would introduce a potentially BC-breaking + // API change, since field_attach_form() defaults to the default language + // instead of LANGUAGE_NONE. Moreover this allows us to distinguish between + // entities that have no language specified from ones that do not have + // language support at all. $langcode = NULL; } diff --git a/modules/system/system.api.php b/modules/system/system.api.php index c551e22..d749250 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -97,6 +97,14 @@ function hook_hook_info_alter(&$hooks) { * instead specify a callback function here, which will be called to * determine the entity label. See also the entity_label() function, which * implements this logic. + * - language callback: (optional) A function taking an entity and an entity + * type as arguments and returning the language the entity has been created + * in. This value may be changed when editing the entity and represents the + * language its textual components are supposed to have. In most situations, + * when needing to determine this value, inspecting a property named after + * the 'language' element of the 'entity keys' should be enough. However + * some entity types might not define such a property, in which case the + * language callback can be used to return the proper value. * - fieldable: Set to TRUE if you want your entity type to accept fields * being attached to it. * - translation: An associative array of modules registered as field @@ -123,6 +131,9 @@ function hook_hook_info_alter(&$hooks) { * 'subject' should be specified here. If complex logic is required to * build the label, a 'label callback' should be defined instead (see * the 'label callback' section above for details). + * - language: The name of the property that contains the entity language + * code, typically 'language'. If no language property is available, the + * 'language callback' may be used instead. * - bundle keys: An array describing how the Field API can extract the * information it needs from the bundle objects for this type. This entry * is required if the 'path' provided in the 'bundles'/'admin' section