HTML:多语言元描述? [英] HTML: Multiple language meta descriptions?

查看:62
本文介绍了HTML:多语言元描述?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的网站上设置两种语言元描述?



此代码是否有效?

 < meta name =descriptionlang =encontent =english blablabla/> 
< meta name =descriptionlang =hucontent =hungary blablabla/>


解决方案

从Google网站管理员中心博客中查看此帖: http://googlewebmastercentral.blogspot.com.es/2010/03 /working-with-multilingual-websites.html



Google试图确定您的每个网页的主要语言。如果您坚持每页仅使用一种语言并避免并行翻译,尽量让语言识别更容易,尽管Google可以将页面识别为使用多种语言,但我们建议对页面的所有元素使用相同的语言:标题,侧边栏,菜单等。
请记住,Google会忽略所有代码级语言信息,从lang属性到文档类型定义(DTD)。这些属性是自动的,因此在尝试时它们不是很可靠以确定网页的语言。



有关多语言网站的一些信息:



由于htmllang属性不允许定义多种语言,并且指定语言的元属性已过时,所以根据W3的建议,最好在HTTP标头中指定语言。

  HTTP / 1.1·200·OK 
日期:·星期六,·23·7月·2011·07:28:50·GMT
服务器:· Apache / 2
Content-Location:·qa-http-and-lang.en.php
Vary:·协商,接受语言,接受编码
TCN:·选择
P3P:·policyref =http://www.w3.org/2001/05/P3P/p3p.xml
连接:·关闭
传输编码:·分块
内容型:·为text / html; charset = utf-8
Content-Language:·en

http-equiv属性设置为Content-Language,HTTP标头的值可以是以逗号分隔的语言标签列表

请参阅:
http://tools.ietf.org/html/rfc2616#section-14.12



正如RFC2616所述:

 可能会列出多种语言为
多个观众。例如,在原始的毛利语和英语
版本中同时出现的b $ b Waitangi条约的演绎将要求

Content-Language:mi,en

如果您转到 http://validator.w3.org/check 并尝试验证这一点:

  <!DOCTYPE html> 
< html>
< head>
< title>测试< /标题>
< meta http-equiv =Content-Languagecontent =en,hu>
< meta charset =UTF-8>
< / head>
< body>
< p>测试< / p>
< / body>
< / html>



验证工具说:

 第5行,第52列:使用meta元素指定文档范围的默认语言已过时。考虑改为在根元素上指定语言。 

然后,如果html标签上的lang属性不允许多种语言,我认为您的最佳尝试将会请在HTTP标头中指定它

How can I set two language meta descriptions to my website?

Is this code google valid?

<meta name="description" lang="en" content="english blablabla" />
<meta name="description" lang="hu" content="hungary blablabla" />

解决方案

Check this post from Google Webmaster Central Blog: http://googlewebmastercentral.blogspot.com.es/2010/03/working-with-multilingual-websites.html

"Google tries to determine the main languages of each one of your pages. You can help to make language recognition easier if you stick to only one language per page and avoid side-by-side translations. Although Google can recognize a page as being in more than one language, we recommend using the same language for all elements of a page: headers, sidebars, menus, etc. Keep in mind that Google ignores all code-level language information, from "lang" attributes to Document Type Definitions (DTD). Some web editing programs create these attributes automatically, and therefore they aren’t very reliable when trying to determine the language of a webpage."

Some info about multi languages websites:

Since html "lang" attribute doesn't allow define multiple languages, and meta attribute for specify language is obsolete, according to W3 recommendations, it's better to specify language in the HTTP header.

HTTP/1.1·200·OK
Date:·Sat,·23·Jul·2011·07:28:50·GMT
Server:·Apache/2
Content-Location:·qa-http-and-lang.en.php
Vary:·negotiate,accept-language,Accept-Encoding
TCN:·choice
P3P:·policyref="http://www.w3.org/2001/05/P3P/p3p.xml"
Connection:·close
Transfer-Encoding:·chunked
Content-Type:·text/html; charset=utf-8
Content-Language:·en

Like the meta element with the http-equiv attribute set to Content-Language, the value of the HTTP header can be a comma-separated list of language tags

See: http://tools.ietf.org/html/rfc2616#section-14.12

As RFC2616 says:

Multiple languages MAY be listed for content that is intended for
   multiple audiences. For example, a rendition of the "Treaty of
   Waitangi," presented simultaneously in the original Maori and English
   versions, would call for

       Content-Language: mi, en

If you go to http://validator.w3.org/check and try to validate this:

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Language" content="en,hu">
<meta charset="UTF-8">
</head>
<body>
<p>Test</p>
</body>
</html>

W3 validator tool says:

Line 5, Column 52: Using the meta element to specify the document-wide default language is obsolete. Consider specifying the language on the root element instead.

Then, if lang attribute on html tag doens't allow multiple languages, I think your best try will be specify it in HTTP header

这篇关于HTML:多语言元描述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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