Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -13,6 +13,7 @@ use Drupal\Core\StringTranslation\TranslationInterface;
|
|||
use Drupal\Core\Url;
|
||||
use Drupal\locale\LocaleConfigManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
|
@ -73,9 +74,11 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
* The entity manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
|
||||
* The event dispatcher.
|
||||
*/
|
||||
public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
|
||||
parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager, $language_manager);
|
||||
public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL) {
|
||||
parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager, $language_manager, $event_dispatcher);
|
||||
$this->setType($plugin_definition['entity_type']);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
|
@ -97,7 +100,8 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
$container->get('router.route_provider'),
|
||||
$container->get('string_translation'),
|
||||
$container->get('entity.manager'),
|
||||
$container->get('language_manager')
|
||||
$container->get('language_manager'),
|
||||
$container->get('event_dispatcher')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -105,9 +109,9 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function populateFromRouteMatch(RouteMatchInterface $route_match) {
|
||||
parent::populateFromRouteMatch($route_match);
|
||||
$entity = $route_match->getParameter($this->entityType);
|
||||
$this->setEntity($entity);
|
||||
parent::populateFromRouteMatch($route_match);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,7 +267,7 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
$parameters += [
|
||||
$this->entityType => [
|
||||
'type' => 'entity:' . $this->entityType,
|
||||
]
|
||||
],
|
||||
];
|
||||
$route->setOption('parameters', $parameters);
|
||||
}
|
||||
|
|
|
@ -282,12 +282,12 @@ interface ConfigMapperInterface {
|
|||
public function hasTranslation(LanguageInterface $language);
|
||||
|
||||
/**
|
||||
* Populate the config mapper with request data.
|
||||
*
|
||||
* @todo Replace $request with RouteMatch https://www.drupal.org/node/2295255.
|
||||
* Populate the config mapper with route match data.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* The route match.
|
||||
*
|
||||
* @see \Drupal\config_translation\Event\ConfigTranslationEvents::POPULATE_MAPPER
|
||||
*/
|
||||
public function populateFromRouteMatch(RouteMatchInterface $route_match);
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Drupal\config_translation;
|
||||
|
||||
use Drupal\config_translation\Event\ConfigMapperPopulateEvent;
|
||||
use Drupal\config_translation\Event\ConfigTranslationEvents;
|
||||
use Drupal\config_translation\Exception\ConfigMapperLanguageException;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Config\TypedConfigManagerInterface;
|
||||
|
@ -15,6 +17,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
|||
use Drupal\Core\Url;
|
||||
use Drupal\locale\LocaleConfigManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
|
@ -61,7 +64,7 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
/**
|
||||
* The base route object that the mapper is attached to.
|
||||
*
|
||||
* @return \Symfony\Component\Routing\Route
|
||||
* @var \Symfony\Component\Routing\Route
|
||||
*/
|
||||
protected $baseRoute;
|
||||
|
||||
|
@ -86,6 +89,13 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
*/
|
||||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* The event dispatcher.
|
||||
*
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
/**
|
||||
* Constructs a ConfigNamesMapper.
|
||||
*
|
||||
|
@ -115,12 +125,14 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
* The string translation manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
|
||||
* (optional) The event dispatcher.
|
||||
*
|
||||
* @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
|
||||
* Throws an exception if the route specified by the 'base_route_name' in
|
||||
* the plugin definition could not be found by the route provider.
|
||||
*/
|
||||
public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation, LanguageManagerInterface $language_manager) {
|
||||
public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL) {
|
||||
$this->pluginId = $plugin_id;
|
||||
$this->pluginDefinition = $plugin_definition;
|
||||
$this->routeProvider = $route_provider;
|
||||
|
@ -132,6 +144,7 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
|
||||
$this->stringTranslation = $string_translation;
|
||||
$this->languageManager = $language_manager;
|
||||
$this->eventDispatcher = $event_dispatcher ?: \Drupal::service('event_dispatcher');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +162,8 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
$container->get('plugin.manager.config_translation.mapper'),
|
||||
$container->get('router.route_provider'),
|
||||
$container->get('string_translation'),
|
||||
$container->get('language_manager')
|
||||
$container->get('language_manager'),
|
||||
$container->get('event_dispatcher')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -368,6 +382,9 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
*/
|
||||
public function populateFromRouteMatch(RouteMatchInterface $route_match) {
|
||||
$this->langcode = $route_match->getParameter('langcode');
|
||||
|
||||
$event = new ConfigMapperPopulateEvent($this, $route_match);
|
||||
$this->eventDispatcher->dispatch(ConfigTranslationEvents::POPULATE_MAPPER, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,7 +62,7 @@ class ConfigTranslationController extends ControllerBase {
|
|||
/**
|
||||
* The language manager.
|
||||
*
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
|
@ -139,7 +139,7 @@ class ConfigTranslationController extends ControllerBase {
|
|||
|
||||
$languages = $this->languageManager->getLanguages();
|
||||
if (count($languages) == 1) {
|
||||
drupal_set_message($this->t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', [':url' => $this->url('entity.configurable_language.collection')]), 'warning');
|
||||
$this->messenger()->addWarning($this->t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', [':url' => $this->url('entity.configurable_language.collection')]));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -162,7 +162,7 @@ class ConfigTranslationController extends ControllerBase {
|
|||
'#items' => $items,
|
||||
],
|
||||
];
|
||||
drupal_set_message($this->renderer->renderPlain($message), 'warning');
|
||||
$this->messenger()->addWarning($this->renderer->renderPlain($message));
|
||||
|
||||
$original_langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
|
||||
$operations_access = FALSE;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\config_translation\Controller;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
|
@ -97,7 +96,7 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
|
|||
public function getFilterLabels() {
|
||||
$info = parent::getFilterLabels();
|
||||
$bundle = $this->baseEntityInfo->getBundleLabel() ?: $this->t('Bundle');
|
||||
$bundle = Unicode::strtolower($bundle);
|
||||
$bundle = mb_strtolower($bundle);
|
||||
|
||||
$info['placeholder'] = $this->t('Enter field or @bundle', ['@bundle' => $bundle]);
|
||||
$info['description'] = $this->t('Enter a part of the field or @bundle to filter by.', ['@bundle' => $bundle]);
|
||||
|
|
|
@ -45,7 +45,8 @@ class ConfigTranslationListController extends ControllerBase {
|
|||
* The name of the mapper.
|
||||
*
|
||||
* @return array
|
||||
* A render array as expected by drupal_render().
|
||||
* A render array as expected by
|
||||
* \Drupal\Core\Render\RendererInterface::render().
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
* Throws an exception if a mapper plugin could not be instantiated from the
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Event;
|
||||
|
||||
use Drupal\config_translation\ConfigMapperInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Provides a class for events related to configuration translation mappers.
|
||||
*/
|
||||
class ConfigMapperPopulateEvent extends Event {
|
||||
|
||||
/**
|
||||
* The configuration mapper this event is related to.
|
||||
*
|
||||
* @var \Drupal\config_translation\ConfigMapperInterface
|
||||
*/
|
||||
protected $mapper;
|
||||
|
||||
/**
|
||||
* The route match this event is related to.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteMatchInterface
|
||||
*/
|
||||
protected $routeMatch;
|
||||
|
||||
/**
|
||||
* Constructs a ConfigMapperPopulateEvent object.
|
||||
*
|
||||
* @param \Drupal\config_translation\ConfigMapperInterface $mapper
|
||||
* The configuration mapper this event is related to.
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* The route match this event is related to.
|
||||
*/
|
||||
public function __construct(ConfigMapperInterface $mapper, RouteMatchInterface $route_match) {
|
||||
$this->mapper = $mapper;
|
||||
$this->routeMatch = $route_match;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration mapper this event is related to.
|
||||
*
|
||||
* @return \Drupal\config_translation\ConfigMapperInterface
|
||||
* The configuration mapper this event is related to.
|
||||
*/
|
||||
public function getMapper() {
|
||||
return $this->mapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the route match this event is related to.
|
||||
*
|
||||
* @return \Drupal\Core\Routing\RouteMatchInterface
|
||||
* The route match this event is related to.
|
||||
*/
|
||||
public function getRouteMatch() {
|
||||
return $this->routeMatch;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Event;
|
||||
|
||||
/**
|
||||
* Provides a list of events dispatched by the Configuration Translation module.
|
||||
*/
|
||||
final class ConfigTranslationEvents {
|
||||
|
||||
/**
|
||||
* The name of the event dispatched when a configuration mapper is populated.
|
||||
*
|
||||
* Allows modules to add related config for translation on a specific
|
||||
* translation form.
|
||||
*
|
||||
* @see \Drupal\config_translation\ConfigMapperInterface::populateFromRouteMatch()
|
||||
*/
|
||||
const POPULATE_MAPPER = 'config_translation.populate_mapper';
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Routing\RouteMatchInterface;
|
|||
|
||||
/**
|
||||
* Defines a form for adding configuration translations.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigTranslationAddForm extends ConfigTranslationFormBase {
|
||||
|
||||
|
@ -34,7 +36,7 @@ class ConfigTranslationAddForm extends ConfigTranslationFormBase {
|
|||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
parent::submitForm($form, $form_state);
|
||||
drupal_set_message($this->t('Successfully saved @language translation.', ['@language' => $this->language->getName()]));
|
||||
$this->messenger()->addStatus($this->t('Successfully saved @language translation.', ['@language' => $this->language->getName()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||
|
||||
/**
|
||||
* Builds a form to delete configuration translation.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigTranslationDeleteForm extends ConfirmFormBase {
|
||||
|
||||
|
@ -140,7 +142,7 @@ class ConfigTranslationDeleteForm extends ConfirmFormBase {
|
|||
$cache_backend->deleteAll();
|
||||
}
|
||||
|
||||
drupal_set_message($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));
|
||||
$this->messenger()->addStatus($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));
|
||||
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Routing\RouteMatchInterface;
|
|||
|
||||
/**
|
||||
* Defines a form for editing configuration translations.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigTranslationEditForm extends ConfigTranslationFormBase {
|
||||
|
||||
|
@ -34,7 +36,7 @@ class ConfigTranslationEditForm extends ConfigTranslationFormBase {
|
|||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
parent::submitForm($form, $form_state);
|
||||
drupal_set_message($this->t('Successfully updated @language translation.', ['@language' => $this->language->getName()]));
|
||||
$this->messenger()->addStatus($this->t('Successfully updated @language translation.', ['@language' => $this->language->getName()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ interface ElementInterface {
|
|||
public static function create(TypedDataInterface $schema);
|
||||
|
||||
/**
|
||||
* Builds a render array containg the source and translation form elements.
|
||||
* Builds a render array containing the source and translation form elements.
|
||||
*
|
||||
* @param \Drupal\Core\Language\LanguageInterface $source_language
|
||||
* The source language of the configuration object.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\config_translation\FormElement;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\language\Config\LanguageConfigOverride;
|
||||
|
@ -20,7 +20,7 @@ class PluralVariants extends FormElementBase {
|
|||
$values = explode(LOCALE_PLURAL_DELIMITER, $source_config);
|
||||
$element = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@source_language)</span>', [
|
||||
'#title' => new FormattableMarkup('@label <span class="visually-hidden">(@source_language)</span>', [
|
||||
// Labels originate from configuration schema and are translatable.
|
||||
'@label' => $this->t($this->definition->getLabel()),
|
||||
'@source_language' => $source_language->getName(),
|
||||
|
@ -32,7 +32,7 @@ class PluralVariants extends FormElementBase {
|
|||
'#type' => 'item',
|
||||
// @todo Should use better labels https://www.drupal.org/node/2499639
|
||||
'#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'),
|
||||
'#markup' => SafeMarkup::format('<span lang="@langcode">@value</span>', [
|
||||
'#markup' => new FormattableMarkup('<span lang="@langcode">@value</span>', [
|
||||
'@langcode' => $source_language->getId(),
|
||||
'@value' => isset($values[$i]) ? $values[$i] : $this->t('(Empty)'),
|
||||
]),
|
||||
|
@ -49,7 +49,7 @@ class PluralVariants extends FormElementBase {
|
|||
$values = explode(LOCALE_PLURAL_DELIMITER, $translation_config);
|
||||
$element = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@translation_language)</span>', [
|
||||
'#title' => new FormattableMarkup('@label <span class="visually-hidden">(@translation_language)</span>', [
|
||||
// Labels originate from configuration schema and are translatable.
|
||||
'@label' => $this->t($this->definition->getLabel()),
|
||||
'@translation_language' => $translation_language->getName(),
|
||||
|
|
|
@ -15,7 +15,7 @@ class Textarea extends FormElementBase {
|
|||
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
|
||||
// Estimate a comfortable size of the input textarea.
|
||||
$rows_words = ceil(str_word_count($translation_config) / 5);
|
||||
$rows_newlines = substr_count($translation_config, "\n" ) + 1;
|
||||
$rows_newlines = substr_count($translation_config, "\n") + 1;
|
||||
$rows = max($rows_words, $rows_newlines);
|
||||
|
||||
return [
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Drupal\config_translation\Plugin\Menu\ContextualLink;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Menu\ContextualLinkDefault;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Defines a contextual link plugin with a dynamic title.
|
||||
|
@ -22,12 +22,12 @@ class ConfigTranslationContextualLink extends ContextualLinkDefault {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTitle() {
|
||||
public function getTitle(Request $request = NULL) {
|
||||
// Use the custom 'config_translation_plugin_id' plugin definition key to
|
||||
// retrieve the title. We need to retrieve a runtime title (as opposed to
|
||||
// storing the title on the plugin definition for the link) because it
|
||||
// contains translated parts that we need in the runtime language.
|
||||
$type_name = Unicode::strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
|
||||
$type_name = mb_strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
|
||||
return $this->t('Translate @type_name', ['@type_name' => $type_name]);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Drupal\config_translation\Plugin\Menu\LocalTask;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Menu\LocalTaskDefault;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Defines a local task plugin with a dynamic title.
|
||||
|
@ -22,12 +22,12 @@ class ConfigTranslationLocalTask extends LocalTaskDefault {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTitle() {
|
||||
public function getTitle(Request $request = NULL) {
|
||||
// Take custom 'config_translation_plugin_id' plugin definition key to
|
||||
// retrieve title. We need to retrieve a runtime title (as opposed to
|
||||
// storing the title on the plugin definition for the link) because
|
||||
// it contains translated parts that we need in the runtime language.
|
||||
$type_name = Unicode::strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
|
||||
$type_name = mb_strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
|
||||
return $this->t('Translate @type_name', ['@type_name' => $type_name]);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,52 +2,20 @@
|
|||
|
||||
namespace Drupal\config_translation\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
@trigger_error('The ' . __NAMESPACE__ . '\I18nProfileField is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use ' . __NAMESPACE__ . '\ProfileFieldTranslation', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* i18n strings profile field source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_i18n_profile_field",
|
||||
* source_provider = "i18n"
|
||||
* source_module = "i18nprofile"
|
||||
* )
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x and will be removed in Drupal 9.0.x. Use
|
||||
* \Drupal\config_translation\Plugin\migrate\source\d6\ProfileFieldTranslation
|
||||
* instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2898649
|
||||
*/
|
||||
class I18nProfileField extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('profile_fields', 'pf')
|
||||
->fields('pf', ['fid', 'name'])
|
||||
->fields('i18n', ['property'])
|
||||
->fields('lt', ['lid', 'translation', 'language']);
|
||||
$query->leftJoin('i18n_strings', 'i18n', 'i18n.objectid = pf.name');
|
||||
$query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'fid' => $this->t('Profile field ID.'),
|
||||
'lid' => $this->t('Locales target language ID.'),
|
||||
'language' => $this->t('Language for this field.'),
|
||||
'translation' => $this->t('Translation of either the title or explanation.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
$ids['language']['type'] = 'string';
|
||||
$ids['lid']['type'] = 'integer';
|
||||
$ids['lid']['alias'] = 'lt';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
class I18nProfileField extends ProfileFieldTranslation {}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Gets i18n strings profile field source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_profile_field_translation",
|
||||
* source_module = "i18nprofile"
|
||||
* )
|
||||
*/
|
||||
class ProfileFieldTranslation extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('profile_fields', 'pf')
|
||||
->fields('pf', ['fid', 'name'])
|
||||
->fields('i18n', ['property'])
|
||||
->fields('lt', ['lid', 'translation', 'language']);
|
||||
$query->leftJoin('i18n_strings', 'i18n', 'i18n.objectid = pf.name');
|
||||
$query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'fid' => $this->t('Profile field ID.'),
|
||||
'lid' => $this->t('Locales target language ID.'),
|
||||
'language' => $this->t('Language for this field.'),
|
||||
'translation' => $this->t('Translation of either the title or explanation.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
$ids['language']['type'] = 'string';
|
||||
$ids['lid']['type'] = 'integer';
|
||||
$ids['lid']['alias'] = 'lt';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests for altering configuration translation forms.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationFormTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['config_translation', 'config_translation_test', 'editor'];
|
||||
|
||||
/**
|
||||
* The plugin ID of the mapper to test.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $pluginId;
|
||||
|
||||
/**
|
||||
* The language code of the language to use for testing.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $langcode;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$definitions = \Drupal::service('plugin.manager.config_translation.mapper')->getDefinitions();
|
||||
$this->pluginId = key($definitions);
|
||||
|
||||
$this->langcode = 'xx';
|
||||
ConfigurableLanguage::create(['id' => $this->langcode, 'label' => 'XX'])->save();
|
||||
|
||||
\Drupal::state()->set('config_translation_test_alter_form_alter', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests altering of the configuration translation forms.
|
||||
*/
|
||||
public function testConfigTranslationFormAlter() {
|
||||
$form_builder = \Drupal::formBuilder();
|
||||
$add_form = $form_builder->getForm('Drupal\config_translation\Form\ConfigTranslationAddForm', \Drupal::routeMatch(), $this->pluginId, $this->langcode);
|
||||
$edit_form = $form_builder->getForm('Drupal\config_translation\Form\ConfigTranslationEditForm', \Drupal::routeMatch(), $this->pluginId, $this->langcode);
|
||||
|
||||
// Test that hook_form_BASE_FORM_ID_alter() was called for the base form ID
|
||||
// 'config_translation_form'.
|
||||
$this->assertTrue($add_form['#base_altered']);
|
||||
$this->assertTrue($edit_form['#base_altered']);
|
||||
|
||||
// Test that hook_form_FORM_ID_alter() was called for the form IDs
|
||||
// 'config_translation_add_form' and 'config_translation_edit_form'.
|
||||
$this->assertTrue($add_form['#altered']);
|
||||
$this->assertTrue($edit_form['#altered']);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
|
||||
use Drupal\simpletest\InstallerTestBase;
|
||||
|
||||
/**
|
||||
* Installs the config translation module on a site installed in non english.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationInstallTest extends InstallerTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $langcode = 'eo';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $profile = 'standard';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpLanguage() {
|
||||
// Place custom local translations in the translations directory.
|
||||
mkdir(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations', 0777, TRUE);
|
||||
file_put_contents(DRUPAL_ROOT . '/' . $this->siteDirectory . '/files/translations/drupal-8.0.0.eo.po', $this->getPo('eo'));
|
||||
|
||||
parent::setUpLanguage();
|
||||
|
||||
$this->translations['Save and continue'] = 'Save and continue eo';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string for the test .po file.
|
||||
*
|
||||
* @param string $langcode
|
||||
* The language code.
|
||||
* @return string
|
||||
* Contents for the test .po file.
|
||||
*/
|
||||
protected function getPo($langcode) {
|
||||
return <<<ENDPO
|
||||
msgid ""
|
||||
msgstr ""
|
||||
|
||||
msgid "Save and continue"
|
||||
msgstr "Save and continue $langcode"
|
||||
|
||||
msgid "Anonymous"
|
||||
msgstr "Anonymous $langcode"
|
||||
|
||||
msgid "Language"
|
||||
msgstr "Language $langcode"
|
||||
ENDPO;
|
||||
}
|
||||
|
||||
public function testConfigTranslation() {
|
||||
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'en'], t('Add custom language'));
|
||||
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'fr'], t('Add custom language'));
|
||||
|
||||
$edit = [
|
||||
'modules[config_translation][enable]' => TRUE,
|
||||
];
|
||||
$this->drupalPostForm('admin/modules', $edit, t('Install'));
|
||||
|
||||
$this->drupalGet('/admin/structure/types/manage/article/fields');
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,172 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationOverviewTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = [
|
||||
'block',
|
||||
'config_test',
|
||||
'config_translation',
|
||||
'config_translation_test',
|
||||
'contact',
|
||||
'contextual',
|
||||
'entity_test_operation',
|
||||
'views',
|
||||
'views_ui',
|
||||
];
|
||||
|
||||
/**
|
||||
* Languages to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* String translation storage object.
|
||||
*
|
||||
* @var \Drupal\locale\StringStorageInterface
|
||||
*/
|
||||
protected $localeStorage;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$permissions = [
|
||||
'translate configuration',
|
||||
'administer languages',
|
||||
'administer site configuration',
|
||||
'administer contact forms',
|
||||
'access site-wide contact form',
|
||||
'access contextual links',
|
||||
'administer views',
|
||||
];
|
||||
// Create and log in user.
|
||||
$this->drupalLogin($this->drupalCreateUser($permissions));
|
||||
|
||||
// Add languages.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
}
|
||||
$this->localeStorage = $this->container->get('locale.storage');
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the config translation mapper page.
|
||||
*/
|
||||
public function testMapperListPage() {
|
||||
$this->drupalGet('admin/config/regional/config-translation');
|
||||
$this->assertLinkByHref('admin/config/regional/config-translation/config_test');
|
||||
$this->assertLinkByHref('admin/config/people/accounts/translate');
|
||||
// Make sure there is only a single operation for each dropbutton, either
|
||||
// 'List' or 'Translate'.
|
||||
foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
|
||||
$this->assertIdentical(1, $dropbutton->count());
|
||||
foreach ($dropbutton->li as $link) {
|
||||
$this->assertTrue(((string) $link->a === 'Translate') || ((string) $link->a === 'List'));
|
||||
}
|
||||
}
|
||||
|
||||
$labels = [
|
||||
'&$nxd~i0',
|
||||
'some "label" with quotes',
|
||||
$this->randomString(),
|
||||
];
|
||||
|
||||
foreach ($labels as $label) {
|
||||
$test_entity = entity_create('config_test', [
|
||||
'id' => $this->randomMachineName(),
|
||||
'label' => $label,
|
||||
]);
|
||||
$test_entity->save();
|
||||
|
||||
$base_url = 'admin/structure/config_test/manage/' . $test_entity->id();
|
||||
$this->drupalGet('admin/config/regional/config-translation/config_test');
|
||||
$this->assertLinkByHref($base_url . '/translate');
|
||||
$this->assertEscaped($test_entity->label());
|
||||
|
||||
// Make sure there is only a single 'Translate' operation for each
|
||||
// dropbutton.
|
||||
foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
|
||||
$this->assertIdentical(1, $dropbutton->count());
|
||||
foreach ($dropbutton->li as $link) {
|
||||
$this->assertIdentical('Translate', (string) $link->a);
|
||||
}
|
||||
}
|
||||
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId());
|
||||
$this->drupalGet($base_url . '/translate');
|
||||
|
||||
$title = $test_entity->label() . ' ' . $entity_type->getLowercaseLabel();
|
||||
$title = 'Translations for <em class="placeholder">' . Html::escape($title) . '</em>';
|
||||
$this->assertRaw($title);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
|
||||
$this->drupalGet($base_url);
|
||||
$this->assertLink(t('Translate @title', ['@title' => $entity_type->getLowercaseLabel()]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests availability of hidden entities in the translation overview.
|
||||
*/
|
||||
public function testHiddenEntities() {
|
||||
// Hidden languages are only available to translate through the
|
||||
// configuration translation listings.
|
||||
$this->drupalGet('admin/config/regional/config-translation/configurable_language');
|
||||
$this->assertText('Not applicable');
|
||||
$this->assertLinkByHref('admin/config/regional/language/edit/zxx/translate');
|
||||
$this->assertText('Not specified');
|
||||
$this->assertLinkByHref('admin/config/regional/language/edit/und/translate');
|
||||
|
||||
// Hidden date formats are only available to translate through the
|
||||
// configuration translation listings. Test a couple of them.
|
||||
$this->drupalGet('admin/config/regional/config-translation/date_format');
|
||||
$this->assertText('HTML Date');
|
||||
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_date/translate');
|
||||
$this->assertText('HTML Year');
|
||||
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_year/translate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that overrides do not affect listing screens.
|
||||
*/
|
||||
public function testListingPageWithOverrides() {
|
||||
$original_label = 'Default';
|
||||
$overridden_label = 'Overridden label';
|
||||
|
||||
$config_test_storage = $this->container->get('entity.manager')->getStorage('config_test');
|
||||
|
||||
// Set up an override.
|
||||
$settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [
|
||||
'value' => $overridden_label,
|
||||
'required' => TRUE,
|
||||
];
|
||||
$this->writeSettings($settings);
|
||||
|
||||
// Test that the overridden label is loaded with the entity.
|
||||
$this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label);
|
||||
|
||||
// Test that the original label on the listing page is intact.
|
||||
$this->drupalGet('admin/config/regional/config-translation/config_test');
|
||||
$this->assertText($original_label);
|
||||
$this->assertNoText($overridden_label);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Verifies theme configuration translation settings.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationUiThemeTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['config_translation', 'config_translation_test'];
|
||||
|
||||
/**
|
||||
* Languages to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* Administrator user for tests.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$admin_permissions = [
|
||||
'administer themes',
|
||||
'administer languages',
|
||||
'administer site configuration',
|
||||
'translate configuration',
|
||||
];
|
||||
// Create and log in user.
|
||||
$this->adminUser = $this->drupalCreateUser($admin_permissions);
|
||||
|
||||
// Add languages.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that theme provided *.config_translation.yml files are found.
|
||||
*/
|
||||
public function testThemeDiscovery() {
|
||||
// Install the test theme and rebuild routes.
|
||||
$theme = 'config_translation_test_theme';
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
$this->drupalGet('admin/appearance');
|
||||
$elements = $this->xpath('//a[normalize-space()=:label and contains(@href, :theme)]', [
|
||||
':label' => 'Install and set as default',
|
||||
':theme' => $theme,
|
||||
]);
|
||||
$this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], ['external' => TRUE]);
|
||||
|
||||
$translation_base_url = 'admin/config/development/performance/translate';
|
||||
$this->drupalGet($translation_base_url);
|
||||
$this->assertResponse(200);
|
||||
$this->assertLinkByHref("$translation_base_url/fr/add");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
|
||||
use Drupal\views_ui\Tests\UITestBase;
|
||||
|
||||
/**
|
||||
* Visit view list and test if translate is available.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationViewListUiTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['node', 'test_view'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['config_translation', 'views_ui'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$permissions = [
|
||||
'administer views',
|
||||
'translate configuration',
|
||||
];
|
||||
|
||||
// Create and log in user.
|
||||
$this->drupalLogin($this->drupalCreateUser($permissions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests views_ui list to see if translate link is added to operations.
|
||||
*/
|
||||
public function testTranslateOperationInViewListUi() {
|
||||
// Views UI List 'admin/structure/views'.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$translate_link = 'admin/structure/views/view/test_view/translate';
|
||||
// Test if the link to translate the test_view is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
|
||||
// Test that the 'Edit' tab appears.
|
||||
$this->assertLinkByHref('admin/structure/views/view/test_view');
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue