lang=unknown 属性是否有效? [英] Is lang=unknown attribute valid?

查看:19
本文介绍了lang=unknown 属性是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个特定语言(英语)的 HTML 文档.

Given an HTML document in a specific language (english).

我在标签上定义了一个 lang 属性:

I have defined a lang attribute on the tag :

<html lang="en">

页面中的某些文本是用另一种语言(例如法语)编写的:

Some texts in the page are written in another language (for example french) :

<span lang="fr">
  blabla...
</span>

但是,如果我无法识别语言,但我知道它不是英语,我可以将unknown"设置为 lang 属性的有效值吗?

But, if I can not identify the language, but I know it is NOT english, can I set "unknown" as a valid value for lang attribute?

<span lang="unknown">
  blabla...
</span>

我在 w3c 文档中读到了这个,但我不确定默认值是 [...] 未知"是否意味着未知"是一个真正的值...

I read this in w3c documentation, but I am not sure if "the default value is [...] unknown" means that "unknown" is a real value...

http://www.w3.org/TR/html4/struct/dirlang.html

lang = 语言代码 [CI]此属性指定元素的属性值和文本内容的基本语言.该属性的默认值未知.

推荐答案

HTML 4.01 规范中的措辞含糊不清;值 unknown 不是有效的语言标签,规范使用单词unknown"作为普通的英语单词.即默认值是一个表示语言未知的值,但没有明确指定该值.

The wording in the HTML 4.01 specification is obscure; the value unknown is not a valid language tag, and the spec uses the word "unknown" as a normal English word. That is, the default value is a value that indicates that the language is not known, but this value is not explicitly specified.

该规范在该领域部分已过时,因为它引用了已被取代的关于语言标签的 RFC.当前的 RFC 是 RFC 5646,用于识别语言的标签,也称为 BCP(Best Current Practice)47. 除其他外,它参考了 ISO 639-2 关于主要语言标签的内容,其中包含未确定"的代码 und.因此,从技术上讲,您可以使用 lang=und,但 RFC 说:除非需要语言标记并且语言信息不可用或无法确定,否则不应使用此子标记.最好省略语言标签(在允许的情况下)."

The spec is partly outdated in this area, as it refers to a superseded RFC on language tags. The current RFC is RFC 5646, Tags for Identifying Languages, also known as BCP (Best Current Practice) 47. It refers, among other things, to ISO 639-2 as regards to primary language tags, and they contain the code und for "undetermined". So technically you could use lang=und, but the RFC says: "This subtag SHOULD NOT be used unless a language tag is required and language information is not available or cannot be determined. Omitting the language tag (where permitted) is preferred."

这是 HTML5 RC 中采用的方法,它表示 关于lang:将属性设置为空字符串表示主要语言未知.[BCP47]"

And this is the approach adopted in HTML5 RC, which says about lang: "Setting the attribute to the empty string indicates that the primary language is unknown. [BCP47]"

因此,对于无法识别语言的文本,您可以使用例如<span lang="">...</span>.

Thus, for text in unidentifiable language you can use e.g. <span lang="">...</span>.

原则上,当您在元素嵌套的更高级别指示语言时,这很有用.例如,设置 lang="" 可能意味着用户代理禁用拼写检查和特定于语言的格式,尽管这仍然是理论上的.

This is, in principle, useful when you have indicated the language at a higher level of element nesting. Setting lang="" may mean that user agents disable spelling checks and language-specific formatting, for example, though this is still rather theoretical.

这篇关于lang=unknown 属性是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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