If you've ever worked on or built a multi-lingual website you will know there are a million and one things to keep in mind. Sorting out domain names, web server configuration, URL structure, page layout and the translation of content are likely to be high on your 'to do' list.

With all that keeping you busy, meeting the accessibility requirements for your website may slip to the bottom of the pile. This shouldn't be the case as making your multi-lingual website accessible is easy to achieve.

What is a multi-lingual website?

A multi-lingual website is a website where the content is written in more than one language. The information displayed in different languages is often the same, but maybe tailored for different audiences. Booking.com is an example of a multi-lingual website as its content is available in 35 different languages.


Booking.com homepage shown in English (left) and Portuguese (right)

1: Language Codes

The first thing to get right when working with multiple languages on a website is making sure the language is identified in the code of the page. The Web Content Accessibility Guidelines require under success criterion 3.1.1 Language of Page that:

The default human language of each Web page can be programmatically determined.

Assistive technologies such as screen readers and Braille devices can not automatically identify the language being used on a website from the text alone.  The language must be identified in the code of the page in order for assistive technologies to interpret it correctly.  Once recognized, these technologies can automatically switch to that language, adjusting the accent, pitch and speaking rate of the content depending on the language in question. Modern screen readers such as Jaws and Window Eyes are able to speak multiple languages in appropriate accents with proper pronunciation.

Setting the primary language

First of all you will need to choose the primary language for your pages. This is the language the majority of your content is written in. For example if your page is predominantly written in English then your primary language should be set as English.

Once the primary language of your pages has been chosen, you will need to find the language code which corresponds to that language. Language codes usually consist of two letters, however four letter codes can be used for further defining the language into different dialects.

A two letter language code 'en' could be used to define 'English', whereas the four letter language code 'en-GB' could be used to distinguish British English from American English 'en-US'. Please note 'en-UK' is not a valid four letter language code. Next we need to apply the language code to our page.

To set the primary language of our page as English we use the 'lang' attribute along with our 'en' language code and apply this to the HTML element at the beginning of each page.

<html lang="en">

If you are using XHTML, you will need to apply an additional attribute to set the language used in an XML document. The 'xml:lang' attribute serves the same purpose as the 'lang' attribute and should use the same language code. Your pages will not pass the W3C HTML validation check without this attribute.

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

For a multi-lingual website consisting of English, French and German pages, the primary language should be reset for each language.


The primary language of the page should correspond with the human language of the page

Using the wrong language code

If you don't provide a primary language code or set the code incorrectly it may be impossible for someone using a screen reader or Braille device to understand the content. If the primary language of the web page has not been identified, screen reading software in general will read out the content in the same language as the default setting for the screen reader.

So if your screen reader has English set as the default language, it will read out web page content in English. This isn’t too much of a problem if you are only viewing web pages written in English.

However if the page uses the wrong language code, for instance if the content is written in English, but identified in the code as French the screen reader will attempt to speak the English content using a French accent and pronunciation. For those of you familiar with 'Allo Allo', your website could end up sounding something like Officer Crabtree, below. While amusing, this might not be very easy to understand.

 

2: Multiple Languages

The majority of web pages use a single language at a time, however there maybe occasions when you want to include a language other than the primary one on your pages. If this is the case, the Web Content Accessibility Guidelines success criterion 3.1.2 Language of Parts requires that:

The human language of each passage or phrase in the content can be programmatically determined except for proper names, technical terms, words of indeterminate language, and words or phrases that have become part of the vernacular of the immediately surrounding text.

If you wanted to include a passage in French on your page you would need to use the 'lang' attribute to mark the change in language. The 'lang' attribute can be used with almost every HTML element, making it very easy to change languages within a page. To include a French quotation on an English page you would simply add the lang attribute to the blockquote tag:

<blockquote lang=”fr”> <p>Le plus grand faible des hommes, c'est l'amour qu'ils ont de la vie.</p> </blockquote>

Links

If you are creating a multi-lingual website you may also need to provide links to the other language versions of your site. If the page you are linking to is written in a different language to the current page, you need to let people using assistive technologies know about this. This can be done by using the 'hreflang' attribute.

The 'hreflang' attribute allows you to inform people the primary language of the page found when following the link is different to the current page. For example to link to a page written in French from a page written in English, you would use:

<a href="" hreflang="fr">French</a>

If you need to identify both the text of the link, and the links target as different languages you need to use both the 'lang' and 'hreflang' attributes:

