0

For context: I am not a web developer or programmer of any sort and I use a screen-reader.

I am using an accessibility evaluation tool across some sites I'd like to visit, which, however, have some accessibility issues.

From some googling, I see that it is fairly easy to specify a single webpages language by using <HTML lang='en'></html> for example for English.

How easy would it be to implement this across an entire site with hundreds of separate pages? This is a very vague question without linking to the specific website. For example, a car website with a separate page for individual cars with each page missing a specified language. Would it be fairly simple to specify the language across all automatically or would one have to manually copy/paste <HTML lang='en'></html> for each page? Or does it heavily depend on how the website was structured HTML-wise? etc.

Thank you

Leitmotif
  • 33
  • 4
  • This isn't a programming problem. If you have problems accessing a website, then bring up the problem with customer services, not what you think the solution is. – Quentin Mar 01 '21 at 15:07
  • This is a programming question from someone who wants to know more. Thanks for your time, Quentin. – Leitmotif Mar 01 '21 at 15:12
  • No, it isn't a programming question. You aren't trying to write code, you're trying to figure out if you should bother someone else to get them to change code you haven't seen in a way that you don't know with solve some problem you have. Even if you were trying to write code, it would be an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). – Quentin Mar 01 '21 at 15:13
  • I guess you could make a browser extension that checks if its absent and adds it? This isnt really a programming question as he said – Penguin Mar 01 '21 at 18:50

2 Answers2

4

You can define the content language sitewide without modifying the HTML using the HTTP header:

Content-Language: de-DE

This is described in the WCAG : Specifying the default language in the HTTP header

This header should be used as fallback by browsers when no lang attribute is declared.

The HTML5 specification says that if there is no lang attribute on the html tag, and if there is no meta element with the http-equiv attribute set to Content-Language, and if there is only a single language tag in the HTTP header declaration, then a browser may use that information to guess at the default language of the text in the page.

But as noted in the WCAG, this might not be always sufficient:

Note that the Content-Language HTTP header does not serve to identify the language used for processing the content. The content processing language can be identified by means of other techniques, such as the attributes lang and xml:lang in markup languages.

The technique Using the language attribute on the HTML element must be applied and specifiying the lang attribute is something that you won't do an a per-webpage basis, but modifying the site template.

And yes, this is a programming question, a beginner one, but still a programming one

Adam
  • 17,838
  • 32
  • 54
0

To answer the underlying programming question: Yes, usually changing one file is enough.

You can safely assume that the HTML files that make a website are generated by either a Static Site Generator in advance, or by Content Management System (CMS) on the server when a page is requested.

To generate these files, templates are used. Templates give a common structure and contain variables, which will be replaced by content from the respective page or component.

Usually, there is one main, high-level HTML template, which provides the basic HTML structure with the opening HTML tag <html>.

So usually it suffices to change only one file to include the language attribute, by writing <html lang="en"> in that template, or using a variable for a multi-lingual site <html lang="{{language}}"> (syntax depends on your generator).

Andy
  • 4,783
  • 2
  • 26
  • 51