Problem/Motivation
At the moment, we have some annotations for tags that provide metadata about its contents.
E.g. image = FALSE.
It would be great having more metadata for treating this from other modules. E.g. type = image, type = label, type = url, type = string.
My usecase: I want to extract metadata tags and send them to third-party translation services. It makes sense to translate "twitter:title", but not to translate "twitter:card", which values are defined from a closed list of strings.
Proposed resolution
Add a type annotation and deprecate the image annotation.
Remaining tasks
Agree, implement patch, add tests
User interface changes
None,
API changes
Added type annotation, deprecated image.
Data model changes
None,
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | metatag-n2692117-9.interdiff.txt | 419 bytes | damienmckenna |
| #9 | metatag-n2692117-9.patch | 44.44 KB | damienmckenna |
Comments
Comment #2
damienmckennaDid you see #2690973: Make all tags translatable? Will it help?
Comment #3
damienmckennaYeah, thinking through it, this could be a useful way of doing it. Good idea. Might also backport the API change to D7.
Comment #4
penyaskito@Damien, I saw that one. But if I'm right, that one is about translating the labels of the metatags, not the metatag values assigned to content.
In case of tag values, IMHO we should only translate those that are human-facing texts, not all of them.
Comment #5
penyaskitoThis replaces the image annotation tag with a type tag. Used values are: integer, string, label, image, uri. I'm wondering how we could benefit from using TypedData here, as we may be able of take validation and other candies from that.
This patch doesn't contain any new tests, existings tests pass.
Comment #6
penyaskitoOops, use the right typed data labels in the generator command.
Comment #7
damienmckennaWhat's the difference between a 'label' and a 'string'?
This just adds the 'type' field for the twitter:image:alt tag.
Comment #8
damienmckennaThe interdiff for #7.
Comment #9
damienmckennaThis improves the documentation in src/Annotation/MetatagTag.php.
Comment #10
damienmckenna@penyaskito: Is there an existing standard in core somewhere that would be similar to the 'type' attribute?
Comment #12
damienmckennaCommitted, any improvements can be handled as separate issues.
Comment #13
penyaskito@Damien, I tried to reuse types from Typed Data API, but not sure if it will make sense in every case. In any case we are not validating that the annotation contains a valid identifier in any case.
The difference between a string and a label is that the label is a translatable text, usually a text an end-user will see. The string usually is just a string which translation is a non-sense or problematic.
E.g. The Twitter Card type is a string (e.g. "summary" value), but the description metatag is a label. We want to translate our description values, but translating the twitter card type value can have unexpected results.
As this ToDo I added says, we should be inferring these allowed values from TypedData API in case it is extended somehow. We just have a hard-coded list of allowed values now.
Thanks for committing, it makes sense to me to improve in further issues.
Comment #14
damienmckenna@penyaskito: Thanks for the extra info!