Академический Документы
Профессиональный Документы
Культура Документы
MULTILINGUAL
WEBSITES WITH
DRUPAL 7
About us!
Getting to know you...
What are your
multilingual needs?
What you need
Check
• A fresh Drupal 7 instance installed locally
• Download of module files
Previous experience
• Familiar with Drupal site building?
• Experience setting up content types and
Views
• Optional: Experience creating a simple
glue module or custom theme?
What’s in the box?
What you have
• Your local development environment
• Your manual
• Browser opened to drupal.org *
MULTILINGUAL
USER INTERFACES
Multilingual
Requirements
Internationalization
• aka i18n
• Developing a website that enables
localization.
• Separating elements that should be
localized so they can be specified for
each locale.
Localization
• aka l10n
• Process of adapting a website for a
certain locale including:
• Text and graphics
• Numeric, date and time formats
• Currency
• Time zones
• Legal requirements
Translation
• The act of translating the text of a website
into another language
• Part of the localization process
Multilingual Website
• A website that displays information in
multiple languages
• Involves internationalization of
functionality and localization of content
and settings
What kind of site are you
building?
• How many languages do you need to
support?
• Does the user interface need to be fully
translated?
• Are there elements other than text that
have to be ‘localized’?
• Do you have content in all languages? Is
all the content translated?
Lots of reasons for
multilingual websites
• Translation Manager
What is Multilingual
Drupal?
Foreign-language site
Multilingual Site
Multilingual Site with
Translation
Multilingual Modules
• Core modules:
• Locale
• Content Translation
• Contributed Modules:
• i18n (Internationalization)
• Entity Translation
• Others provide additional functionality
Installing a New
Language
The Language of Drupal
English UI French UI
Drupal Core is Language
Aware
The t function is defined in bootstrap.inc. From the beginning of each page
load, Drupal knows what language to render your site in.
Language Detection &
Selection
Using the URL as the primary method of language detection
Path Prefix vs. Domain
Path prefix: example.com/fr/user
Domain: exemple.com/user
Domain: fr.example.com/user
Path Prefix vs. Domain
Configuration > Regional & language > Languages > French
i18n Strings
Variables
Built-in interface (User-Defined)
Built-in interface (Code)
Translation Interfaces Built-in interface (User-Defined)
in Drupal i18n Strings
i18n Strings
Variables Content
Translating Built-in
Interface Text (from
Code)
Built-in Interface (Code)
Using Translations
from
Localize.Drupal.org
Use Localize.Drupal.org
• Each language has a project
• Translators contribute translations in their
language
• Some projects have better coverage than
others.
Localize.Drupal.org
Project Page
What is a .po file?
• Text file storing the
original text and the
translations.
• A .pot file is a
template file,
containing only the
original text to be
translated.
Upload .po files to Drupal
Overriding
Translations in
Drupal
Overriding a Translation
Searching for the String
Editing the Translation
Testing the Change
Your turn
• Download translations from
localize.drupal.org and upload them to
your site
• Override a translation in Drupal
Use Localization
Update
Localization Update
drupal.org/project/l10n_update
Localization Update
Translation Overview
Your turn
• Use the Localization Update module to
pull in more translations from Drupal.org
Use Localization
Update
Localization Update
drupal.org/project/l10n_update
Localization Update
Translation Overview
Your turn
• Use the Localization Update module to
pull in more translations from Drupal.org
Use Localization
Client
Use Localization Client
drupal.org/project/l10n_client
Sharing Your
Translations
Drupal Database
‘Recent ‘Articles
Articles’ récents’
MULTILINGUAL
CONTENT
What content
experience are you
building?
Fully Symmetric
Experience
English Polish
Asymmetric Experience
French English
Mixed Language Experience
English
French
What about
untranslated
content?
Show Untranslated
Content
Hide Untranslated
Content
French English
Content Translation
Methods
Content Translation
Methods
Node-Level Translation Field-Level Translation
• Title • Image
• Description • Sign-up List
• What to bring • Sign-up Deadline
• URL • Published Status
• Date/Time
• Location
• Organizer
Issue
Issue
Language-specific Language-neutral
User Comments
Articles
Blog Posts
Content Translation
Methods
Node-Level Translation Field-Level Translation
Permissions
Translate Users:
Use Cases
• Team member profiles
• Multilingual community site
• Users who offer a service to users in more
than one language
Translate Users:
Drawbacks
• Single permission for users (can translate
any user entity)
• UI is not self-explanatory
Translate Terms
Configure Fields Translate Terms
Permissions
Translate Terms:
Use Cases
• Any vocabulary that is symmetric across
languages:
• Categories
• Destinations
• Medical Topics
Translate Terms:
Drawbacks
• Time-consuming to use translation UI
• Single permission for translating all
vocabularies
• Alphabetical listings in Views will use
source language
Translate Comments
Configure Fields Translate Comments
Permissions
Translate Comments:
Use Cases
• Travel website (machine translation of
reviews)
• Government website (human translation
of questions + answers)
Translate Other Entities
Translation of entities from contributed modules
Entities need to
have fields and
include
translation
support in
hook_entity_info()
Product
Product
Language-specific Language-neutral
• Title • SKU
• Description • Status
• URL • Image
• Price
• Quantity Remaining
• Shopping Cart Status
Translatable Commerce
Product
Product
Product
Your turn
Translate categories
using entity translation
Multilingual Views
Mixed-Language Views
Do you want the view
to show untranslated
English
content?
French
Filtering by Language
MULTILINGUAL
STRUCTURE
Overview
• What else in Drupal needs translation?
• Field settings
• Blocks
• Paths
• Date Formats
• Emails to Users
• Menus
Text Groups
Fields
Menu
Blocks
Taxonomy
Translating Field
Settings
Field Settings
/fr/node/add/article
Label
Description
Translating Field Settings
• Field Translation module (i18n)
• Translate field settings
• Label
• Description
• Options
• Default Value
• Only core field settings
Translate Interface
Field Translate Tab
Translate Field Settings
Translating Options
Field Display Formatters
TRANSLATING
CUSTOM AND
CONTRIB MODULES
Modules to Extend
Drupal’s Multilingual
Functionality
Adding Functionality
+
Contact Form Meta Tags Site Map
Contact Form
• Translation of form
labels
• Recipients per
language?
• What other language
is involved?
Meta Tags
• How are meta tags attached to each node?
• Will translators have permission to add
them?
Is this module
multilingual-
compatible?
Your turn
• Take a sample module you’re considering
using for your current project.
• How would you determine whether it’s
multilingual-compatible?
Your turn
• What type of text does the module introduce?
<?php
$message = t("If you don't want to
receive such e-mails, you can change your
settings at
!url.", array('!url' => l(t('My account'),
"user/$account->uid")));
?>
The $account variable includes HTML
@variable
<?php
$title = t("@name's blog",
array('@name' => $account->name));
?>
<?php
$message = t('%name-from sent %name-
to an e-mail.', array('%name-from' =>
$user->name, '%name-to' =>
$account->name));
?>
Hebrew
Localizing Date
Formats
What are date formats?
• Friday, July 23rd, 2012 6:30pm
• vendredi le 23 juillet, 2012 18:30
• 07/23/2012 6:30pm
• 2012-07-23 18:30
Date Format
Documentation
http://php.net/manual/en/function.date.php
Define new formats
Localizing Date Formats
Date formats in Views
Your turn
• Create a localized date format for French
• Add dates to the Recent Articles View
User Language
Preferences
User Language Preference
Set on Account Creation
Used in Language
Detection
Language Preference for
User Emails
Session 5
TRANSLATION
WORKFLOWS
Translation
Workflows
Cost of Translation
• Time-consuming
• Expensive
• How can you speed up the process and
reduce the amount of text to be
translated?
What are Translation
Workflows?
Translator
Benefits of an External
Translation Tool
• Translation teams are used to an external
tool
• Tracks cost of translation
• Provides integration with machine/
community sourced translations
• Advanced tools (translation memory)
• Integration with multiple translation teams
Benefits of an Internal
Translation Tool
• Easy to set up
• Add translations as you go
• Less costly
• Takes advantage of Drupal’s content
management tools
• Easier to provide context
Discussion
• Which approach would work better at
your organization?
Translation
Workflows for UI
Strings
Translation Workflow for
UI Strings
1. Pull in contributed translations 2. Override translations +
from localize.drupal.org add translations of custom strings
Translator
Overriding/Adding
Translations Outside
of Drupal
Use POEdit to Translate
Translations Spreadsheet
Translating Outside Drupal
CSV with Translations
Translator
CSV Template
.po file for each language
Re-using Your
Translations
Translating User-
Defined Strings
User-Defined Strings
• Strings added in the admin UI (not in
code)
• For example: Views text
Other User-Defined
Strings
• Block text
• Menu items
• Field settings
Translate Interface
Translate Tab
Translate Tab
User-Defined Strings
Challenges
• Giving translators access to block/field/
menu configuration
• Allowing translators to use all input formats
• Changing the original values
• Changing the default language
Translation
Workflows for
Content
Content Translation
Workflow
1. Author creates a new node 2. Translators adds a translation
Author Translator
Translation
Workflows for
Content:
Translating in Drupal
Translation Interface in
Drupal
Node-Level vs. Field-Level
Translation
Field-Level Translation Node-Level Translation
Creating a Translation
Workflow from Scratch
• Permissions for translators
• Rules and Flag to trigger translation
requests
• Views for Translators
Permissions for
Translation
• Content Translation: Translators need to
be able to create content
• Entity Translation: Permission to edit the
entity
• No granular translation permissions per
content type (use i18n_access)
Challenges
• Different UI for Entity Translation/Content
Translation (Confusing)
• Professional translators need to learn
Drupal
• Need to build system for reviewing
translations
Typical UI for Translators
Your turn
• Set up permissions for translators
• Create a view for translators
Translation
Workflows for
Content:
TMGMT Module
Translation Management
Tool (TMGMT)
drupal.org/project/tmgmt
Translation Management
Tool (TMGMT)
Drupal
Translators
• Nativy (human)
• MyGengo (human)
• Supertext (human)
drupal.org/project/lingotek
Lingotek
Drupal
Individual
Translator
Create a Lingotek Account
Connect to Machine
Translation Tool
Create a Project
REVIEW
Multilingual Checklist
• Installing languages
• Translating the Interface
• Translating content
• Setting up multilingual building blocks
• Configuring a translation workflow
• Auditing/configuring contrib modules
Before you start
• How many languages?
• Who are the translators?
• How will content be translated? What
method should be used?
• Choose a default language that makes
sense
• Have a plan for translation workflow +
adding languages in the future
• Leave extra time for testing contrib
modules
What to Avoid?
• Changing the default language
• Passing variables through the t function
• Putting non-English text in code
http://acquia.com/training-feedback
Feedback please!
Q+A