The [node:metatag:*] tokens don't get translated properly when using entity translation.

e.g.:
I have an English node, translated to French via entity translation.
The meta description is properly translated and shows the French version when the current language is French.
The og description is set to [node:metatag:description], but this shows the English version for both French and English as current language.

This is because the function that gets the replacement data only checks for the main language of the entity, in stead of first checking the current language.

See "metatag_token_generate_array($entity, $entity_type, $bundle)" at about line 148 of metatags.token.inc

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

L_VanDamme created an issue. See original summary.

L_VanDamme’s picture

Status: Active » Needs review
FileSize
1.4 KB

In attachment a patch made against the 7.x-1.21 version.

DamienMcKenna’s picture

Version: 7.x-1.22 » 7.x-1.x-dev
Status: Needs review » Needs work
Issue tags: -tokens, -token, -metatag

Could you please reroll the patch? Thanks.

brentg’s picture

Rerolled the patch of @L_VanDamme

brentg’s picture

Status: Needs work » Needs review
StijnStroobants’s picture

Status: Needs review » Reviewed & tested by the community

Patch looking fine! Thanks!

StijnStroobants’s picture

Assigned: L_VanDamme » Unassigned
DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks for rerolling the patch, StijnStroobants.

I'm going to need to have us work on some tests to make sure it works as intended and make sure there aren't any regressions.

StijnStroobants’s picture

@DamienMcKenna, brentgees rerolled the patch, credits to him! ;-)

phjou’s picture

Hi,
I've debugging the exact same bug. The current patch is using the global language but Metatag is already passing the language into the options of the tokens. I think it's a better id to use it than the global language because you lose the metatag custom logic. For example, you have the metatag_entity_no_lang_default variable which impact the language.

What do you think?

PieterDC’s picture

Thanks for your hint @phjou

Changing metatag_entity_no_lang_default from 0 (default) to 1 helped, in my case, without needing the patch from this issue.

proweb.ua’s picture

#10 works
7.x-1.27