New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 877724 link

Starred by 3 users

Issue metadata

Status: Verified
Owner:
Closed: Sep 14
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug
Team-Accessibility



Sign in to add a comment

No language indicated in markup on chrome://accessibility

Project Member Reported by leberly@chromium.org, Aug 25

Issue description

Google Chrome	70.0.3524.2 (Official Build) dev (64-bit)
Firmware Version	Google_Lulu.6301.136.57

Navigate to chrome://accessibility and either inspect or look at source code
Expected: <html lang="en">
Actual: No language markup
 
Labels: a11y-webui a11y-internals
Owner: chrishall@chromium.org
Status: Started (was: Available)
Note I can find lots of examples of <html> within  chrome/browser/resources
chromium/src/chrome/browser/resources$ git grep -ni '^<html>$' | wc -l
48

and only a few specifying a lang
hromium/src/chrome/browser/resources$ git grep -ni '^<html lang' | wc -l
8

I may try fix up more of them as a follow-up commit.
patch for chrome://accessibility uploaded at
https://chromium-review.googlesource.com/c/chromium/src/+/1198706
Although some pages specify
<html lang="$i18n{language}">

is this preferable? or is lang="en" sufficient? (chrome does both)
the 4th option appears to be
<html i18n-values="dir:textdirection;lang:language">

Generally the approach in #7 is preferred, but test that it works in a page that isn't localized like chrome://accessibility.
Thanks for that michaelpg

I have updated https://chromium-review.googlesource.com/c/chromium/src/+/1198706 to only add lang="en" to pages which do not include any i18n references (e.g. they have no evidence of internationalization).

I will try do a follow-up commit to address pages which are internationized.
I'll also try test those pages in case it 'just works'
Huh, michaelpg for the win.

lang="$i18n{language}" works on accessibility.html

Even removing 'all' the js includes still leaves it working, so it looks like this is done before the page is 'served' (not sure what that means in this context).

Awesome, I'll update the patch.
the alternative
<html i18n-values="dir:textdirection;lang:language">

only works when we include
https://cs.chromium.org/chromium/src/ui/webui/resources/js/i18n_template.js

as this is the js that uses i18n-values to then populate the other attributes (dir, lang, i18n-processed).
Cc: dschuyler@chromium.org hcarmona@chromium.org
Can I ask why |lang| is important in WebUI?
lang is important for screen readers.

If a page is only available in English and a user is using a screen reader in Spanish, it may try to pronounce the page using Spanish readings of the English words.
Setting the lang correctly to "en" should instead make it read the page correctly in English (in theory).




So it seems that the templates of the form "$i18n{key}" are replaced by
https://cs.chromium.org/chromium/src/ui/base/template_expressions.cc?q=%22$i18n%22&sq=package:chromium&dr=C&l=61

and seem to be initially populated by
https://cs.chromium.org/chromium/src/ui/base/webui/web_ui_util.cc?q=%5C%22language%5C%22&sq=package:chromium&dr=C&l=179

If I set a garbage key like
<html lang="$i18n{BEEP}">

then when I load the page (chrome://accessibility) I see the error
[106213:106242:0903/125950.096984:FATAL:template_expressions.cc(97)] Check failed: value != replacements.end(). $i18n replacement key "BEEP" not found

which comes from
https://cs.chromium.org/chromium/src/ui/base/template_expressions.cc?q=%22$i18n%22&sq=package:chromium&dr=C&l=97
Michael are you able to elaborate on why the js i18n-values is preferred and if there is any good documentation on it?
For static html pages (pages without any obvious internationalization support) I think using the lang="en" is likely the safest.

My concern is that using any of the other two options will set the lang to the user's preference, even when the page itself is not available in that language.

I can try test this to confirm.
i18n-values is an older method that requires the JS template processor to be included. It sets the |dir| attribute, which is important for right-to-left languages, but you can also get that with:

<html dir="$i18n{textdirection}" lang="$i18n{language}">

So I think the tl;dr is:

On untranslated pages (mainly internal pages), use <html lang="en">

On translated pages, use 
<html dir="$i18n{textdirection}" lang="$i18n{language}">
Project Member

Comment 18 by bugdroid1@chromium.org, Sep 7

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e808b4f74f0fa65c8f45ccc0489a8dfa128e84b8

commit e808b4f74f0fa65c8f45ccc0489a8dfa128e84b8
Author: Chris Hall <chrishall@chromium.org>
Date: Fri Sep 07 03:40:03 2018

Specifying lang="en" on English-only WebUI accessibility page.

Bug:  877724 
Change-Id: Iaa71eda0e0fa94f9d23c9bc71b12d2abd3ec4224
Reviewed-on: https://chromium-review.googlesource.com/1209001
Commit-Queue: Chris Hall <chrishall@chromium.org>
Reviewed-by: Alice Boxhall <aboxhall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589425}
[modify] https://crrev.com/e808b4f74f0fa65c8f45ccc0489a8dfa128e84b8/chrome/browser/resources/accessibility/accessibility.html

Project Member

Comment 19 by bugdroid1@chromium.org, Sep 14

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/98192dac000a6762dbba673a4dba180006e749fa

commit 98192dac000a6762dbba673a4dba180006e749fa
Author: Chris Hall <chrishall@chromium.org>
Date: Fri Sep 14 00:58:44 2018

Specifying lang="en" on English-only WebUI pages.

Bug:  877724 
Change-Id: I5321f253513f369db9f3ed54758785ca84cfb2cf
Reviewed-on: https://chromium-review.googlesource.com/1198706
Commit-Queue: Chris Hall <chrishall@chromium.org>
Reviewed-by: Alice Boxhall <aboxhall@chromium.org>
Reviewed-by: Michael Giuffrida <michaelpg@chromium.org>
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591244}
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/about_invalidations.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/bluetooth_internals/bluetooth_internals.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/chromeos/cryptohome.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/chromeos/drive_internals.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/chromeos/sys_internals/index.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/chromeos/zip_archiver/unpacker-test/cpp/index.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/eoc_internals/eoc_internals.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/inspect/inspect.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/interventions_internals/unsupported_page.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/local_state/local_state.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/media/media_engagement.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/omnibox/omnibox.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/sandbox_internals/sandbox_internals.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/supervised_user_internals.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/task_scheduler_internals/index.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/usb_internals/usb_internals.html
[modify] https://crrev.com/98192dac000a6762dbba673a4dba180006e749fa/chrome/browser/resources/user_actions/user_actions.html

Status: Fixed (was: Started)
and that should be us \o/
Status: Verified (was: Fixed)

Sign in to add a comment