Because Drupal 7's entity_label() function doesn't accept nor pass through a $langcode parameter to the label callback, the $langcode parameter in title_entity_label() will in fact always be NULL. I filed #1764174: Ensure that all core entity label and URL tokens actually use entity_label() and entity_uri() against Token module to fix this for all core label tokens like [node:title] and [term:name]. But even if we pass a specific language code to entity_lable() in Drupal 7 it does not work, so things like using [node:title] for nodes URL aliases in entity translation don't actually work.
- We should attempt to still fetch the $langcode parameter using debug_backtrace() in title_entity_label(). Is there a core feature request filed against D7 to add $langcode to entity_label()?
- We should remove title_tokens_alter() and encourage people to have token module installed to fix core tokens. Any other entities should be calling entity_label() for their tokens and if not, it's a bug. We should file an issue to fix this in core's token integration.
Also fun fact, title_tokens_alter() does not work for taxonomy terms since the entity type 'taxonomy_term' does not match the token type 'term'.
Comments
Comment #1
dave reidPart one would look like this:
Comment #2
dave reidCross-linking core bug #1764358: Core token values do not use the new entity methods
Comment #3
dave reidI've also filed #1775768: Backport langcode support for all entity labels to actually get real langcode support for Drupal 7's entity_label() since it can be added optionally without modifying or breaking existing code.
Comment #4
plachSorry, I'm pretty busy with porting ET to D8 these days. I'll get back to this ASAP.