diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/http/headers/content-language | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/http/headers/content-language')
-rw-r--r-- | files/zh-cn/web/http/headers/content-language/index.html | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/files/zh-cn/web/http/headers/content-language/index.html b/files/zh-cn/web/http/headers/content-language/index.html new file mode 100644 index 0000000000..194aae784a --- /dev/null +++ b/files/zh-cn/web/http/headers/content-language/index.html @@ -0,0 +1,103 @@ +--- +title: Content-Language +slug: Web/HTTP/Headers/Content-Language +tags: + - 超文本传输协议 + - 首部 +translation_of: Web/HTTP/Headers/Content-Language +--- +<div> </div> + +<p><strong><code>Content-Language</code></strong> 是一个 {{Glossary("entity header")}} (实体消息首部),用来说明访问者希望采用的语言或语言组合,这样的话用户就可以根据自己偏好的语言来定制不同的内容。</p> + +<p>举个例子,假如设置了这样一条消息首部( "<code>Content-Language: de-DE</code>" ),那么说明这份文件是为说德语的人提供的(当然这并不意味着文件本身就是用德语写的。比如,它可能是为说德语的人开设的英语教程的一部分,也就是用英语写的)。</p> + +<p>如果没有指明 <code>Content-Language</code>,那么默认地,文件内容是提供给所有语言的访问者使用的。多个语言标签也是合法的,同样的,这个首部还可以用来描述不同媒体类型的文件,而不单单局限于文本型文档。</p> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">Header type</th> + <td>{{Glossary("Entity header")}}</td> + </tr> + <tr> + <th scope="row">{{Glossary("Forbidden header name")}}</th> + <td>no</td> + </tr> + <tr> + <th scope="row">{{Glossary("Simple response header", "CORS-safelisted response-header")}}</th> + <td>yes</td> + </tr> + <tr> + <th scope="row">{{Glossary("Simple header", "CORS-safelisted request-header")}}</th> + <td>yes</td> + </tr> + </tbody> +</table> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">Content-Language: de-DE +Content-Language: en-US +Content-Language: de-DE, en-CA +</pre> + +<h2 id="指令">指令</h2> + +<dl> + <dt><code>language-tag</code></dt> + <dd>多个语言标签需要用逗号隔开。每一个语言标签都是由一个或多个不区分大小写的子标签构成的,子标签之间用连字号 ("-", %x2D)隔开。通常情况下,一个语言标签是由标识一个大的语言家族的主语言子标签(例如"en" = English),以及后面可选的用来缩小语言范围使更确切的一系列子标签("en-CA" 表示在加拿大范围使用的英语的变种)构成的。</dd> +</dl> + +<div class="note"> +<p><strong>注意:</strong> 语言标签在 <a href="https://tools.ietf.org/html/rfc5646">RFC 5646</a>中被正式定义,它使用的<a href="https://en.wikipedia.org/wiki/Language_code">语言代码</a>依赖于 <a href="https://en.wikipedia.org/wiki/ISO_639">ISO 639</a> 标准(通常为 <a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">ISO 639-1 code list</a>) 。</p> +</div> + +<h2 id="示例">示例</h2> + +<h3 id="声明文档的书写语言">声明文档的书写语言</h3> + +<p>全局的 <code><a href="/en-US/docs/Web/HTML/Global_attributes/lang">lang</a></code> 属性使用在HTML元素去表达全部的 <a href="/en-US/docs/Web/HTML">HTML</a>文档或者部分的语言。</p> + +<pre class="brush: html"><html lang="de"></pre> + +<p>不要使用这个meta元素去声明文档语言:</p> + +<pre class="brush: html example-bad"><!-- /!\ This is bad practice --> +<meta http-equiv="content-language" content="de"></pre> + +<h3 id="为资源指定目标访问者">为资源指定目标访问者</h3> + +<p><code>Content-Language</code> 请求头用于指定<strong>页面的目标受众,</strong>并且可以指明当前页面存在多种语言.</p> + +<pre>Content-Language: de, en</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规格</th> + <th scope="col">表头</th> + </tr> + <tr> + <td>{{RFC("7231", "Content-Language", "3.1.3.2")}}</td> + <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("http.headers.Content-Language")}}</p> + +<h2 id="相关内容">相关内容</h2> + +<ul> + <li>{{HTTPHeader("Accept-Language")}}</li> + <li> + <p><a href="https://www.w3.org/International/questions/qa-http-and-lang.en">HTTP headers, meta elements and language information</a></p> + </li> +</ul> |