<a href="" lang="fr" hreflang="fr">Francais</a>

Please note the 'hreflang' attribute should only be used for links.

sample

<meta name="description" content="Site Explorer runs on a huge database of 12 trillion links and 402 million tracked keywords to give you the most complete SEO data about any website or URL">        <meta name="viewport" content="width=device-width">
    <link rel="shortcut icon" href="/favicon.ico" />
    <link rel="alternate" type="application/rss+xml" href="http://feeds.feedburner.com/AhrefsBlog" title="Ahrefs SEO Digest">
    <link rel="alternate" hreflang="x-default" href="https://ahrefs.com/site-explorer" />
<link rel="alternate" hreflang="de" href="https://ahrefs.com/de/site-explorer" />
<link rel="alternate" hreflang="es" href="https://ahrefs.com/es/site-explorer" />
<link rel="alternate" hreflang="fr" href="https://ahrefs.com/fr/site-explorer" />
<link rel="alternate" hreflang="it" href="https://ahrefs.com/it/site-explorer" />
<link rel="alternate" hreflang="ko" href="https://ahrefs.com/ko/site-explorer" />
<link rel="alternate" hreflang="ja" href="https://ahrefs.com/ja/site-explorer" />
<link rel="alternate" hreflang="nl" href="https://ahrefs.com/nl/site-explorer" />
<link rel="alternate" hreflang="pl" href="https://ahrefs.com/pl/site-explorer" />
<link rel="alternate" hreflang="pt" href="https://ahrefs.com/pt/site-explorer" />
<link rel="alternate" hreflang="ru" href="https://ahrefs.com/ru/site-explorer" />
<link rel="alternate" hreflang="sv" href="https://ahrefs.com/sv/site-explorer" />
<link rel="alternate" hreflang="tr" href="https://ahrefs.com/tr/site-explorer" />
<link rel="alternate" hreflang="zh" href="https://ahrefs.com/zh/site-explorer" />
                        <link rel="canonical" href="https://ahrefs.com/site-explorer"/>

 

https://www.wikihow.com/Write-SEO-Content

<link rel="alternate" hreflang="en" href="https://www.wikihow.com/Write-SEO-Content"/>

<link rel="alternate" hreflang="es" href="https://es.wikihow.com/escribir-un-art%C3%ADculo-optimizado-(SEO)"/>

<link rel="alternate" hreflang="it" href="https://www.wikihow.it/Scrivere-un-Articolo-a-Scopo-SEO"/>

<link rel="alternate" hreflang="ru" href="https://ru.wikihow.com/%D0%BD%D0%B0%D0%BF%D0%B8%D1%81%D0%B0%D1%82%D1%8C-%D1%81%D1%82%D0%B0%D1%82%D1%8C%D1%8E-%D0%B4%D0%BB%D1%8F-SEO"/>

<link rel="alternate" hreflang="fr" href="https://fr.wikihow.com/cr%C3%A9er-du-contenu-pour-optimiser-son-r%C3%A9f%C3%A9rencement"/>

<link rel="alternate" hreflang="de" href="https://de.wikihow.com/SEO-Content-schreiben"/>

<link rel="alternate" hreflang="id" href="https://id.wikihow.com/Menulis-Konten-SEO"/>

<link rel="alternate" hreflang="nl" href="https://nl.wikihow.com/SEO%E2%80%90inhoud-schrijven"/>

<link rel="alternate" hreflang="ar" href="https://ar.wikihow.com/%D9%83%D8%AA%D8%A7%D8%A8%D8%A9-%D9%85%D8%AD%D8%AA%D9%88%D9%89-%D9%85%D8%AD%D8%B3%D9%86-%D9%84%D9%84%D8%B8%D9%87%D9%88%D8%B1-%D9%81%D9%8A-%D9%85%D8%AD%D8%B1%D9%83%D8%A7%D8%AA-%D8%A7%D9%84%D8%A8%D8%AD%D8%AB"/>

 

多语言网站优化和hreflang标签

3: Google and language recognition

Unlike assistive technologies such as screen readers, Google does not recognise language identifiers such as 'lang' attributes in the code of the page. Google tries to work out the main languages of your pages itself. In order to make language identification easier for Google, Google recommends only using one language per page. 

 

4: Language direction

If you are creating a multi-lingual website which caters for languages written from right-to -left rather than left-to-right, you will need to make sure the direction of text is specified correctly in the code of the page. You can set the direction of text by using the 'dir' attribute on the HTML element. For languages such as Arabic, Persian and Urdu the 'dir' attribute should be set to be set to rtl (right-to-left):

