Keep protocol identity and locale conventions explicit
The Open Graph protocol defines core object properties and optional locale information, including alternate locales. Its locale notation uses the documented language/territory form. Do not substitute an HTML language tag mechanically and assume every tag system has identical syntax.
For these two fixtures, the explicit mappings are en-US→en_US and de-DE→de_DE. They are not a universal replace-hyphens algorithm for every possible language or script tag. Keep the approved mapping in the source manifest.
Open Graph object identity is also separate from Google canonical selection. This fictional publication approves distinct localized article URLs and self-referencing page canonicals. This is the example’s chosen model, not a protocol requirement that every translation become a separate platform object. The metadata must reflect the approved decision;the presence of og:url does not establish that a search engine selected it or that every platform will display the same card.
Use both complete localized documents
English fixture:
<!doctype html>
<html lang="en-US" prefix="og: https://ogp.me/ns#">
<head>
<meta charset="utf-8">
<title>Verify a recovery result</title>
<link rel="canonical" href="https://journal.example/en/recovery">
<meta property="og:type" content="article">
<meta property="og:url" content="https://journal.example/en/recovery">
<meta property="og:title" content="Verify a recovery result">
<meta property="og:description" content="Check the resulting state before calling a recovery complete.">
<meta property="og:locale" content="en_US">
<meta property="og:locale:alternate" content="de_DE">
<meta property="og:image" content="https://cards.example/recovery-en.png">
<meta property="og:image:alt" content="English recovery verification checklist">
</head>
<body><p>Check the resulting state before calling a recovery complete.</p></body>
</html>
German fixture:
<!doctype html>
<html lang="de-DE" prefix="og: https://ogp.me/ns#">
<head>
<meta charset="utf-8">
<title>Ein Wiederherstellungsergebnis prüfen</title>
<link rel="canonical" href="https://journal.example/de/wiederherstellung">
<meta property="og:type" content="article">
<meta property="og:url" content="https://journal.example/de/wiederherstellung">
<meta property="og:title" content="Ein Wiederherstellungsergebnis prüfen">
<meta property="og:description" content="Prüfen Sie den erreichten Zustand, bevor Sie eine Wiederherstellung als abgeschlossen bezeichnen.">
<meta property="og:locale" content="de_DE">
<meta property="og:locale:alternate" content="en_US">
<meta property="og:image" content="https://cards.example/recovery-de.png">
<meta property="og:image:alt" content="Deutsche Checkliste zur Prüfung einer Wiederherstellung">
</head>
<body><p>Prüfen Sie den erreichten Zustand, bevor Sie eine Wiederherstellung als abgeschlossen bezeichnen.</p></body>
</html>
Each document names its own article object and its own approved card image. The alternate locale refers to the other supported language edition. It does not provide the alternate page URL;do not confuse that property with a hreflang link relationship.
Preserve a populated independent manifest
The approved interface record is:
| Page | HTML language | Object locale | Alternate locale | Approved card |
|---|---|---|---|---|
| /en/recovery | en-US | en_US | de_DE | /recovery-en.png on cards.example |
| /de/wiederherstellung | de-DE | de_DE | en_US | /recovery-de.png on cards.example |
The exact titles, descriptions and image-alt values are the approved teaching values in the printed documents. For the real publisher, store their independently approved records with ownership and source revision. Do not build the expected manifest by reading the same generated head you intend to test.
Use absolute URLs in this interface contract. A document base is not a safe substitute for explicit Open Graph resource identity. If the image host or access policy changes, inspect its actual public response rather than assuming the localized page’s success proves the card asset is available.
Use the complete approved input rows
These JSON rows provide every value consumed by the bounded checker. They are fictional approved inputs, not values inferred from the generated metadata. Keep the expected source record separate from actual output in a real publisher.
[
{
"url": "https://journal.example/en/recovery",
"lang": "en-US",
"locale": "en_US",
"alternate": "de_DE",
"title": "Verify a recovery result",
"description": "Check the resulting state before calling a recovery complete.",
"image": "https://cards.example/recovery-en.png",
"alt": "English recovery verification checklist"
},
{
"url": "https://journal.example/de/wiederherstellung",
"lang": "de-DE",
"locale": "de_DE",
"alternate": "en_US",
"title": "Ein Wiederherstellungsergebnis prüfen",
"description": "Prüfen Sie den erreichten Zustand, bevor Sie eine Wiederherstellung als abgeschlossen bezeichnen.",
"image": "https://cards.example/recovery-de.png",
"alt": "Deutsche Checkliste zur Prüfung einer Wiederherstellung"
}
]
Changing the German object to the English URL must not change this expected record. Otherwise the fixture would redefine the defect as the new baseline. The same applies to a copied description or duplicate title:the acceptance inputs retain the chosen per-edition contract until an authorized owner deliberately changes it.
Run a duplicate-aware field check
Pass each complete printed document and its corresponding approved manifest row to this standard-library function. It performs no platform request. List-valued collection prevents duplicate root properties from being silently overwritten by a dictionary assignment.
from html.parser import HTMLParser
class ShareHead(HTMLParser):
def __init__(self):
super().__init__()
self.fields = {}
self.lang = None
def handle_starttag(self, tag, attrs):
values = dict(attrs)
if tag == 'html':
self.lang = values.get('lang')
if tag == 'meta' and values.get('property', '').startswith('og:'):
self.fields.setdefault(values['property'], []).append(values.get('content'))
def check(html_text, expected):
parsed = ShareHead()
parsed.feed(html_text)
assert parsed.lang == expected['lang']
wanted = {
'og:type': 'article', 'og:url': expected['url'],
'og:title': expected['title'], 'og:description': expected['description'],
'og:locale': expected['locale'], 'og:image': expected['image'],
'og:image:alt': expected['alt']
}
for name, value in wanted.items():
assert parsed.fields.get(name) == [value], name
assert parsed.fields.get('og:locale:alternate') == [expected['alternate']]
return True
This fixture expects one alternate locale for each page. A real publication with more supported editions needs its actual approved alternate set and applicable protocol representation. The function is intentionally bounded to the two-object contract above, not a universal social-preview validator.
Require copied identity and copy to fail
First, replace the German page’s og:url with the English URL. Its visible language and heading can remain German while the object identity is copied. The exact URL comparison must fail.
Second, use de-DE in the Open Graph locale field while retaining the expected de_DE protocol value. The format assertion must fail. Third, copy the English description into the German object. The approved-field comparison must detect the mismatch without pretending to identify German semantically.
A fourth negative duplicates og:title with another value. A last-value-wins parser could hide the conflict;the collected list must reject it. Restore the baseline between mutations and preserve the actual emitted order when diagnosing duplicate contributors.
Verify output without promising a platform refresh
Inspect the ordinary initial HTML from each public route and the exact card asset responses. A client-only correction after page load is not the same evidence as the delivered metadata. Preserve the actual collection method and any authorization limitations.
Use the image delivery check for stable public assets. Use the translated-claim review to verify meaning when the underlying product explanation changes. The field parser supplies neither image permission nor language expertise.
Close when both emitted objects match their approved localized experiences and their known relationships. Later share-card appearance or cache refresh remains a separately observed platform result. Correct tags do not guarantee a particular crop, display date, click-through rate or generated-answer interpretation.
