Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I internationalize meta og tags to be parsed correctly by Facebook?

I have a grails application with meta og tags like this:

<meta property="og:description" content="${message(code:'description')}"/>

The message properties works fine for i18n if the user's browser send the request. But in case of Facebook it is different. Facebook seems to request alwas the en_US version on my page which means that the meta og tags are always in the wrong language if the user requests the page from a de_DE browser.

Is there a way to tell facebook to use a different request language than en_US?

I tried:

<meta property="og:locale" content="de_DE" />

but this does not change the requested language as well.

What can I do to get the correct i18n?

like image 219
confile Avatar asked Dec 17 '12 23:12

confile


1 Answers

If you setup some og:locale:alternate meta tag, Facebook will rescrape the page by passing a get parameter fb_locale with the value of the locale. For example, if your site is http://mysite.com/share and it present these alternative locales:

<html>
<head>
    <meta property="og:locale:alternate" content="fr_FR" />
    <meta property="og:locale:alternate" content="es_ES" />
    ...
</head>
    ...
</html> 

Facebook will call these url on your site.

http://mysite.com/share
http://mysite.com/share?fb_locale=fr_FR
http://mysite.com/share?fb_locale=es_ES

You then just need to localize you content (and set og:locale) correctly.

Doc is here: https://developers.facebook.com/docs/technical-guides/opengraph/internationalization/

like image 67
Simon Boudrias Avatar answered Oct 03 '22 02:10

Simon Boudrias