Building multilingual websites with drupal

Preview:

Citation preview

Building Multilingual Websites WithDrupal

Sam Murray / Developer, Cogapp

DrupalCamp Brighton 2015

0

What we'll coverContext - sites we've worked on at Cogapp over the last few yearsWhy multilingual websites?Drupal 7 - multilingual out of the boxContent translation vs. Entity translationUseful modulesRight-to-Left scriptsDrupal 8

Cogapp +Multilingual Drupal

Qatar Digital Library

Qatar Digital Library

Qatar Museums

Qatar Museums

Kubota Collection

Kubota Collection

Relate: What's Next?

Relate: What's Next?

App PublisherEnglish

French

German

Chinese (Simplified)

Hebrew

and more...

Why multilingualwebsites?

Non-English speaking web users~75% web content was English in 1998

Now roughly 30%

Arabic web users:

Fastest increase in top 10 languages of the net2000: 2,560,337 users2013: 135,610,819 users> 10x faster than increase in English speakers online

http://www.internetworldstats.com/stats7.htm

Language extinctionOnly 5% of the world's languages represented online

Unesco: up to half of the world's languages extinct by the end of the century

Diverse web prevents cultural and economic hegemony and inequality

Vannini L., Le Crosnier H. Net.Lang: Towards The Multilingual Cyberspace. C&F Éditions: Caen, France.2012

Multilingual Drupal

Locale module (core)Add languages to your siteTranslate the Drupal interfaceLanguage detection and selectionURL format (fr.example.com or example.com/fr)

Language installation interface

Interface translation

<?php t('This is translatable'); ?><?php t('My name is @name', array('@name' => $name)); ?>

Content Translation (core)Associate a node with a languageRelate translations of content to each other

Content translationvs. Entity translation

Content translationCore module in Drupal 6 and 7; not in Drupal 8Provides ability for you to translate nodesEach translation of a node is a node in itselfPro: easier for language site to differCon: only nodes are translatable

Enable translation on a content type

Entity translationContrib module in Drupal 7 (beta); core in Drupal 8Provides ability for you to translate fieldable entitiesDefine which fields can be translated

Pro: far more can be translatedPro: core support in D8Con: D7 core search and revisions not supportedCon: D7 all translations must be provided before any can be pubishedCon: D7 properties can't be translated

global $language; // Site languageglobal $language_content; // Content language

$entity->field_body['fr'][0]['value'];$entity->field_body[$language->language][0]['value'];$entity->field_body[$language_content->language][0]['value'];

$emw->field_body->value(); // Uses $language (site language)

Enable translation on a content type

Enable translation on a field

Adding a translation (Arabic)

Entity translation interface

Choose a method and stick with it

Handy modules

Internationalization modules (i18n,i18n_*)

Extends multilingual support in Drupal 6 + 7Taxonomy translationMultilingual blocksMultilingual variablesSome overlaps with Entity Translation module, but the 2 work together

Localization clientOn-page interface translation

Gotchas

GotchasContent editing when site language != content language (e.g. entity

references)

Menu translation - various methods, none perfect

Fonts (particurly webfonts) - do they have all of the characters you need?Including bold? Including light? .ttf? .svg? .eot?

Right-to-Left scripts

LTR / RTL

Lorem ipsum... ----->

يیذذكرر ووقامم أأيي... ----->

RTL Scripts/LanguagesArabic Script ==> Arabic, Persian, Urdu

Hebrew Script ==> Hebrew, Yiddish

Thaana Script ==> Dhivehi (Maldives)

Syriac Script ==> Syriac (ancient Aramaic language)

ArabicBasic alphabet = 28 charactersEastern Arabic numbers - Left-to-Right!CaselessItalics = :(Some punctuation marks are differentComma = ،٬Question mark = ؟Mostly uses the same punctuation marks used in English

RTL on the webHTML 'dir' attribute

<html dir="rtl"></html> <p dir="ltr"></p>

CSS 'direction' property

CSS 'unicode-bidi' property

div { direction:rtl; unicode-bidi: bidi-override; }

Unicode left-to-right mark - HTML &lrm;

Unicode right-to-left mark - HTML &rlm;

These go before a character to specify where it should be placed in

relation to the previous character

Problems with bi-directionality

Some "English" يیذذكرر ووقامم أأيي

<p dir="ltr">Some "English" يذكر وقام أي</p>

Some "English" يیذذكرر ووقامم أأيي

<p dir="rtl">Some "English" يذكر وقام أي</p>

Drupal 8

Drupal 8Content translation is obsoleteEntity translation out of the boxMuch wider support for translation across the different Drupal elements4 core moduleshttp://www.drupal8multilingual.org/

Recommended