Building multilingual websites with drupal

42
Building Multilingual Websites With Drupal Sam Murray / Developer, Cogapp DrupalCamp Brighton 2015 0

Transcript of Building multilingual websites with drupal

Page 1: Building multilingual websites with drupal

Building Multilingual Websites WithDrupal

Sam Murray / Developer, Cogapp

DrupalCamp Brighton 2015

0

Page 2: Building multilingual websites with drupal

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

Page 3: Building multilingual websites with drupal

Cogapp +Multilingual Drupal

Page 4: Building multilingual websites with drupal

Qatar Digital Library

Page 5: Building multilingual websites with drupal

Qatar Digital Library

Page 6: Building multilingual websites with drupal

Qatar Museums

Page 7: Building multilingual websites with drupal

Qatar Museums

Page 8: Building multilingual websites with drupal

Kubota Collection

Page 9: Building multilingual websites with drupal

Kubota Collection

Page 10: Building multilingual websites with drupal

Relate: What's Next?

Page 11: Building multilingual websites with drupal

Relate: What's Next?

Page 12: Building multilingual websites with drupal

App PublisherEnglish

French

German

Chinese (Simplified)

Hebrew

and more...

Page 13: Building multilingual websites with drupal

Why multilingualwebsites?

Page 14: Building multilingual websites with drupal

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

Page 15: Building multilingual websites with drupal

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

Page 16: Building multilingual websites with drupal

Multilingual Drupal

Page 17: Building multilingual websites with drupal

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

Page 18: Building multilingual websites with drupal

Language installation interface

Page 19: Building multilingual websites with drupal

Interface translation

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

Page 20: Building multilingual websites with drupal

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

Page 21: Building multilingual websites with drupal

Content translationvs. Entity translation

Page 22: Building multilingual websites with drupal

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

Page 23: Building multilingual websites with drupal

Enable translation on a content type

Page 24: Building multilingual websites with drupal

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)

Page 25: Building multilingual websites with drupal

Enable translation on a content type

Page 26: Building multilingual websites with drupal

Enable translation on a field

Page 27: Building multilingual websites with drupal

Adding a translation (Arabic)

Page 28: Building multilingual websites with drupal

Entity translation interface

Page 29: Building multilingual websites with drupal

Choose a method and stick with it

Page 30: Building multilingual websites with drupal

Handy modules

Page 31: Building multilingual websites with drupal

Internationalization modules (i18n,i18n_*)

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

Page 32: Building multilingual websites with drupal

Localization clientOn-page interface translation

Page 33: Building multilingual websites with drupal

Gotchas

Page 34: Building multilingual websites with drupal

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?

Page 35: Building multilingual websites with drupal

Right-to-Left scripts

Page 36: Building multilingual websites with drupal

LTR / RTL

Lorem ipsum... ----->

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

Page 37: Building multilingual websites with drupal

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

Hebrew Script ==> Hebrew, Yiddish

Thaana Script ==> Dhivehi (Maldives)

Syriac Script ==> Syriac (ancient Aramaic language)

Page 38: Building multilingual websites with drupal

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

Page 39: Building multilingual websites with drupal

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

Page 40: Building multilingual websites with drupal

Problems with bi-directionality

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

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

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

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

Page 41: Building multilingual websites with drupal

Drupal 8

Page 42: Building multilingual websites with drupal

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