drupal 8 s multilingual apis
play

Drupal 8s multilingual APIs Gbor Hojtsy DRUPAL 7 MULTILINGUAL - PowerPoint PPT Presentation

Drupal 8s multilingual APIs Gbor Hojtsy DRUPAL 7 MULTILINGUAL DRUPAL 7 MULTILINGUAL Drupal CORE DRUPAL 7 MULTILINGUAL LOCALE Drupal CORE DRUPAL 7 MULTILINGUAL LOCALE L10n UP m Drupal CORE DRUPAL 7 MULTILINGUAL LOCALE


  1. Drupal 8’s multilingual APIs Gábor Hojtsy

  2. DRUPAL 7 MULTILINGUAL

  3. DRUPAL 7 MULTILINGUAL Drupal CORE

  4. DRUPAL 7 MULTILINGUAL LOCALE � Drupal CORE

  5. DRUPAL 7 MULTILINGUAL LOCALE L10n UP � m Drupal CORE

  6. DRUPAL 7 MULTILINGUAL LOCALE L10n UP � m CONTENT TRANSLATION Drupal CORE Ü

  7. DRUPAL 7 MULTILINGUAL LOCALE L10n UP � m CONTENT TRANSLATION Drupal CORE Ü � I18N

  8. DRUPAL 7 MULTILINGUAL LOCALE L10n UP � m CONTENT TRANSLATION VARIABLE Drupal CORE Ü � � I18N

  9. DRUPAL 7 MULTILINGUAL LOCALE Entity translation L10n UP � m � CONTENT TRANSLATION VARIABLE Drupal CORE Ü � � I18N

  10. FOUR PILLARS IN DRUPAL 8

  11. FOUR PILLARS IN DRUPAL 8 � LANGUAGE Base services for all modules dealing with data. Not just multilingual.

  12. FOUR PILLARS IN DRUPAL 8 8 � LANGUAGE INTERFACE Base services for all Interface modules dealing translation has with data. Not just built-in update multilingual. feature, improved usability.

  13. FOUR PILLARS IN DRUPAL 8 8 é � LANGUAGE INTERFACE CONTENT Base services for all Interface Field translation in modules dealing translation has built-in API for all with data. Not just built-in update entities. Content multilingual. feature, improved translation module usability. provides user interface.

  14. FOUR PILLARS IN DRUPAL 8 8 é � ( LANGUAGE INTERFACE CONTENT CONFIG Base services for all Interface Field translation in Common modules dealing translation has built-in API for all configuration with data. Not just built-in update entities. Content system handles multilingual. feature, improved translation module blocks, views, field usability. provides user settings. Unified interface. translation.

  15. FOUR PILLARS IN DRUPAL 8 8 é � ( LANGUAGE INTERFACE CONTENT CONFIG

  16. DEALING WITH LANGUAGE LanguageManager \Drupal:languageManager() ConfigurableLanguageManager

  17. DEALING WITH LANGUAGE ->getLanguages() EN: ENGLISH ( DEFAULT ) UND: NOT SPECIFIED ZXX: NOT APPLICABLE

  18. DEALING WITH LANGUAGE ->getLanguages() UND: NOT SPECIFIED HU: HUNGARIAN ZXX: NOT APPLICABLE IT: ITALIAN

  19. DEALING WITH LANGUAGE ->getLanguages() UND: NOT SPECIFIED HU: HUNGARIAN ZXX: NOT APPLICABLE IT: ITALIAN language.entity.$langcode.yml

  20. DEALING WITH LANGUAGE ->getLanguages() UND: NOT SPECIFIED HU: HUNGARIAN ZXX: NOT APPLICABLE IT: ITALIAN Locked language.entity.$langcode.yml

  21. DEALING WITH LANGUAGE ->getLanguages() UND: NOT SPECIFIED HU: HUNGARIAN ZXX: NOT APPLICABLE IT: ITALIAN Locked Not locked language.entity.$langcode.yml

  22. DEALING WITH LANGUAGE ConfigurableLanguage:: 
 createFromLangcode(‘fr’) 
 ->save()

  23. DEALING WITH LANGUAGE ConfigurableLanguage:: 
 load(‘fr’)->delete()

  24. DEALING WITH LANGUAGE $languageManager 
 ->getCurrentLanguage()

  25. FOUR PILLARS IN DRUPAL 8 8 é � ( LANGUAGE INTERFACE CONTENT CONFIG

  26. INTERFACE LANGUAGE

  27. INTERFACE LANGUAGE t(‘English text’)

  28. INTERFACE LANGUAGE

  29. DEPENDENCY INJECTION CONFIGURATION USER LOGIC TRANSLATION

  30. DEPENDENCY INJECTION CONFIGURATION USER LOGIC TRANSLATION

  31. INTERFACE LANGUAGE t(‘English text’)

  32. INTERFACE LANGUAGE t(‘English text’) $this->t(‘English text’)

  33. INTERFACE LANGUAGE class Foo { use StringTranslationTrait; … }

  34. INTERFACE LANGUAGE

  35. INTERFACE LANGUAGE $this->t(‘English text’) 
 ->getOption(‘langcode’);

  36. INTERFACE LANGUAGE format_plural(…) $this->formatPlural(…)

  37. JAVASCRIPT API Drupal.t(…) Drupal.formatPlural()

  38. 
 LOCALE.LINKS.MENU.YML locale.translate_page: 
 title: 'User interface translation' 
 description: 'Configure the import …’ 
 route_name: locale.translate_page 
 parent: system.admin_config_regional 
 weight: 15 locale.translate_status: 
 title: 'Available translation updates' 
 route_name: locale.translate_status 
 description: 'Get a status report …’ 
 parent: system.admin_reports

  39. 
 LOCALE.LINKS.MENU.YML locale.translate_page: 
 title: 'User interface translation' 
 description: 'Configure the import …’ 
 route_name: locale.translate_page 
 parent: system.admin_config_regional 
 weight: 15 locale.translate_status: 
 title: 'Available translation updates' 
 route_name: locale.translate_status 
 description: 'Get a status report …’ 
 parent: system.admin_reports

  40. FOUR PILLARS IN DRUPAL 8 8 é � ( LANGUAGE INTERFACE CONTENT CONFIG English to X

  41. NODE.PHP ( SNIPPET ) /** * Defines the node entity class. * * @ContentEntityType( * id = "node", * label = @Translation(“Content"), * translatable = TRUE, * entity_keys = { * "id" = "nid", * "label" = "title", * "langcode" = "langcode", * } * )

  42. NODE.PHP ( SNIPPET ) function baseFieldDefinitions($entity_type) { // … $fields['title'] = BaseFieldDefinition::create('string') ->setLabel(t('Title')) ->setRequired(TRUE) ->setTranslatable(TRUE); }

  43. FIELDS THEMSELVES

  44. FIELDS THEMSELVES AUTOMATED!

  45. MULTICOLUMN FIELD SNIPPET * @FieldType( * id = "image", * column_groups = { * "file" = { * "label" = @Translation("File"), * "columns" = { * "target_id", "width", "height" * }, * }, * "alt" = { * "label" = @Translation("Alt"), * "translatable" = TRUE * }, * }

  46. ENTITY LANGUAGE API $node = Node::load(42); $node = $node ->getTranslation(‘hu’); $node = $entityRepository ->getTranslationFromContext($node);

  47. ENTITY LANGUAGE API $node->getUntranslated() $node->language() $node->getTranslationLanguages() $node->hasTranslation(‘hu’) $node->addTranslation(‘hu’) $node->removeTranslation(‘hu’)

  48. VIEWS ALL THE THINGS

  49. FOUR PILLARS IN DRUPAL 8 8 é � ( LANGUAGE INTERFACE CONTENT CONFIG English to X X to Y Intelligent objects

  50. CONFIG / INSTALL / SYSTEM.MAINTENANCE.YML message: '@site is currently under maintenance. We should be back shortly. Thank you for your patience.' langcode: en

  51. CORE.DATA _ TYPES.SCHEMA.YML config_object: type: mapping mapping: langcode: type: string label: 'Language code' … text: type: string label: 'Text' translatable: true

  52. CONFIG / SCHEMA / SYSTEM.SCHEMA.YML LANGCODE system.maintenance: type: config_object label: 'Maintenance mode' mapping: TRANSLATABLE message: STRING type: text label: 'Message to display…’

  53. SYSTEM.MAINTENANCE.YML message: '@site is currently under maintenance. We should be back shortly. Thank you for your patience.' langcode: en

  54. SYSTEM.MAINTENANCE.YML message: '@site is currently under maintenance. We should be back shortly. Thank you for your patience.' langcode: en LANGUAGES / HU / SYSTEM.…YML

  55. SYSTEM.MAINTENANCE.YML message: '@site is currently under maintenance. We should be back shortly. Thank you for your patience.' langcode: en LANGUAGES / HU / SYSTEM.…YML message: '@site karbantartás alatt áll…’

  56. SYSTEM.MAINTENANCE.YML message: '@site is currently under maintenance. We should be back shortly. Thank you for your patience.' langcode: en LANGUAGES / HU / SYSTEM.…YML message: '@site karbantartás alatt áll…’ LANGUAGES / IT / SYSTEM.…YML

  57. SYSTEM.MAINTENANCE.YML message: '@site is currently under maintenance. We should be back shortly. Thank you for your patience.' langcode: en LANGUAGES / HU / SYSTEM.…YML message: '@site karbantartás alatt áll…’ LANGUAGES / IT / SYSTEM.…YML message: '@site …’

  58. CONFIGURATION API $config = \Drupal::config(‘system.maintenance’); $config->get(‘message’);

  59. CONFIGURATION API OVERRIDES APPLY AS APPROPRIATE $config = \Drupal::config(‘system.maintenance’); $config->get(‘message’);

  60. CONFIGURATION API $manager = \Drupal::languageManager(); $hu = $manager->getLanguage('hu'); $original = $manager->getConfigOverrideLanguage(); $manager->setConfigOverrideLanguage($hu); $config = \Drupal::config(‘system.maintenance'); // … $manager->setConfigOverrideLanguage($original);

  61. CONFIGURATION API \Drupal::config(‘system.maintenance’); OVERRIDES APPLY AS APPROPRIATE \Drupal::configFactory()- >getEditable(‘system.maintenance’); NO OVERRIDES APPLY \Drupal::languageManager() ->getLanguageConfigOverride THE OVERRIDE ('hu', 'system.maintenance') ITSELF ->set('message', 'Karbantartás...') ->save();

  62. FOUR PILLARS IN DRUPAL 8 8 é � ( LANGUAGE INTERFACE CONTENT CONFIG English to X X to Y X to Y Intelligent Dumb objects arrays

  63. How was it? Evaluate this session - https://events.drupal.org/node/9814 @gaborhojtsy

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend