Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
1) enable language support on a node type
2) create in a different language (japanese for example)
3) Override metatag description
4) publish node and view while using default language (English for example
Expected: overridden metatag description used
Actual: default metatag description used.
When viewing the node with the site in the language of the node, the correct metatag is used.
Comment | File | Size | Author |
---|---|---|---|
#19 | metatag-n2185791-19.patch | 4.35 KB | DamienMcKenna |
#15 | metatag-n2185791-15.patch | 4.58 KB | DamienMcKenna |
Comments
Comment #1
DamienMcKennaSo you're saying that the node was created in Japanese, i.e. $node->language = 'jp', and when you view the node in English you don't see the customized meta tags? Isn't that how it should work?
Comment #2
hefox CreditAttribution: hefox commentedImagine it from perspective of a user -- they are an English speaker entering in Japanese content for their Japanese speakers, so their user language is set to English, but the content they are creating is in Japanese. They go to the meta tag section and override some metatag information and press save. They check the content, making sure it's ready to go, including checking the meta information. However, what they entered is not there, and instead whatever the default settings is. When they were entering content, they had no setting for entering metadata for different languages, just for that single piece of Japanese content, e.g. that content has a single setting and it's not using that setting.
May not be a functional bug, but seems def a UX or such; looking at the code, I didn't see any fault there. Logically, everything made sense, but the result is confusing for the user.
Comment #3
Blackice2999 CreditAttribution: Blackice2999 commentedHi,
a other example for this bug is. If you have untranslatable content types they are always with the default language as language set. So nodes that you can see on different language pages the metatag is only be vissible under one language. For "robot" metatags this is a unwanted behavior.
If i understand the concept currently right the metatag module select the right metatag settings with hook_entity_view by building a cache key based upon the entity language. But exactly this is the problem... the node is in englisch and the currently language is a other language (for example DE) so the cache must be misses because the language identifer is part of the cache key.
Possible Idea for a solution:
This will be no fast and workaround but i think this is neccesary for the future. Use a field that stores the cache idenfier on entity save. So if you save the entity the field value is by default in LANGUAGE_NONE ... now we can use entity_translation to store a cache identifer per language... this can be done on top of current metatag implementation and could be a extra module "metatag_field"
What do you think about it?
Comment #4
DamienMcKennaComment #5
DamienMcKennaDoes #2025425: Multilingual nodes with translated fields don't always output correct language metatags due to caching resolve this?
Comment #6
DamienMcKennaComment #7
hefox CreditAttribution: hefox commentedI don't think so; I believe we were using that patch and the issue remained (not a developer on the project that is experiencing this anymore)
Comment #8
DamienMcKennaThis should be fixed in the latest -dev release, which will be the 1.0-rc1 release soon. If the problem persist feel free to reopen it and provide further details.
Comment #9
DamienMcKennaOk, I was contacted by someone experiencing this and have confirmed the problem.
Comment #10
DamienMcKennaGoing to fix this for the next release.
Now that we have a settings page I'm thinking of making this customizable, i.e. provide an option to control whether the entity's default language should be used if present if there is nothing currently available for the current language. I might even default the option to "on". What do you think, hefox?
Comment #11
DamienMcKennaThis adds a new option on the Advanced Settings page which makes Metatag use the entity's default language's values if none were found for the current language.
Comment #12
DamienMcKennaFYI the above reworks the language handling a little so needs further testing.
Comment #13
hefox CreditAttribution: hefox commentedNot active in a project that is using metatags and languages at the moment, but seems good from a brief looksee
Comment #14
DamienMcKennaAdded a note to the README.txt about the new option.
Comment #15
DamienMcKennaThis simplifies the logic when deciding what language to use:
Because we're now loading all of the meta tags for all languages during entity_load() I think it's safe to do this.
Comment #16
DamienMcKennaCommitted. Hopefully this will help.
Comment #18
DamienMcKennaAfter thinking on it further, I'm going to change the default to the reverse of the current situation - automatically load the meta tags, with an option to disable it.
Comment #19
DamienMcKennaThis patch reverses the logic so that values saved for the the entity's default language will be used should there not be any assigned for the current language.
Comment #20
DamienMcKennaComment #21
DamienMcKennaCommitted.
Comment #25
mfbIs there a way to set this option per-metatag?
For example, I always want to use a language-specific metatag for the canonical URL - if the canonical URL defaulted to that of the default language, then, for example the French version of a page would have its canonical URL set to that of its English version, instructing search engines not to index the French page.
However, for other metatags, like an image, I always want the non-English versions to use the metatag defined on the English version if a language-specific metatag wasn't defined.