我的页面上有一个实时区域。整个页面都是荷兰语(应用lang="nl"
了 on <html>
),对于大多数文本,一切正常。但是,如果我使用带有 的实时区域aria-live
,则文本会以系统语言宣布,即使我lang="nl"
使用实时区域本身也是如此。
这是 VoiceOver 中的错误吗?还是我做错了什么?
我做了一个codepen来演示:https ://codepen.io/petergoes/pen/LYbagMw
编码:
<div lang="nl">
<span id="output" aria-live="polite"></span>
</div>
<button id="fill-en">Add English text</button>
<button id="fill-nl">Add Dutch text</button>
const enText = "This is some text in English"
const nlText = "Dit is wat tekst in het Nederlands"
const $enButton = document.querySelector('#fill-en')
const $nlButton = document.querySelector('#fill-nl')
const $output = document.querySelector('#output')
$enButton.addEventListener('click', () => {
$output.lang = 'en'
$output.innerText = enText
})
$nlButton.addEventListener('click', () => {
$output.lang = 'nl'
$output.innerText = nlText
})