在Open Graph标记中,如果没有位置(href),'og:locale:alternate'有什么用处?

23

Facebook的Open Graph Protocol标记允许使用类似以下的标记来定义当前网页的语言环境,以及它所在的任何可用的替代语言环境:

<meta property="og:locale" content="en_GB">
<meta property="og:locale:alternate" content="fr_FR">
<meta property="og:locale:alternate" content="es_ES">

可以轻松地从当前页面的URL、规范URL元标签或og:url中推断出永久链接。

但是,如果没有它们各自的URL,包括og:locale:alternate有什么意义呢?这样做有什么用处呢?

1个回答

18
在Facebook官方开发者博客的文章“国际化Open Graph应用程序”中明确说明了:

Translating Objects

In order to translate Open Graph objects, two things must happen. The developer must specify which locales are supported by the object through Open Graph meta tags, and the app must return the correct strings in the requested locale. For example, if the object can be translated into French and Spanish, the markup that describes this would look like the following:

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

When Facebook needs to render an object in one of the specified locales, we will make a request to the object URL with the fb_locale URL parameter set, e.g. &fb_locale=es_ES. The app should then return the object markup in that specified locale. For more details on translating Open Graph objects, please look at the Open Graph I18N doc.

You can debug issues with translating objects by adding a fb_locale parameter, e.g. fb_locale=es_ES, to the Debugger and entering your object URL. If you change or add locales for a particular object, you can make Facebook re-scrape your object to pick up the changes by adding a scrape=true as described in the Objects section in the I18N documentation.


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接