SlideShare a Scribd company logo
1 of 21
Download to read offline
Parler en plusieurs langues avec Drupal
Bogdan Herea
Zsolt Tasnadi
l About us
l Before we start building a site
l Translating code
l Variables and settings
l Translating user entered content
l Translating taxonomies
l Translating media
l Other tips and tricks
l Conclusions
Summary
About me
Bogdan Herea- Founder & CEO
- 18 years of professional IT experience in
France, Belgium & Romania
- Obtained in 1998 his Engineering Degree at
INSA Lyon, France
- 8 years of IT Management, prior to founding
PITECH+PLUS
- Commercial & strategic spearhead, and
mentor for middle & top-management
PITECH+PLUS is a European software
business started in Cluj-Napoca, Romania
Key Facts
- Founded in 2005
- 120 Employees
- 12 spoken languages
- Offices: Berlin, Paris, Brussels,
Bucharest, Prague.
Strategic Markets
- Healthcare
- Governmental (incl. International)
- Advertising agencies
- Public Companies
- Start-ups
Our expertise contributed to the
success of famous brands – Part 1
Our expertise contributed to the
success of famous brands – Part 2
TECH OVERVIEW
Before we start a site
l How many languages will the site have?
l Enable the languages
l Decide which to use:
l  content translation vs entity translation
l Download, install the core and contribution
modules for translations
Before we start the site
!TIP: Use the default English language only as source!
To be changed in Drupal 8
Install en-us or en-gb for English and use those
for displaying content.
Use string overrides module only if you are sure
you will not have to many exceptions
(Hard to maintain, eating lot of resources)
Before we start the site
Content translation:
l  In core
l  Use it only if you migrating your site from Drupal 6
l  The old way of translation content (a node
for each language)
Entity translation:
l  Supposed to be on core, wasn't finished on time,
core contributors are working on it.
l  Stores the translations in fields
l  You can't translate entity properties with it
l  This is the future, Drupal 8 will have
something similar
Translating code
The t function:
$text = t("@name is presenting a session.",
array('@name' => format_username($account)));
The st function:
$text = st("@name is installing Drupal for a session.",
array('@name' => format_username($account)));
The get_t function:
Use it when can't decide to use t() or st()
$t = get_t();
$text = $t('text to translate.');
Translating code
Context (new from Drupal 7):
print t('Order', array(), array('context' => 'non-commerce-page'));
Because of context, $conf translations shall be declared:
$conf['locale_custom_strings_en'][''] = array(
'ORIGINAL STRING' => 'YOUR STRING',
);
TIP: Don't use variables in t();
Don't: echo t($text_to_translate);
Workaround!
Do like views is exporting labels in features!
Translating code
Format plurals
format_plural($count, '1 category', '@count categories');
Variables placeholder
@variable – check plain applied to the variable
!variable – output the value without filtering it
%variable – Escaped to HTML and formatted
using drupal_placeholder()
Variables and settings
Transliteration module (chars/path) – a must have
Translating variables with i18n_variable (site title)
Translating custom variables (hook_variables_info)
(Variables Table)
Translating custom content with i18n submodules:
l  Block translation
l  Path translation
l  Menu translation
l  Views translation (independent module)
Translating content
Use entity translation for translating nodes
or custom entities.
!TIP: use the title module for nodes, else
node's titles won't be translatable.
Use Title Module
Translating taxonomies
Taxonomy i18n translation – the old way
Taxonomies translated as entities:
l  Use name as machine name
l  Create translatable title field !!!
Translating media?
Don't! Files are referenced by fields, use translation
on the entity reference field.
If you are using entity translation for files:
l  Problems with field_get_items and entity
metadata wrappers;
l  Workaround (not recommended):
/**
* Implements hook_entity_TYPE_load().
*/
function mymodule_entity_file_load($entities)
foreach ($entities as $entity) {
$entity->language = language_default('language');
}
}
Other tips and tricks
Other useful modules:
l  Contact translation
l  Translation overview
l  Translation management tool
Other tips:
l  Localization update – synchronizes
the translations automatically instead of
downloading the po files manually
Other tips and tricks
Other tips
Redirect localization update to custom
translation server
/**
* Implements hook_l10n_update_projects_alter().
*/
function mymodule_l10n_update_projects_alter(&$projects) {
$projects['contrib_module]['info'] = array_merge(
$projects['contrib_module']['info'], array(
'l10n server' => $custom_l10n_server',
'l10n url' => $custom_l10n_url,
'l10n path' => $custom_l10n_path,
)
);
}
Conclusions
Translations UI and translation implementation
improved a lot from Drupal 6.
Still lot of work (entity translation in core, entity
properties translation, etc.)
Drupal 8 will get in lots of good stuff, check
Drupal 8 multilingual initiative (D8MI).
 
	
  
	
  
	
  
	
  
	
  
	
  
Questions?

More Related Content

Similar to Parler en plusieurs langues avec Drupal

Drupal 8 customized checkout system
Drupal 8 customized checkout systemDrupal 8 customized checkout system
Drupal 8 customized checkout systemAhmad Hassan
 
Drupal 8 customized checkout system
Drupal 8 customized checkout systemDrupal 8 customized checkout system
Drupal 8 customized checkout systemAhmad Hassan
 
Putting DITA Localization into Practice
Putting DITA Localization into PracticePutting DITA Localization into Practice
Putting DITA Localization into PracticeXMetaL
 
Safetty systems intro_embedded_c
Safetty systems intro_embedded_cSafetty systems intro_embedded_c
Safetty systems intro_embedded_cMaria Cida Rosa
 
LavaCon 2017 - Reusing Your Reuse: How to Keep the Reuse You Have When You Mo...
LavaCon 2017 - Reusing Your Reuse: How to Keep the Reuse You Have When You Mo...LavaCon 2017 - Reusing Your Reuse: How to Keep the Reuse You Have When You Mo...
LavaCon 2017 - Reusing Your Reuse: How to Keep the Reuse You Have When You Mo...Jack Molisani
 
Drupal7 Release Party in Luxembourg
Drupal7 Release Party in LuxembourgDrupal7 Release Party in Luxembourg
Drupal7 Release Party in Luxembourgnvisionagency
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentsparkfabrik
 
Drupalcamp Atlanta 2010 Internationalization Presentation
Drupalcamp Atlanta 2010 Internationalization PresentationDrupalcamp Atlanta 2010 Internationalization Presentation
Drupalcamp Atlanta 2010 Internationalization PresentationMediacurrent
 
Open Power Template 2 presentation
Open Power Template 2 presentationOpen Power Template 2 presentation
Open Power Template 2 presentationTomasz Jędrzejewski
 
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural LanguagesData Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural LanguagesIan Huston
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Ian Huston
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsSuite Solutions
 
C:\Users\User\Desktop\Eclipse Infocenter
C:\Users\User\Desktop\Eclipse InfocenterC:\Users\User\Desktop\Eclipse Infocenter
C:\Users\User\Desktop\Eclipse InfocenterSuite Solutions
 
Django Translations: Internationalization
Django Translations: Internationalization Django Translations: Internationalization
Django Translations: Internationalization Jaya Silwal
 
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...PyData
 
WordPress internationalization, localization, and multilingual
WordPress internationalization, localization, and multilingualWordPress internationalization, localization, and multilingual
WordPress internationalization, localization, and multilingualmbigul
 
Bring drupal 8 to all in their native languages
Bring drupal 8 to all in their native languagesBring drupal 8 to all in their native languages
Bring drupal 8 to all in their native languagesSébastien Corbin
 
Talend Data Integration Tutorial | Talend Tutorial For Beginners | Talend Onl...
Talend Data Integration Tutorial | Talend Tutorial For Beginners | Talend Onl...Talend Data Integration Tutorial | Talend Tutorial For Beginners | Talend Onl...
Talend Data Integration Tutorial | Talend Tutorial For Beginners | Talend Onl...Edureka!
 

