如何实现OG标签的国际化? [英] How to implement internationalization of OG-Tags?

查看:194
本文介绍了如何实现OG标签的国际化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于即将到来的项目,我们将将我们的应用程序翻译成多种语言。看看Facebook的操作方法:打开图表国际化页面,您将获得非常详细的信息这样做。



所以我们正确地实现了这些标签。当用英语说的用户查看该页面时,您将得到:

 < meta property =og:urlcontent = https://site.url/> 
< meta property =og:titlecontent =英文标题/>
< meta property =og:descriptioncontent =英文描述/>
< meta property =og:localecontent =en_US/>
< meta property =og:locale:alternatecontent =de_DE/>

对于德国用户,反之亦然:

 < meta property =og:urlcontent =https://site.url/> 
< meta property =og:titlecontent =German title/>
< meta property =og:descriptioncontent =德语描述/>
< meta property =og:localecontent =de_DE/>
< meta property =og:locale:alternatecontent =en_US/>

如文档中所述,我们来看看?fb_locale-get参数,另外,解析HTTP_X_FACEBOOK_LOCALE标题以决定哪个翻译应该显示。



所以,我的问题如下:


  1. 使用Facebook Debugger(调试器中使用的任何语言(如locale = de_DE eg))调试提到的URL时,会显示英文文本。这是调试器或预期行为的错误吗?


  2. 当在调试器中单击备用语言环境链接时,会将一个?locale = de_DE附加到调试器-url界面正在变成德国。但是,由于刮擦的文本保留在英文中,所以本地区不会传递给url本身。任何关于这一点的提示?


  3. 当手动将?fb_locale = de_DE参数附加到调试器中的url时,调试器的对象属性部分仍然是英文,而原始打开图形文档信息则包含德文翻译。这是正确的还是应该对象属性更新?


  4. 有没有任何网站使用适当的国际化的og标签,你知道?在野外看到一个功能完整的例子将是非常棒的。


  5. 将Facebook提供的站点URL直接粘贴到Facebook新闻源(作为德国Facebook用户)时,Facebook只会显示英文文本。在这种情况下,当一切都正确执行时,不应该显示德文吗?



解决方案>

我有同样的问题,并写信给Facebook支持。他们的答案是这样的:


... Open Graph Localization的用例不是用于在Facebook上共享链接并具有元数据本地化。相反,它被用作自定义Open Graph故事的一部分,例如X完成了一个级别。



基本上,当使用链接发布打开的图形故事时一个自我托管的对象,那么我们才发送fb_locale参数和X-Facebook-Locale HTTP头。


你可以关注这个链接了解详情: https://developers.facebook.com/bugs/141601252889984


for an upcoming project we wanna translate our app to multiple languages. Having a look at Facebook's How-To: Open Graph Internationalization page, you get very detailed information on doing this.

So, we implemented the tags correctly. When viewing the page as a english-speaking user, you get:

<meta property="og:url" content="https://site.url" />
<meta property="og:title" content="English title" />
<meta property="og:description" content="English description" />
<meta property="og:locale" content="en_US" />
<meta property="og:locale:alternate" content="de_DE" /> 

For german users, it looks like vice-versa:

<meta property="og:url" content="https://site.url" />
<meta property="og:title" content="German title" />
<meta property="og:description" content="German description" />
<meta property="og:locale" content="de_DE" />
<meta property="og:locale:alternate" content="en_US" /> 

As described in the documentation, we look at the "?fb_locale"-get parameter and in addition, parse the HTTP_X_FACEBOOK_LOCALE header to decide, which translation should be displayed.

So, my questions are as following:

  1. When debugging the mentioned url with Facebook Debugger (whatever language used in the debugger (with ?locale=de_DE e.g.)) english texts are displayed. Is this a bug of debugger or intended behavior?

  2. When clicking of the alternate locale link within debugger, a ?locale=de_DE is attached to the debugger-url and the interface is changing to german. but the locale isn't passed to the url itself, as it looks, because the scraped texts remain in english. Any hints on this one?

  3. When manually attaching the "?fb_locale=de_DE" parameter to the url in the debugger, the "object properties" section of the debugger remains english, whereas the "raw open graph document information" contains the german translations. Is this correct or should the "object properties" update as well?

  4. Is there any site out there using proper internationalization of og-tags that you know of? It would be awesome to see a fully-functional example in the wild.

  5. When pasting the mentioned site url directly in Facebook newsfeed (as an user with german Facebook), Facebook displays only the english og texts. Shouldn't it display the german texts in this scenario, when everything's implemented correctly?

解决方案

I had the same problem and wrote to facebook support. Their answer was like this:

... The use case for Open Graph Localization is not for sharing links on Facebook and having the meta data localized. Instead it is meant to be used as part of custom Open Graph stories such as "X completed a level".

Basically when an open graph story is published using a link to a self-hosted object, only then will we send the fb_locale parameter and X-Facebook-Locale HTTP header.

You can follow this link for details: https://developers.facebook.com/bugs/141601252889984

这篇关于如何实现OG标签的国际化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