要使API以不同語言加載,您應該在配置中指定lang
。在plusone.js可以加載之前執行此操作。這應該使按鈕和它的屏幕顯示該語言。
下面是一個例子:
<html>
<head>
<title>+1 Demo: Async render</title>
<link rel="canonical" href="http://www.example.com" />
</head>
<body>
<g:plusone></g:plusone>
<script type="text/javascript">
window.___gcfg = {
lang: 'zh-CN'
};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</body>
</html>
然而,對於它的一部分份額,你能肯定的是,當谷歌擦傷你分享它拿起正確的語言的頁面?由於Google使用的用戶代理可能未指定語言,因此您的頁面將作爲默認語言呈現給Google的刮板。也許你應該爲你的頁面使用每種語言的規範網址,谷歌可以正確地抓取它。