Similar to Parler en plusieurs langues avec Drupal (20)

Drupal 8 customized checkout system
Drupal 8 customized checkout systemDrupal 8 customized checkout system
Drupal 8 customized checkout system
 
Drupal 8 customized checkout system
Drupal 8 customized checkout systemDrupal 8 customized checkout system
Drupal 8 customized checkout system
 
Putting DITA Localization into Practice
Putting DITA Localization into PracticePutting DITA Localization into Practice
Putting DITA Localization into Practice
 
Safetty systems intro_embedded_c
Safetty systems intro_embedded_cSafetty systems intro_embedded_c
Safetty systems intro_embedded_c
 
LavaCon 2017 - Reusing Your Reuse: How to Keep the Reuse You Have When You Mo...
LavaCon 2017 - Reusing Your Reuse: How to Keep the Reuse You Have When You Mo...LavaCon 2017 - Reusing Your Reuse: How to Keep the Reuse You Have When You Mo...
LavaCon 2017 - Reusing Your Reuse: How to Keep the Reuse You Have When You Mo...
 
Drupal7 Release Party in Luxembourg
Drupal7 Release Party in LuxembourgDrupal7 Release Party in Luxembourg
Drupal7 Release Party in Luxembourg
 
The Best Talend Training From myTectra in Bangalore
The Best Talend Training From myTectra in BangaloreThe Best Talend Training From myTectra in Bangalore
The Best Talend Training From myTectra in Bangalore
 
Drupal7 multilingual
Drupal7 multilingualDrupal7 multilingual
Drupal7 multilingual
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Drupalcamp Atlanta 2010 Internationalization Presentation
Drupalcamp Atlanta 2010 Internationalization PresentationDrupalcamp Atlanta 2010 Internationalization Presentation
Drupalcamp Atlanta 2010 Internationalization Presentation
 
Open Power Template 2 presentation
Open Power Template 2 presentationOpen Power Template 2 presentation
Open Power Template 2 presentation
 
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural LanguagesData Science Amsterdam - Massively Parallel Processing with Procedural Languages
Data Science Amsterdam - Massively Parallel Processing with Procedural Languages
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputs
 
C:\Users\User\Desktop\Eclipse Infocenter
C:\Users\User\Desktop\Eclipse InfocenterC:\Users\User\Desktop\Eclipse Infocenter
C:\Users\User\Desktop\Eclipse Infocenter
 
Django Translations: Internationalization
Django Translations: Internationalization Django Translations: Internationalization
Django Translations: Internationalization
 
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
Massively Parallel Processing with Procedural Python by Ronert Obst PyData Be...
 
WordPress internationalization, localization, and multilingual
WordPress internationalization, localization, and multilingualWordPress internationalization, localization, and multilingual
WordPress internationalization, localization, and multilingual
 
Bring drupal 8 to all in their native languages
Bring drupal 8 to all in their native languagesBring drupal 8 to all in their native languages
Bring drupal 8 to all in their native languages
 
