Drupal7 multilingual


Published on

Multilingual sites in Drupal 7: New features, new possibilities
by Grigory Naumovets
(A presentation ar DrupalCamp Kyiv, June 3-4, 2011)

  • Be the first to comment

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

No notes for slide

Drupal7 multilingual

  1. 1. Multilingual sites in Drupal 7: New features, new possibilities Grigory Naumovets Kiev, Ukraine
  2. 2. Outline <ul><li>Support of multilingual content in Drupal: an overview </li></ul><ul><li>New multilingual features in D7 core </li></ul><ul><li>New multilingual features in D7 versions of contributed modules (i18n etc.) </li></ul><ul><li>Summary of most important improvements in multilingual functionality </li></ul><ul><li>Problems and prospects </li></ul>
  3. 3. It’s a followup presentation to: <ul><li>Multilingual sites in Drupal : Problems, solutions, workarounds, and “goodness on the way” </li></ul><ul><li>(DrupalCamp Kyiv 2009) </li></ul><ul><li>www.slideshare.net/Tinnka/multilanguage-drupal </li></ul><ul><li>gn.org.ua/drupal/presentations/DrupalCamp_2009-2010 </li></ul><ul><li>2009 ----> 2011: </li></ul><ul><li>Has anything essential changed with the release of Drupal 7? </li></ul><ul><li>Is “multilingual goodness” already approaching, or still on the way? </li></ul>
  4. 4. What is ”i18n” and ”L10n”? <ul><li>i nternationalizatio n  i18n </li></ul>18 letters omitted 10 letters omitted L ocalizatio n  L10n These abbreviations are used in the names of Drupal modules, such as “i18n” or “L10n_client”
  5. 5. If Drupal nodes were designed as multilingual from the very beginning … <ul><li>node/1 </li></ul><ul><li>(multilingual) </li></ul>Title (lang1) Title (lang2) Body (lang1) Body (lang2) Some field (lang1) Some field (lang2) Another field (language-neutral) Some file attached (lang1) Some file attached (lang2) Another file attached (language-neutral) comments
  6. 6. However, Drupal nodes are unilingual . i18n is an external feature. <ul><li>node/1 (unilingual) lang1 </li></ul>Some file attached Another file attached node/2 (unilingual) lang2 Some file attached Another file attached Drupal i18n system: I hereby declare node/1 and node/2 to be translations of each other comments comments Title Body Some field Another field Title Body Some field Another field
  7. 7. Multilanguage: inside or outside? <ul><li>Two possible approaches to i18n: </li></ul><ul><li>Multilingual features inside an object </li></ul><ul><li>Unilingual object, multilanguage features are applied from outside as a system of connections to other objects </li></ul><ul><li>“ Object” can be a node, a block, a taxonomy term, a menu, a menu item, and so on. </li></ul>
  8. 8. Inside vs outside <ul><li>Drupal uses both approaches (depending on the object type), so improvements of multilang support proceed in two ways: </li></ul><ul><ul><li>Making objects “more multilingual” </li></ul></ul><ul><ul><li>Improving the system of i18n-related connections between unilingual objects </li></ul></ul><ul><li>Each approach has its advantages and difficulties </li></ul><ul><li>Until recently, approach to nodes was only “from outside” </li></ul><ul><li>Some problems caused by this approach will be demonstrated below </li></ul>
  9. 9. No field-level language attributes: Why it can be a problem? Example 1 <ul><li>node/1 lang1 </li></ul>Image field node/2 lang2 Image field translation synchronization Title Body Title Body
  10. 10. No field-level language attributes: Why it can be a problem? Example 2 <ul><li>You need to synchronize nodereferences </li></ul><ul><li>(i18nsync) </li></ul>node/3 (en) event info node/4 (ru) event info node/1 (en) location info node/2 (ru) location info translation translation nodereference nodereference
  11. 11. Problem with multilingual views based on nodereference <ul><li>ru/events/by-location/ Распределение со бытий по месту проведения: </li></ul><ul><ul><li>Киев (6) </li></ul></ul><ul><ul><li>Кишинёв (4) </li></ul></ul>ru/events/by-location/37 Список событий в Кишинёве <ul><li>en/events/by-location/ Events grouped by locations : </li></ul><ul><ul><li>Kiev (6) </li></ul></ul><ul><ul><li>Chişinău (4) </li></ul></ul>en/events/by-location/36 List of events in Chişinău “ Chişinău ” (node/36) and “ Кишинёв ” (node/37) are different nodes, so when you switch language EN -> RU while viewing the “ List of events in Chişinău ” you will see an empty list instead of “ Список событий в Кишинёве ” . en  ru en  ru
  12. 12. Inside vs outside <ul><li>However, the “outside” approach can have some advantages, too </li></ul><ul><ul><li>It can be simpler to do or maintain </li></ul></ul><ul><ul><li>It can utilize such node-level things as access permissions for nodes having certain attributes (e.g. when you have different people working with nodes in different languages), and so on </li></ul></ul><ul><li>It’s highly desirable to have both possibilities, and choose between them depending on the specific situation. </li></ul>
  13. 13. Now, let us look at the D7 core <ul><li>Modules included in D7 core (same as for D6): </li></ul><ul><ul><li>Content Translation </li></ul></ul><ul><ul><li>Locale </li></ul></ul><ul><li>( disabled by default ) </li></ul>
  14. 14. Site configuration settings: “ Regional and Language ” section <ul><li>Available after enabling the “ Locale ” module </li></ul>
  15. 15. Regional settings <ul><li>New in D7: </li></ul><ul><li>Now you can set “Default country” (to be used by contributed modules) </li></ul><ul><li>More intelligent time zone handling (with PHP 5.2+ DateTime objects ) </li></ul>
  16. 16. Date and time settings <ul><li>More control over date and time format </li></ul>
  17. 17. Configuration of Languages: Detection and selection <ul><li>New in D7: </li></ul><ul><li>Finer control over language detection and selection </li></ul><ul><li>We can set order of priorities </li></ul>
  18. 18. Interface translation <ul><li>New in D7: </li></ul><ul><li>Improved user interface </li></ul><ul><li>Support for context </li></ul>
  19. 19. Contexts are intended for per-meaning translatability Context: “May” as Long month name ( not “may be”) Context is a new feature; guidelines still need to be developed. So far, used inconsistently. Not supported by Javascript menu items and strings.
  20. 20. Localization auto-update <ul><li>Localization update module by Jose Reyero ( L10n_update ) </li></ul><ul><li>Works similarly to Drupal core update module </li></ul><ul><li>Downloads translation updates from localize.drupal.org (or from custom depository) </li></ul><ul><li>Available both for D7 and D6 (v. 7.x-1.0-beta2 and 6.x-1.0-beta1 of 2011-May-31 ) </li></ul>
  21. 21. “ Cheat sheets” for localizers (“ шпаргалки ”) <ul><li>Drupal 7 localization cheat sheet Drupal 6 localization cheat sheet by Gábor Hojtsy hojtsy.hu/files/Drupal7TranslationCheatSheetv2.pdf hojtsy.hu/files/Drupal6TranslationCheatSheetv2.pdf </li></ul>
  22. 22. Now about content translation Enable multilingual support in content type properties: Looking for this in “Publishing options” is not really obvious
  23. 23. Now we can control ‘ node.language ’ attribute for nodes of this content type <ul><li>By default, a new node is Language neutral </li></ul>New in D7: For language-neutral nodes, database field node.language = ‘und’ ‘ und’ means ‘undetermined’ in compliance with ISO 639
  24. 24. Node translation (same as in D6) <ul><li>“ Translate ” tab is seen when: </li></ul><ul><li>This content type has multilingual support “ Enabled, with translation ” </li></ul><ul><li>This node is NOT language neutral </li></ul><ul><li>User is permitted to translate content </li></ul>
  25. 25. “ Translation set” (same as in D6) <ul><li>‘ tnid ’ – translation set id </li></ul><ul><li>is shared by all nodes in a translation set </li></ul><ul><li>is equal to ‘nid’ of the base node </li></ul>node/1 Base node node.nid=1 node.language=‘ en ’ node.tnid= 1 node/2 Translated node node.nid=2 node.language=‘ uk ’ node.tnid= 1 node/3 Translated node node.nid=3 node.language=‘ ru ’ node.tnid= 1
  26. 26. And now something really new… We need to use some contributed modules However, D7 has NO built-in interface for translatable fields  D7 core has built-in support for field languages!!! (via its new Field API) 
  27. 27. Entity_translation module <ul><li>Can be used to translate fields </li></ul>New item in “Regional and language settings” – “Entity translation”
  28. 28. Entity translation <ul><li>Field settings: “Users may translate this field” </li></ul>New option for multilingual support in content type properties
  29. 29. Single node with multilingual body and other fields: wow, it [almost] works! <ul><li>Node title is a different kind of field and cannot be translated this way!!! </li></ul>example.com/uk/node/1 example.com/node/1
  30. 30. ‘ Title’ module: replace node title with a regular field
  31. 31. Single node with multilingual body and other fields: now the title can be translated, too! <ul><li>Node title is now replaced with a regular field using ‘Title’ module </li></ul>example.com/uk/node/1 example.com/node/1
  32. 32. Entity_translation + Title: is this already the “multilingual field goodness”? <ul><li>These modules are very recent, still at the ‘dev’ stage (v. 7.x-1.x-dev ) </li></ul><ul><li>As of June 2, 2011, </li></ul><ul><ul><li>130 sites currently report using ‘Entity_translation’ </li></ul></ul><ul><ul><li>59 sites currently report using ‘Title’ </li></ul></ul><ul><li>Still quite a lot of todo’s </li></ul><ul><li>We need to test its interactions with views. taxonomy, paths, and so on. </li></ul>
  33. 33. Now about the i18n.module <ul><li>Q: Can I build a multilingual site using only the core D7 functionality? </li></ul><ul><li>A: A very simple site – yes, but for more complex things you’ll need the i18n.module. i18n helps you handle multilingual blocks, menus, views, synchronization of items between nodes, and so on. </li></ul>
  34. 34. Enabling multilingual variables in i18n/D6: add their names ( site_name , site_footer , theme_settings , etc.) to the settings.php file $conf['i18n_variables'] = array( // Site name, slogan, mission, etc.. 'site_name', 'site_slogan', 'site_mission', 'site_footer', 'anonymous', // Different front page for each language 'site_frontpage', // Primary and secondary links 'menu_primary_links_source', 'menu_secondary_links_source', // Contact form information 'contact_form_information', // For theme variables, read more below 'theme_settings', 'theme_garland_settings', );
  35. 35. i18n/D7 does not work this way anymore Now multilingual variables are controlled via “Multilingial settings – Variables” menu (Depends on the new variable.module )
  36. 36. Multilingual variables A very convenient link to switch languages (especially if there is no language switcher in the admin theme)
  37. 37. New in D7 and important: Translation set API <ul><li>(i18n_translation.module) </li></ul><ul><li>Now we can create translation sets not only for nodes, but for other things, too: </li></ul><ul><ul><li>taxonomy terms </li></ul></ul><ul><ul><li>menu items </li></ul></ul><ul><ul><li>paths </li></ul></ul><ul><li>Not implemented yet for blocks </li></ul>
  38. 38. Taxonomy terms Connect different terms as translations of each other: This option was available in D6, too – but it did not really work. Now (I hope) it should!
  39. 39. New: Path translation (i18n_path.module) <ul><li>Intended for translation of generic paths that don't have other way of being translated. </li></ul><ul><li>From any of these pages, the language switcher will point to the other path for each language. </li></ul><ul><li>Note: path translations must be defined without aliases. </li></ul>
  40. 40. Menu translation <ul><li>Thanks to Translation set API, now we can translate menu items pointing to specific nodes, e.g.: (en) -> node/1 (uk) -> node/2 </li></ul>
  41. 41. Blocks <ul><li>Translation sets not working for Blocks yet(?) </li></ul><ul><li>Improved UI and visibility options </li></ul><ul><li>Block can be translated via string translation </li></ul>
  42. 42. Other improvements in i18n <ul><li>More options and improved UI for content selection and filtering by language </li></ul><ul><li>More items can be synchronized between translation set nodes (because more items are available as Fields) </li></ul><ul><li>Translation redirect (i18n_redirect.module): redirect to translated path when available (SEO optimization) </li></ul><ul><li>Contact form translation (i18n_contact.module) – recently added </li></ul>
  43. 43. Berlin Internationalization sprint (May 11-15, 2011) <ul><li>i18nsprint.drupalevents.de </li></ul><ul><li>reyero.net/en/drupal/berlin_internationalization_sprint : “ How i18n got some fresh blood and a sexy facelift ” </li></ul><ul><li>i18n 7.x-1.0-beta6 (May 24, 2011) includes improvements from Berlin i18n sprint. New features: </li></ul><ul><ul><li>Consistent translation tabs for objects </li></ul></ul><ul><ul><li>Contact form translation </li></ul></ul>
  44. 44. Summary of most important changes in D7 and i18n/D7 <ul><li>D7: </li></ul><ul><ul><li>Translation of fields within a node (no built-in UI yet, available via recently contributed modules) </li></ul></ul><ul><li>i18n/D7: </li></ul><ul><ul><li>Translation sets (connecting taxonomy terms, menu items, paths, etc.) </li></ul></ul><ul><li>Plus lots of less important improvements in UI, content selection and filtering, etc. </li></ul>
  45. 45. References <ul><li>Drupal 7's new multilingual systems compilation by Gábor Hojtsy hojtsy.hu/multilingual-drupal7 </li></ul><ul><li>Drupal 7 Multilingual: What is new in i18n by Suzanne Kennedy evolvingweb.ca/story/drupal-7-multilingual-whats-new-i18n </li></ul><ul><li>Multilanguage for Drupal 7: Internationalization module (i18n beta1) by Jose Reyero reyero.net/en/drupal/drupal7_i18n_beta1_overview </li></ul><ul><li>Content Translation (field translation) in Drupal 7: First steps by Randy Fay (read discussions in the comments, too!) randyfay.com/node/88 </li></ul>
  46. 46. Questions? <ul><li>Contacts: </li></ul><ul><li>http://camp11.drupal.ua/users/GN </li></ul><ul><li>[email_address] </li></ul><ul><li>http://gn.org.ua/feedback </li></ul>