支持og:locale:alternate

时间:2014-10-16 15:09:45

标签: facebook-opengraph

我们有一个支持多种语言环境的站点,但是由于我们的大部分请求都是通过瑞典数据中心进行路由,因此我们所有的opengraph元数据都将以瑞典语返回。

我已更新我们的代码以查找X-Facebook-Locale请求标头和fb_locale查询参数,并根据该标准设置网站的区域设置。我还添加了我们网站支持的所有语言环境的元属性。

该网站是:

http://mixrad.io/mixes/seeded/?artists=Madonna%2CSheryl%20Crow%2CKylie%20Minogue&s=fb8e5e45-a82c-4577-a01a-81ab358a5a81

我们的opengraph标签是:

<meta name="description" content="MixRadio. It’s like having your own personal radio station. #MixRadio">
<meta property="og:site_name" content="MixRadio"/>

<meta property="og:locale" content="en_GB"/>
<meta property="og:locale:alternate" content="de_AT"/>
<meta property="og:locale:alternate" content="de_CH"/>
<meta property="og:locale:alternate" content="de_DE"/>
<meta property="og:locale:alternate" content="en_AU"/>
<meta property="og:locale:alternate" content="en_CA"/>
<meta property="og:locale:alternate" content="en_GB"/>
<meta property="og:locale:alternate" content="en_IE"/>
<meta property="og:locale:alternate" content="en_IN"/>
<meta property="og:locale:alternate" content="en_SG"/>
<meta property="og:locale:alternate" content="en_US"/>
<meta property="og:locale:alternate" content="en_ZA"/>
<meta property="og:locale:alternate" content="es_ES"/>
<meta property="og:locale:alternate" content="es_MX"/>
<meta property="og:locale:alternate" content="fi_FI"/>
<meta property="og:locale:alternate" content="fr_CA"/>
<meta property="og:locale:alternate" content="fr_CH"/>
<meta property="og:locale:alternate" content="fr_FR"/>
<meta property="og:locale:alternate" content="id_ID"/>
<meta property="og:locale:alternate" content="it_IT"/>
<meta property="og:locale:alternate" content="nb_NO"/>
<meta property="og:locale:alternate" content="nl_NL"/>
<meta property="og:locale:alternate" content="pl_PL"/>
<meta property="og:locale:alternate" content="pt_BR"/>
<meta property="og:locale:alternate" content="pt_PT"/>
<meta property="og:locale:alternate" content="ru_RU"/>
<meta property="og:locale:alternate" content="sv_SE"/>
<meta property="og:locale:alternate" content="th_TH"/>
<meta property="og:locale:alternate" content="tr_TR"/>
<meta property="og:locale:alternate" content="vi_VN"/>
<meta property="og:locale:alternate" content="zh_CN"/>

<meta property="twitter:card" content="summary"/>
<meta property="twitter:site" content="@MixRadio"/>
<meta property="og:description" content="MixRadio. It’s like having your own personal radio station."/>
<meta property="twitter:description" content="MixRadio. It’s like having your own personal radio station."/>
<meta property="og:title" content="Madonna,Sheryl Crow,Kylie Minogue"/>
<meta property="twitter:title" content="Madonna,Sheryl Crow,Kylie Minogue"/>
<meta property="twitter:image:src" content="http://asset.ent.nokia.com/asset/artists/200x200/372444.jpg"/>
<meta property="og:image" content="http://asset.ent.nokia.com/asset/artists/200x200/372444.jpg"/>
<meta property="og:image:type" content="image/jpeg"/>
<meta property="og:image:width" content="200"/>
<meta property="og:image:height" content="200"/>
<meta property="og:type" content="music.radio_station"/>
<meta property="og:url" content="http://www.mixrad.io/gb/en/mixes/seeded/?s=fb8e5e45-a82c-4577-a01a-81ab358a5a81"/>
<meta property="og:audio" content="http://www.mixrad.io/gb/en/mixes/seeded/?s=fb8e5e45-a82c-4577-a01a-81ab358a5a81"/>
<meta property="og:audio:type" content="audio/vnd.facebook.bridge"/>

当它从瑞典数据中心抓取时,&#34; og:locale&#34;是sv_SE。

现在我已经把所有的og:locale:替换属性放入,facebook调试器给了我这条消息:

网址&#39; http://www.mixrad.io/se/sv/mixes/seeded/?s=47a36fcd-235b-4b20-9088-6f89353a9728&#39;类型&#39; music.radio_station&#39;是无效的,因为给定的值&#39; de_at&#39;对于财产&#39; og:locale:alternate&#39;无法解析为类型&#39; enum&#39;。

是否有人能够帮助我弄清楚如何让用户以正确的语言呈现我们的元标记?

由于

更新: &#39; de_at&#39; enum问题是由于Facebook不支持该区域设置,删除facebook不支持的区域设置已经摆脱了该特定错误,但一切仍然以瑞典语出现。

1 个答案:

答案 0 :(得分:0)

Facebook并不支持每个语言环境,这里列出了他们所做的:https://www.facebook.com/translations/FacebookLocales.xml

据我所知,Facebook最初在不指定区域设置的情况下擦除您的网站,然后在您的元标记表示您支持的每个区域设置上刮一次。正如您所提到的,当您的服务器看到X-Facebook-Locale标头或其查询参数时,您需要动态更改每个元标记的content属性。

您负责呈现网页的方式,您可能希望使用用户请求中发送的标头来确定语言。如果您有opengraph语言环境支持,Facebook不会查看页面内容,它只会查看元标记并缓存在渲染预览时它在Facebook中向其用户显示的内容。