Issue #1188388 by plach, peximo, YesCT | Gábor Hojtsy, fago, webchick, Bojhan, podarok, cosmicdreams, Berdir, aspilicious, bforchhammer, penyaskito: Added Entity translation UI in core.
2012-11-04 02:38:49 +00:00
<?php
/**
* @file
2013-06-25 19:16:20 +00:00
* Installation functions for Content Translation module.
Issue #1188388 by plach, peximo, YesCT | Gábor Hojtsy, fago, webchick, Bojhan, podarok, cosmicdreams, Berdir, aspilicious, bforchhammer, penyaskito: Added Entity translation UI in core.
2012-11-04 02:38:49 +00:00
*/
2016-02-26 11:12:40 +00:00
use \Drupal\Core\Url;
Issue #1188388 by plach, peximo, YesCT | Gábor Hojtsy, fago, webchick, Bojhan, podarok, cosmicdreams, Berdir, aspilicious, bforchhammer, penyaskito: Added Entity translation UI in core.
2012-11-04 02:38:49 +00:00
/**
* Implements hook_install().
*/
2013-06-25 19:16:20 +00:00
function content_translation_install() {
2013-01-07 11:36:47 +00:00
// Assign a fairly low weight to ensure our implementation of
// hook_module_implements_alter() is run among the last ones.
2013-06-25 19:16:20 +00:00
module_set_weight('content_translation', 10);
2014-05-04 17:19:57 +00:00
// Translation works when at least two languages are added.
2014-03-31 17:29:01 +00:00
if (count(\Drupal::languageManager()->getLanguages()) < 2) {
2016-02-26 11:12:40 +00:00
// @todo: Switch to Url::fromRoute() once https://www.drupal.org/node/2589967 is resolved.
$t_args = [':language_url' => Url::fromUri('internal:/admin/config/regional/language')->toString()];
2016-02-11 16:27:57 +00:00
$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);
2013-01-07 11:36:47 +00:00
drupal_set_message($message, 'warning');
}
// Point the user to the content translation settings.
2016-02-26 11:12:40 +00:00
$t_args = [':settings_url' => Url::fromUri('internal:/admin/config/regional/content-language')->toString()];
Issue #2570355 by Sutharsan, stefan.r, kgoel, josephdpurcell, joelpittet, justAChris, dawehner, pfrenssen, pwolanin, David_Rothstein, catch: Replace remaining !placeholder and @placeholder with :placeholder for URLs
2015-09-22 06:16:37 +00:00
$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);
Issue #1188388 by plach, peximo, YesCT | Gábor Hojtsy, fago, webchick, Bojhan, podarok, cosmicdreams, Berdir, aspilicious, bforchhammer, penyaskito: Added Entity translation UI in core.
2012-11-04 02:38:49 +00:00
drupal_set_message($message, 'warning');
}
2015-11-12 22:14:00 +00:00
/**
* @addtogroup updates-8.0.0-rc
* @{
*/
/**
* Rebuild the routes as the content translation routes have now new names.
*/
function content_translation_update_8001() {
\Drupal::service('router.builder')->rebuild();
}
/**
* @} End of "addtogroup updates-8.0.0-rc".
*/
2016-02-25 15:54:27 +00:00
/**
* @addtogroup updates-8.0.x
* @{
*/
/**
* Clear field type plugin caches to fix image field translatability.
*/
function content_translation_update_8002() {
\Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();
}
/**
* @} End of "addtogroup updates-8.0.x".
*/