The source code of each Content Document indicates the primary language of the content.
- Règle n° 036
- Internationalisation
The Content Document read by speech synthesis tools does not automatically adapt to the language of these documents, which cannot be identified by these tools which analyze the pages. This information must therefore be provided in the source code of the Content Document in question.
Objectives
- Allow correct reading of the content by a speech synthesis tool.
- Facilitate automatic translation.
- Promote the indexing of content according to their language.
Implementation
The lang attribute must be added to the root html element of the Content Document to indicate the primary language of the text. The language code must conform to the language subtag registry maintained by the Internet Assigned Numbers Authority (IANA< /a>). In practice, for French, this gives: This text is in English. This text is in French.html lang="fr"
(in HTML) and html lang="fr" xml:lang="fr"
(in XHTML). If the language varies within a book (for example, English text in a French chapter), you can also use the lang
attribute (and xml: lang
for XHTML) on specific elements of the document to indicate a language change within a section. This can be done on tags like p
, div
, or even span
, to indicate a passage in a different language:
If the primary language of the document changes in different parts of the content, you can set the lang attribute (or xml:lang for XHTML) at multiple parent elements, like head
, body< /code>,
title
, etc., to indicate the dominant language in the sections in question.
Control
- Check that the root element
html
of the Content Document has the lang attribute, for examplehtml lang="fr"
(in HTML) andhtml lang ="fr" xml:lang="fr"
(in XHTML), to indicate the main language of the document. - Verify that the xml:lang attribute is also present in XHTML documents to ensure compatibility with older systems and tools requiring this additional specification. * Verify that all multilingual content uses the lang attribute on relevant elements, such as
p
,div
, orspan
, to indicate language changes within the document. - Check that the languages of metadata and content in sections like
head
,title
, andbody
are specified with the lang attribute to ensure consistency of linguistic information. * Verify that the language code used in the lang attribute meets the standards established by the IANA registry of language subtags, and matches the language of the content. Please note that the codes mul for “multiple languages” and und for “undetermined language” should not be used. Finally, the xml:lang attribute can also be entered in addition to the lang attribute, but it is not sufficient to comply with this good practice.
- Check that the root element
Validation
- Reported by epubcheck.
- Needs to be human verified.
Informations :
Tags :
About that rule
Rule origin : Opquast | Opquast reference 4 125 | Updated on December 3, 2024