Talend Data Integration Tutorial | Talend Tutorial For Beginners | Talend Onl...
Talend Data Integration Tutorial | Talend Tutorial For Beginners | Talend Onl...Talend Data Integration Tutorial | Talend Tutorial For Beginners | Talend Onl...
Talend Data Integration Tutorial | Talend Tutorial For Beginners | Talend Onl...
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Parler en plusieurs langues avec Drupal

  • 1. Parler en plusieurs langues avec Drupal Bogdan Herea Zsolt Tasnadi
  • 2. l About us l Before we start building a site l Translating code l Variables and settings l Translating user entered content l Translating taxonomies l Translating media l Other tips and tricks l Conclusions Summary
  • 3. About me Bogdan Herea- Founder & CEO - 18 years of professional IT experience in France, Belgium & Romania - Obtained in 1998 his Engineering Degree at INSA Lyon, France - 8 years of IT Management, prior to founding PITECH+PLUS - Commercial & strategic spearhead, and mentor for middle & top-management
  • 4. PITECH+PLUS is a European software business started in Cluj-Napoca, Romania Key Facts - Founded in 2005 - 120 Employees - 12 spoken languages - Offices: Berlin, Paris, Brussels, Bucharest, Prague. Strategic Markets - Healthcare - Governmental (incl. International) - Advertising agencies - Public Companies - Start-ups
  • 5. Our expertise contributed to the success of famous brands – Part 1
  • 6. Our expertise contributed to the success of famous brands – Part 2
  • 8. Before we start a site l How many languages will the site have? l Enable the languages l Decide which to use: l  content translation vs entity translation l Download, install the core and contribution modules for translations
  • 9. Before we start the site !TIP: Use the default English language only as source! To be changed in Drupal 8 Install en-us or en-gb for English and use those for displaying content. Use string overrides module only if you are sure you will not have to many exceptions (Hard to maintain, eating lot of resources)
  • 10. Before we start the site Content translation: l  In core l  Use it only if you migrating your site from Drupal 6 l  The old way of translation content (a node for each language) Entity translation: l  Supposed to be on core, wasn't finished on time, core contributors are working on it. l  Stores the translations in fields l  You can't translate entity properties with it l  This is the future, Drupal 8 will have something similar
  • 11. Translating code The t function: $text = t("@name is presenting a session.", array('@name' => format_username($account))); The st function: $text = st("@name is installing Drupal for a session.", array('@name' => format_username($account))); The get_t function: Use it when can't decide to use t() or st() $t = get_t(); $text = $t('text to translate.');
  • 12. Translating code Context (new from Drupal 7): print t('Order', array(), array('context' => 'non-commerce-page')); Because of context, $conf translations shall be declared: $conf['locale_custom_strings_en'][''] = array( 'ORIGINAL STRING' => 'YOUR STRING', ); TIP: Don't use variables in t(); Don't: echo t($text_to_translate); Workaround! Do like views is exporting labels in features!
  • 13. Translating code Format plurals format_plural($count, '1 category', '@count categories'); Variables placeholder @variable – check plain applied to the variable !variable – output the value without filtering it %variable – Escaped to HTML and formatted using drupal_placeholder()
  • 14. Variables and settings Transliteration module (chars/path) – a must have Translating variables with i18n_variable (site title) Translating custom variables (hook_variables_info) (Variables Table) Translating custom content with i18n submodules: l  Block translation l  Path translation l  Menu translation l  Views translation (independent module)
  • 15. Translating content Use entity translation for translating nodes or custom entities. !TIP: use the title module for nodes, else node's titles won't be translatable. Use Title Module
  • 16. Translating taxonomies Taxonomy i18n translation – the old way Taxonomies translated as entities: l  Use name as machine name l  Create translatable title field !!!
  • 17. Translating media? Don't! Files are referenced by fields, use translation on the entity reference field. If you are using entity translation for files: l  Problems with field_get_items and entity metadata wrappers; l  Workaround (not recommended): /** * Implements hook_entity_TYPE_load(). */ function mymodule_entity_file_load($entities) foreach ($entities as $entity) { $entity->language = language_default('language'); } }
  • 18. Other tips and tricks Other useful modules: l  Contact translation l  Translation overview l  Translation management tool Other tips: l  Localization update – synchronizes the translations automatically instead of downloading the po files manually
  • 19. Other tips and tricks Other tips Redirect localization update to custom translation server /** * Implements hook_l10n_update_projects_alter(). */ function mymodule_l10n_update_projects_alter(&$projects) { $projects['contrib_module]['info'] = array_merge( $projects['contrib_module']['info'], array( 'l10n server' => $custom_l10n_server', 'l10n url' => $custom_l10n_url, 'l10n path' => $custom_l10n_path, ) ); }
  • 20. Conclusions Translations UI and translation implementation improved a lot from Drupal 6. Still lot of work (entity translation in core, entity properties translation, etc.) Drupal 8 will get in lots of good stuff, check Drupal 8 multilingual initiative (D8MI).
  • 21.               Questions?