5 * Installation functions for Content Translation module.
11 * Implements hook_install().
13 function content_translation_install() {
14 // Assign a fairly low weight to ensure our implementation of
15 // hook_module_implements_alter() is run among the last ones.
16 module_set_weight('content_translation', 10);
18 // Translation works when at least two languages are added.
19 if (count(\Drupal::languageManager()->getLanguages()) < 2) {
21 ':language_url' => Url::fromRoute('entity.configurable_language.collection')->toString()
23 $message = t('This site has only a single language enabled. <a href=":language_url">Add at least one more language</a> in order to translate content.', $t_args);
24 drupal_set_message($message, 'warning');
26 // Point the user to the content translation settings.
28 ':settings_url' => Url::fromRoute('language.content_settings_page')->toString()
30 $message = t('<a href=":settings_url">Enable translation</a> for <em>content types</em>, <em>taxonomy vocabularies</em>, <em>accounts</em>, or any other element you wish to translate.', $t_args);
31 drupal_set_message($message, 'warning');
35 * Rebuild the routes as the content translation routes have now new names.
37 function content_translation_update_8001() {
38 \Drupal::service('router.builder')->rebuild();
42 * Clear field type plugin caches to fix image field translatability.
44 function content_translation_update_8002() {
45 \Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();