在某个范围内时,Talkback 不会以正确的格式宣布日期

发布于 2025-01-09 07:25:39 字数 650 浏览 0 评论 0原文

似乎在使用 android talkback 时,当格式为 dd/mm/yyyy - dd/mm/yyyy 的范围内有 2 个日期时,它并没有正确说出日期

如果我有一个简单的日期,例如例如 01/06/2017,它会正确地说为“六月一日,二十十七”。但是,如果我有一个日期范围,例如 01/06/2017 - 01/06/2018,它会显示为“一月六日二十七日至一月六日二十八日”,有什么想法吗?为什么

将我的语言设置为 en-AU

我 结构:

01/06/2017 - 01/06/2018

但是,如果我将两者都放在 元素中的日期,然后它会正确读取每个日期,但要单独读取,例如

-

读作“六月一日,二十七号”, “破折号”,“六月一日,二十八”,整个事情是碎片化的,所以不能将其作为一行来读取,而是必须单独读取每个元素,但如果我将整个事情包装起来,这是行不通的。在 中,即

不起作用。

It seems that when using android talkback, it's not saying the date correctly when there are 2 dates in a range in format of dd/mm/yyyy - dd/mm/yyyy

If I had a simple date such as 01/06/2017, it would say it correctly as "First of June, Twenty Seventeen'. However if I had a date range such as 01/06/2017 - 01/06/2018, it would say it as "January Sixth Twenty-Seventeen to January Sixth Twenty-Eighteen", any ideas why?

I have my language set as en-AU.

This is the HTML structure:

<p>01/06/2017 - 01/06/2018</p>

However, if I put both dates in <time> elements, then it reads each date correctly, but separately, e.g. <p><time>01/06/2017</time> - <time>01/06/2018</time></p> is read as "First of june, twenty-seventeen", "dash", "first of june, twenty-eighteen", and the whole thing is fragmented so instead of reading it as a line, each element would have to be read separately. But it doesn't work if I wrap the whole thing in <time>, i.e. <p><time>01/06/2017 - 01/06/2018</time></p> won't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

属性 2025-01-16 07:25:39

日期范围始终是一件棘手的事情,因为没有比您使用的方法更好的方法 (

-

)

但是,有一种方法可以强制它说“to”,但有一个快速警告:
如果您使用此方法,那么如果有人使用自动翻译或您在某个时候对网站进行国际化,则可能会导致翻译质量不佳/将“到”转换为其他语言需要大量工作。

排除了该免责声明后,诀窍是使用实际的单词“to”:

至<时间>01/06/2018

但我知道你在想什么,我不想让“to”这个词可见,我想在视觉上使用破折号。

所以现在我们介绍视觉隐藏文本aria-hidden 显示一件事但读取另一个:

<p>
  <time>01/06/2017</time>
  <span aria-hidden="true">-</span>
  <span class="visually-hidden">to</span>
  <time>01/06/2018</time>
</p>

我们所做的是将破折号从屏幕阅读器中隐藏,然后提供一些仅屏幕阅读器的文本来替换它(“视觉隐藏”的另一个名称是“仅屏幕阅读器”)

这是一个小提琴演示:

.visually-hidden { 
    border: 0;
    padding: 0;
    margin: 0;
    position: absolute !important;
    height: 1px; 
    width: 1px;
    overflow: hidden;
    clip: rect(1px 1px 1px 1px); /* IE6, IE7 - a 0 height clip, off to the bottom right of the visible 1px box */
    clip: rect(1px, 1px, 1px, 1px); /*maybe deprecated but we need to support legacy browsers */
    clip-path: inset(50%); /*modern browsers, clip-path works inwards from each corner*/
    white-space: nowrap; /* added line to stop words getting smushed together (as they go onto seperate lines and some screen readers do not understand line feeds as a space */
}
<p>
  <time>01/06/2017</time>
  <span aria-hidden="true">-</span>
  <span class="visually-hidden">to</span>
  <time>01/06/2018</time>
</p>

注意:试图说服屏幕阅读器以某种方式表达内容几乎总是会引入辅助功能问题,而不是解决这些问题。在这种情况下,我认为你很好(因此我给出了答案),但要谨慎使用这种技术,大多数时候屏幕阅读器用户会习惯奇怪的发音,“修复”它们实际上可能会更令人困惑。

虽然我已经向您展示了如何“修复”这个问题,但我个人的观点是,它不需要任何干预,读出“破折号”是有意义的,但我也认为如果您真的这样做,在这种情况下您不会造成任何伤害我想尝试一下这种技术,所以我将把决定权留给你。

Date ranges are always a tricky thing as there isn't a better way than the one you are using (<p><time>01/06/2017</time> - <time>01/06/2018</time></p>)

However there is a way you can force it to say "to", with a quick caveat:
If you use this method then if someone uses auto translate or you internationalise the site at some point it may result in poor translations / a lot of work converting the "to" to other languages.

With that disclaimer out of the way, the trick is to use the actual word "to": <p><time>01/06/2017</time> to <time>01/06/2018</time></p>.

But I know what you are thinking, I don't want the word "to" to be visible, I want to use a dash visually.

So now we introduce visually hidden text and aria-hidden to display one thing but read out another:

<p>
  <time>01/06/2017</time>
  <span aria-hidden="true">-</span>
  <span class="visually-hidden">to</span>
  <time>01/06/2018</time>
</p>

What we have done is hide the dash from screen readers and then provide some screen reader only text to replace it (another name for "visually hidden" is "screen reader only")

Here is a fiddle demonstrating:

.visually-hidden { 
    border: 0;
    padding: 0;
    margin: 0;
    position: absolute !important;
    height: 1px; 
    width: 1px;
    overflow: hidden;
    clip: rect(1px 1px 1px 1px); /* IE6, IE7 - a 0 height clip, off to the bottom right of the visible 1px box */
    clip: rect(1px, 1px, 1px, 1px); /*maybe deprecated but we need to support legacy browsers */
    clip-path: inset(50%); /*modern browsers, clip-path works inwards from each corner*/
    white-space: nowrap; /* added line to stop words getting smushed together (as they go onto seperate lines and some screen readers do not understand line feeds as a space */
}
<p>
  <time>01/06/2017</time>
  <span aria-hidden="true">-</span>
  <span class="visually-hidden">to</span>
  <time>01/06/2018</time>
</p>

Note: Trying to persuade a screen reader to say things a certain way is nearly always a recipe for introducing accessibility issues rather than fixing them. In this instance I think you are fine (hence why I gave an answer), but use this technique sparingly, most of the time screen reader users will be used to strange pronunciations and "fixing" them can actually be more confusing.

Although I have showed you how to "fix" this my personal opinion is that it does not need any intervention, it makes sense with "dash" being read out, but I also think you will not do any harm in this instance if you really want to try this technique out so I will leave the decision up to you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文