我可以在我的表单元素上配置拼写检查属性使用的字典语言吗?
Can I configure the dictionary language used by the spellcheck attribute on my form elements?
我需要将 spellcheck
属性添加到几个 <textarea>
和 <input>
元素。我的问题是:"Is the version of English that spellcheck
adheres to configurable?" 我在澳大利亚,我们使用英式英语。我的理解是拼写检查器默认配置为美式英语。
它与最初在 html
元素上设置的 lang
属性有什么关系吗?
我相信我已经找到了这个问题的答案,并且在这个过程中学习了英语。
language codes would suggest that the version of English is not configurable. However, I found a more detailed W3C Working Group Note的W3C参考资料如下:
Note 2: Allowed values for the lang and xml:lang attributes are indicated in the resources referenced below. Language tags use a primary code to indicate the language, and optional subcodes (separated by hyphen characters) to indicate variants of the language. For instance, English is indicated with the primary code "en"; British English and American English can be distinguished by using "en-GB" and "en-US", respectively. Use of the primary code is important for this technique. Use of subcodes is optional but may be helpful in certain circumstances.
这是子代码的完整列表:ISO 3166-1 alpha-2。
这意味着以下任何一个值在技术上都是有效的; lang="en-AU"
、lang="en-GB"
和 lang="en-US"
。
我 运行 进行了两项测试,以确定 spellcheck
如何处理这些语言子代码(参见代码段)。我 运行 这些测试是在 macOS High Sierra 版本 10.13.2 和 Safari 版本 11.0.2,Chrome 版本 63.0.3239.132 和 Firefox 版本 57.0.4 并且结果不一。
None 我测试的浏览器似乎受到对各种元素的 lang
属性声明的影响。我在系统级别打开和关闭词典进行了测试。
我首先测试了 Safari 和 Chrome,结果相同:
然后我测试了 Firefox 并得到了这个结果:
所以总而言之:"Yes" 使用 lang
属性时可以配置英语版本。 "No"、spellcheck
似乎无法配置为您使用 lang
属性声明的语言,而是浏览器配置的英语版本。
我希望这个回答对其他人有帮助。
<!-- Test #1 -->
<textarea lang="en-AU" spellcheck="true"></textarea>
<textarea lang="en-GB" spellcheck="true"></textarea>
<textarea lang="en-US" spellcheck="true"></textarea>
<div contenteditable="true" lang="en-AU" spellcheck="true">insert spelling</div>
<div contenteditable="true" lang="en-GB" spellcheck="true">insert spelling</div>
<div contenteditable="true" lang="en-US" spellcheck="true">insert spelling</div>
<!-- Test #2 -->
<!DOCTYPE html>
<html lang="en-AU">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<textarea spellcheck="true"></textarea>
<div contenteditable="true" spellcheck="true">insert spelling</div>
</body>
</html>
我需要将 spellcheck
属性添加到几个 <textarea>
和 <input>
元素。我的问题是:"Is the version of English that spellcheck
adheres to configurable?" 我在澳大利亚,我们使用英式英语。我的理解是拼写检查器默认配置为美式英语。
它与最初在 html
元素上设置的 lang
属性有什么关系吗?
我相信我已经找到了这个问题的答案,并且在这个过程中学习了英语。
language codes would suggest that the version of English is not configurable. However, I found a more detailed W3C Working Group Note的W3C参考资料如下:
Note 2: Allowed values for the lang and xml:lang attributes are indicated in the resources referenced below. Language tags use a primary code to indicate the language, and optional subcodes (separated by hyphen characters) to indicate variants of the language. For instance, English is indicated with the primary code "en"; British English and American English can be distinguished by using "en-GB" and "en-US", respectively. Use of the primary code is important for this technique. Use of subcodes is optional but may be helpful in certain circumstances.
这是子代码的完整列表:ISO 3166-1 alpha-2。
这意味着以下任何一个值在技术上都是有效的; lang="en-AU"
、lang="en-GB"
和 lang="en-US"
。
我 运行 进行了两项测试,以确定 spellcheck
如何处理这些语言子代码(参见代码段)。我 运行 这些测试是在 macOS High Sierra 版本 10.13.2 和 Safari 版本 11.0.2,Chrome 版本 63.0.3239.132 和 Firefox 版本 57.0.4 并且结果不一。
None 我测试的浏览器似乎受到对各种元素的 lang
属性声明的影响。我在系统级别打开和关闭词典进行了测试。
我首先测试了 Safari 和 Chrome,结果相同:
然后我测试了 Firefox 并得到了这个结果:
所以总而言之:"Yes" 使用 lang
属性时可以配置英语版本。 "No"、spellcheck
似乎无法配置为您使用 lang
属性声明的语言,而是浏览器配置的英语版本。
我希望这个回答对其他人有帮助。
<!-- Test #1 -->
<textarea lang="en-AU" spellcheck="true"></textarea>
<textarea lang="en-GB" spellcheck="true"></textarea>
<textarea lang="en-US" spellcheck="true"></textarea>
<div contenteditable="true" lang="en-AU" spellcheck="true">insert spelling</div>
<div contenteditable="true" lang="en-GB" spellcheck="true">insert spelling</div>
<div contenteditable="true" lang="en-US" spellcheck="true">insert spelling</div>
<!-- Test #2 -->
<!DOCTYPE html>
<html lang="en-AU">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<textarea spellcheck="true"></textarea>
<div contenteditable="true" spellcheck="true">insert spelling</div>
</body>
</html>