Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opengraph objects only show default locale in stream

I have an opengraph object https://example.com/object that supports multiple locales, specifically en_US and fr_FR with the first as default.

Parsing it in Facebook's Object Debugger correctly shows both locales as og:locale:alternate properties and the default locale as og:locale. Clicking each locale link indeed shows the object in the expected locale.

However, when a user likes the object (passing https://example.com/object as object url, using any like-box locale, and no matter which locale is defined for the user in Facebook), her stream always shows the object in its default en_US locale.

Is this a Facebook issue, or did I miss anything?

NOTE: This question is similar to this one. However, the focus there is on scraping the URL by Facebook, which works fine for me: both fb_locale and X-Facebook-Locale are correctly passed when the url is scraped. Here, the focus is on displaying the scraped url in the stream using the correct locale

like image 933
dleshem Avatar asked Dec 04 '25 07:12

dleshem


1 Answers

The documentation is a bit confusing.

og:locale shouldn't be set to your default locale; it should be set to whichever locale you're currently returning.

Specifically, if Facebook requests fb_locale=fr_FR, you need to return <meta property="og:locale" content="fr_FR"> in the response.

It does make sense. When Facebook sees og:locale="en_US" in the response, it thinks you didn't have a French page to return, so it uses the English content it's already got. It's just not documented very well at all.

Here are my Open Graph locale tags for English:

<meta property="og:locale" content="en_US" />
<meta property="og:locale:alternate" content="en_US" />
<meta property="og:locale:alternate" content="fr_CA" />

And for French:

<meta property="og:locale" content="fr_CA" />
<meta property="og:locale:alternate" content="en_US" />
<meta property="og:locale:alternate" content="fr_CA" />

On getting Facebook to actually use the right content in a dialog, your mileage may vary, but this will at least get the scraper to recognize your content.

like image 90
Aaron Adams Avatar answered Dec 06 '25 16:12

Aaron Adams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!