<html dir="rtl">

A 'dir' attribute is not needed for pages written using left-to-right languages such as English as this is the default direction of text. Different page layouts are often required for right-to-left languages, as most right-to-left languages should be right aligned rather than left aligned.

This means the page layout will need to be adapted for these languages, essentially mirroring the layout of the left to right language pages. For example the United Nations website adapts its layout for the Arabic language which is written from right-to-left. The whole layout of the page is reversed when compared to the English language version.These types of layout changes can be achieved using CSS.


 

The layout of the United Nations pages change depending on the language used

 

国际化 - 通用 LTR/RTL 布局解决方案

5: Character encoding

A character encoding is essentially a key to decipher an encrypted collection of letters and symbols used in a writing system. There are many different types of character encodings so it's really important to make sure you use the right character encoding otherwise people may not be able to read the text on your pages.

Character encoding also helps computers understand your information, if you use the wrong encoding your pages may not be found by some search engines. The most widely used character encoding is 'Unicode'. 'Unicode' contains characters for most languages and scripts in the world and is supported on a large number of operating systems.

This means Unicode can display multiple languages and scripts within a page, which makes it an excellent choice to use for multi-lingual websites. To specify Unicode for pages written in HTML 4 put the following line in the head of your pages:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

For HTML 5 use:

<meta charset="UTF-8">

Please see 'Declaring character encoding in HTML' for more information about character encoding.

6: Font sizes

When designing your multi-lingual website, it is important to realise that the font size you chose for your default language may not be suitable for all languages. Different languages such as Chinese, Japanese and Arabic might be difficult to read at font sizes that are suitable for English, French and German languages. For web pages displaying Chinese, Japanese or Arabic languages the default font size will need to be increased so the text is legible on screen.

There are two ways this can be achieved. The first uses the CSS 'lang' pseudo class to set different font sizes and font families depending on the value of the 'lang' attribute: HTML

<html lang="en"> or <html lang="zh">

CSS

:lang(en) { font-size: 85%; font-family: arial, verdana, sans-serif; } :lang(zh) { font-size: 125%; font-family: helvetica, verdana, sans-serif; }

This technique is supported in Firefox, Opera and Internet Explorer 8 and higher. Chrome and Safari do not support this pseudo class. If you want to support web-kit browsers and earlier versions of Internet Explorer as well, the second option would be to use classes on the body element for each language required: HTML

<body class="english"> or <body class="chinese"> 

CSS

.english { font-size: 85%; font-family: arial, verdana, sans-serif; } .chinese { font-size: 125%; font-family: helvetica, verdana, sans-serif; }

 

I respect to the :lang() psudo class and support, you could do the following:

:lang(en),
[lang='en'] {
font-size: 85%;
font-family: arial, verdana, sans-serif;
}

:lang(zh),
[lang='zh'] {
font-size: 125%;
font-family: helvetica, verdana, sans-serif;
}

That will target the attribute 'lang' and check for the value 'en' or 'zh'.
Should support most browsers without the need to add custom html.

 

7: Length of words

The length of words varies from language to language. Content written in one language may take up more or less space on the page than another language.  The design of the website should cater for different length words used through the site. Taking Amazon as an example, the length of content in the search bar of the website varies between languages.  The word 'search' takes up 10 characters in French but only two characters in Japanese. The word 'basket' takes up 6 characters in English but when translated to German takes up a massive 13 characters. Amazon have adapted the design of this area of their pages, removing the wish list button from the search bar for those languages which use longer words such as German and Italian.


Different languages take up different amounts of space on the page

Depending on the content on your multi-lingual website, it may not be possible to change the layout and design of your site in this way. You can overcome these types of problems by using shorter words to fit in to the space available on your page and making sure you have your content translated before making essential design decisions.

8: translating the website

To make your site multilingual at a professional level you have to get a nice team of translators and a good localization tool for them to work on. You can easily find translators on forums or on freelance websites and some of them will work for free. The localization platform I suggest is https://poeditor.com/, where they can all work together on translating the website. It's very important to have a good strategy.

Nomensa is an award-winning UX design agency with offices in Bristol, London and Amsterdam. If you would like to find out more about the web accessibility services we offer, give us a call on 01179 297 333 or send us a message and we'll get back to you. 

References

http://www.w3.org/International/questions/qa-lang-why

Suggested Reading