Parler en plusieurs langues avec Drupal - Drupalcamp Paris 2013


Published on

Parler en plusieurs langues avec Drupal
Speak multiple languages with Drupal

Published in: Education, Business, Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Parler en plusieurs langues avec Drupal - Drupalcamp Paris 2013

  1. 1. Parler en plusieurs langues avec DrupalBogdan HereaZsolt Tasnadi
  2. 2. l About usl Before we start building a sitel Translating codel Variables and settingsl Translating user entered contentl Translating taxonomiesl Translating medial Other tips and tricksl ConclusionsSummary
  3. 3. About meBogdan Herea- Founder & CEO- 18 years of professional IT experience inFrance, Belgium & Romania- Obtained in 1998 his Engineering Degree atINSA Lyon, France- 8 years of IT Management, prior to foundingPITECH+PLUS- Commercial & strategic spearhead, andmentor for middle & top-management
  4. 4. PITECH+PLUS is a European softwarebusiness started in Cluj-Napoca, RomaniaKey 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. 5. Our expertise contributed to thesuccess of famous brands – Part 1
  6. 6. Our expertise contributed to thesuccess of famous brands – Part 2
  8. 8. Before we start a sitel How many languages will the site have?l Enable the languagesl Decide which to use:l  content translation vs entity translationl Download, install the core and contributionmodules for translations
  9. 9. Before we start the site!TIP: Use the default English language only as source!To be changed in Drupal 8Install en-us or en-gb for English and use thosefor displaying content.Use string overrides module only if you are sureyou will not have to many exceptions(Hard to maintain, eating lot of resources)
  10. 10. Before we start the siteContent translation:l  In corel  Use it only if you migrating your site from Drupal 6l  The old way of translation content (a nodefor each language)Entity translation:l  Supposed to be on core, wasnt finished on time,core contributors are working on it.l  Stores the translations in fieldsl  You cant translate entity properties with itl  This is the future, Drupal 8 will havesomething similar
  11. 11. Translating codeThe 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 cant decide to use t() or st()$t = get_t();$text = $t(text to translate.);
  12. 12. Translating codeContext (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: Dont use variables in t();Dont: echo t($text_to_translate);Workaround!Do like views is exporting labels in features!
  13. 13. Translating codeFormat pluralsformat_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 formattedusing drupal_placeholder()
  14. 14. Variables and settingsTransliteration module (chars/path) – a must haveTranslating variables with i18n_variable (site title)Translating custom variables (hook_variables_info)(Variables Table)Translating custom content with i18n submodules:l  Block translationl  Path translationl  Menu translationl  Views translation (independent module)
  15. 15. Translating contentUse entity translation for translating nodesor custom entities.!TIP: use the title module for nodes, elsenodes titles wont be translatable.Use Title Module
  16. 16. Translating taxonomiesTaxonomy i18n translation – the old wayTaxonomies translated as entities:l  Use name as machine namel  Create translatable title field !!!
  17. 17. Translating media?Dont! Files are referenced by fields, use translationon the entity reference field.If you are using entity translation for files:l  Problems with field_get_items and entitymetadata 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. 18. Other tips and tricksOther useful modules:l  Contact translationl  Translation overviewl  Translation management toolOther tips:l  Localization update – synchronizesthe translations automatically instead ofdownloading the po files manually
  19. 19. Other tips and tricksOther tipsRedirect localization update to customtranslation 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. 20. ConclusionsTranslations UI and translation implementationimproved a lot from Drupal 6.Still lot of work (entity translation in core, entityproperties translation, etc.)Drupal 8 will get in lots of good stuff, checkDrupal 8 multilingual initiative (D8MI).
  21. 21.              Questions?