Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify locale for strings that may differ from the chosen display locale #5624

Merged
merged 1 commit into from
Sep 6, 2024

Conversation

absidue
Copy link
Member

@absidue absidue commented Aug 30, 2024

Specify locale for strings that may differ from the chosen display locale

Pull Request Type

  • Bugfix
  • Feature Implementation

Description

The MDN page for the HTML lang attribute, mentions that the Web Content Accessibility Guidelines require the page language to be specified and also that parts of the page in other languages require their language to be specified too, so that screenreaders can correctly pronounce and translate the text. FreeTube already fullfills the first part, as we set the lang attribute on the <html> element, however we don't currently fullfill the latter part.

This pull request adds the lang attribute where we know that the language of the text may differ from the user's chosen locale preference and we know the language of the text e.g. locale preference selector (the locale names are in their own language), changelog (always in English). It does not add it in places where it may differ but we don't know the language of the text such as any text received from YouTube e.g. video titles, descriptions, channel names, comments etc, for those we just have to hope that the user is watching content in the same language as their locale preference.

I decided to test the before and after with the Narrator built into Windows 10 with both the narrator and FreeTube set to English and was surprised at the results. Before these changes, for languages with non-Latin characters in their names such as Arabic and Bulgarian, it just annouced their position in the select box (x out of total), so you have no idea what you are currently focused on, whereas afterwards it announced the position and the English translation of the language name.

Screenshots

locale preference selector html with lang attributes

Testing

Quick and easy:

With the dev tools check that the <option> tags in the local preference select box have appropriate lang attributes.

Getting your hands dirty

Use a screen reader of your choice (e.g. built-in Narrator on Windows or VoiceOver on macOS) and see how it handles the newly added lang attributes.

Desktop

  • OS: Windows
  • OS Version: 10
  • FreeTube version: 492f224

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) August 30, 2024 17:09
@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Aug 30, 2024
@@ -21,7 +21,7 @@ export default defineComponent({
{
icon: ['fab', 'github'],
title: this.$t('About.Source code'),
content: `<a href="https://github.com/FreeTubeApp/FreeTube">GitHub: FreeTubeApp/FreeTube</a><br>${this.$t('About.Licensed under the')} <a href="https://www.gnu.org/licenses/agpl-3.0.en.html">${this.$t('About.AGPLv3')}</a>`
content: `<a href="https://github.com/FreeTubeApp/FreeTube" lang="en">GitHub: FreeTubeApp/FreeTube</a><br>${this.$t('About.Licensed under the')} <a href="https://www.gnu.org/licenses/agpl-3.0.en.html">${this.$t('About.AGPLv3')}</a>`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should lang="en" be added to other links too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any link in particular that you have in mind? I added it to this one because the display text is English, form what I can tell the rest of them on the about page either have the link itself as the display text or are translated, but I might have missed something.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh they are translated? Did not check :)

@FreeTubeBot FreeTubeBot merged commit f05549d into FreeTubeApp:development Sep 6, 2024
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Sep 6, 2024
@absidue absidue deleted the lang-attrs branch September 6, 2024 11:47
PikachuEXE added a commit to PikachuEXE/FreeTube that referenced this pull request Sep 8, 2024
* development: (21 commits)
  Fix playback of VOD/non-live videos with Invidious (FreeTubeApp#5654)
  Translated using Weblate (Bulgarian)
  Translated using Weblate (Japanese)
  Translated using Weblate (Bulgarian)
  Specify locale for strings that may differ from the chosen display locale (FreeTubeApp#5624)
  Added translation using Weblate (Afrikaans)
  Remove "Force Local Backend for Legacy Formats" setting (FreeTubeApp#5650)
  Change the hls manifest type to match the parser name shaka player registers (FreeTubeApp#5648)
  Fix incorrect/translated placeholders in locale files (FreeTubeApp#5628)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Turkish)
  Translated using Weblate (Czech)
  Translated using Weblate (Japanese)
  Translated using Weblate (French)
  Translated using Weblate (Japanese)
  Translated using Weblate (Hungarian)
  Translated using Weblate (Portuguese (Brazil))
  Translated using Weblate (Chinese (Traditional Han script))
  Translated using Weblate (Polish)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants