diff --git a/core/modules/config_translation/core/modules/config_translation/config_translation.admin.css b/core/modules/config_translation/core/modules/config_translation/config_translation.admin.css deleted file mode 100644 index 66d9ef3..0000000 --- a/core/modules/config_translation/core/modules/config_translation/config_translation.admin.css +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file - * Styles for configuration translation. - */ - -/** - * Hide the label, in an accessible way, for responsive screens which show the - * form in one column. - */ -.config-translation-form .translation-element-wrapper .translation label { - position: absolute !important; - clip: rect(1px, 1px, 1px, 1px); - overflow: hidden; - height: 1px; - width: 1px; -} - -/** - * For wider screens, show the label and display source and translation side by - * side. - */ -@media all and (min-width: 851px) { - .config-translation-form .translation-element-wrapper .source { - width: 48%; - float: left; - } - .config-translation-form .translation-element-wrapper .translation { - width: 48%; - float: right; - } - .config-translation-form .translation-element-wrapper .translation label { - position: static !important; - clip: auto; - overflow: visible; - height: auto; - width: auto; - } -} diff --git a/core/modules/config_translation/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/core/modules/config_translation/config_translation.api.php deleted file mode 100644 index e6ca187..0000000 --- a/core/modules/config_translation/core/modules/config_translation/config_translation.api.php +++ /dev/null @@ -1,66 +0,0 @@ -addName('othermodule.altered_settings_key'); - } -} - -/** - * @} End of "addtogroup hooks". - */ diff --git a/core/modules/config_translation/core/modules/config_translation/config_translation.info.yml b/core/modules/config_translation/core/modules/config_translation/config_translation.info.yml deleted file mode 100644 index aebc7f4..0000000 --- a/core/modules/config_translation/core/modules/config_translation/config_translation.info.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: 'Configuration Translation' -type: module -description: 'Provides a translation interface for configuration.' -package: Multilingual -version: VERSION -core: 8.x -dependencies: - - locale diff --git a/core/modules/config_translation/core/modules/config_translation/config_translation.module b/core/modules/config_translation/core/modules/config_translation/config_translation.module deleted file mode 100644 index 520b108..0000000 --- a/core/modules/config_translation/core/modules/config_translation/config_translation.module +++ /dev/null @@ -1,382 +0,0 @@ -' . t('About') . ''; - $output .= '

' . t('The Configuration Translation module lets you translate configuration from all around your Drupal site. Views, your site name, contact module categories, vocabularies, menus, blocks, and so on are all stored with Drupal\'s unified configuration system and can be translated with this module. Content, such as nodes, taxonomy terms, custom blocks, and so on are translatable with the Content translation module in Drupal core, while the built-in user interface (such as registration forms, content submission and administration interfaces) are translated with the Interface translation module. Use these tthree modules effectively together to translate your whole site to different languages.') . '

'; - return $output; - } -} - -/** - * Implements hook_menu(). - */ -function config_translation_menu() { - // Generate translation tabs for keys where a specific path can be - // determined. This makes it possible to use translation features in-context - // of the administration experience. - $config_groups = config_translation_get_groups(); - foreach ($config_groups as $group) { - $path = $group->getBasePath(); - if ($group->hasEditTab()) { - // For pages that do not have a default tab, we need a default local task - // on this level, so that the translate tab will show up. - // @todo This is not very compatible with possible other alters. Look - // into other clever ways to make this happen, - // http://drupal.org/node/2011332. - $items[$path . '/edit'] = array( - 'title' => 'Edit', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -100, - ); - } - $items[$path . '/translate'] = array( - 'title' => 'Translate', - 'route_name' => $group->getRouteName(), - 'type' => $group->getMenuType(), - 'weight' => 100, - ); - $items[$path . '/translate/add/%language'] = array( - 'title' => 'Translate', - 'route_name' => $group->getRouteName() . '.add', - 'type' => MENU_CALLBACK, - ); - $items[$path . '/translate/edit/%language'] = array( - 'title' => 'Translate', - 'route_name' => $group->getRouteName() . '.edit', - 'type' => MENU_CALLBACK, - ); - $items[$path . '/translate/delete/%language'] = array( - 'title' => 'Delete', - 'route_name' => $group->getRouteName() . '.delete', - 'type' => MENU_CALLBACK, - ); - } - - return $items; -} - -/** - * Implements hook_permission(). - */ -function config_translation_permission() { - return array( - 'translate configuration' => array( - 'title' => t('Translate user edited configuration'), - 'description' => t('Translate any configuration not shipped with modules and themes.'), - ), - ); -} - -/** - * Implements hook_theme(). - */ -function config_translation_theme() { - return array( - 'config_translation_manage_form_element' => array( - 'render element' => 'element', - ), - ); -} - -/** - * Returns HTML for translation manage element. - * - * @param array $variables - * An associative array containing: - * - element: The element that contains the source and translation childs - * - * @see ConfigTranslationManageForm::buildConfigForm - * @ingroup themeable - */ -function theme_config_translation_manage_form_element($variables){ - $element = $variables['element']; - $result = ' -
-
- ' . drupal_render($element['source']) . ' -
-
- ' . drupal_render($element['translation']) . ' -
-
- '; - return $result; -} - -/** - * Returns TRUE if a configuration key has schema coverage. - * - * @param string $name - * Configuration key. - * - * @return bool - * A boolean indicating if a configuration key has schema coverage. - */ -function config_translation_has_schema($name) { - // The schema system falls back on the Property class for unknown types. - // See http://drupal.org/node/1905230 - $definition = config_typed()->getDefinition($name); - return is_array($definition) && $definition['class'] != '\Drupal\Core\Config\Schema\Property'; -} - -/** - * Returns TRUE if the configuration data has translatable items. - * - * @param string $name - * Configuration key. - * - * @return bool - * A boolean indicating if the configuration data has translatable items. - */ -function config_translation_has_translatable($name) { - return config_translation_find_translatable(config_typed()->get($name)); -} - -/** - * Returns TRUE if at least one translatable element is found. - * - * @todo Make this conditional on the translatable schema property from - * http://drupal.org/node/1905152 - currently hardcodes label and text. - * - * @param mixed $schema - * Configuration schema definition which is a - * \Drupal\Core\Config\Schema\Element or an array of Elements. - * - * @return bool - * A boolean indicating if there is at least one translatable element. - */ -function config_translation_find_translatable($schema) { - foreach ($schema as $element) { - if ($element instanceof Element && config_translation_find_translatable($element)) { - return TRUE; - } - elseif (in_array($element->getType(), array('label', 'text'))) { - return TRUE; - } - } - return FALSE; -} - -/** - * Retrieves original submission language code for configuration object. - * - * @param string $name - * Configuration key. - * - * @return string - * Language code string. - */ -function config_translation_original_langcode($name) { - $config = config($name)->get(); - return isset($config['langcode']) ? $config['langcode'] : 'en'; -} - -/** - * Checks whether a language has config translation. - * - * @param string $name - * Configuration name. - * @param \Drupal\Core\Language\Language $language - * A language object. - * - * @return bool - * A boolean indicating if a language has config translations. - */ -function config_translation_exists($name, Language $language) { - $config_translation = config('locale.config.' . $language->langcode . '.' . $name)->get(); - return !empty($config_translation); -} - -/** - * Gets group definitions from hooks and make it possible to alter groups. - * - * Configuration groups are used to get multiple configuration names used for - * one specific configuration form together. If contributed modules alter a - * form adding in additional settings stored elsewhere, the list of names - * can be expanded. - * - * @return array - * An array of configuration groups. - */ -function config_translation_get_groups() { - $config_groups = Drupal::ModuleHandler()->invokeAll('config_translation_group_info'); - - // Create an array of path indexed groups for easier altering. - $path_indexed_groups = array(); - foreach ($config_groups as $group) { - $path_indexed_groups[$group->getBasePath()] = $group; - } - Drupal::ModuleHandler()->alter('config_translation_group_info', $path_indexed_groups); - return $path_indexed_groups; -} - -/** - * Implements hook_config_translation_group_info(). - * - * Returns configuration name group mappings for core configuration files. - */ -function config_translation_config_translation_group_info() { - $items = array(); - - // Block. - $items[] = new ConfigEntityMapper('admin/structure/block/manage/{block}', 4, 'block', t('@label block'), 'block.block'); - - // Custom block. - $items[] = new ConfigEntityMapper('admin/structure/custom-blocks/manage/{custom_block_type}', 4, 'custom_block_type', t('@label custom block type'), 'custom_block.type'); - - // Contact. - $items[] = new ConfigEntityMapper('admin/structure/contact/manage/{contact_category}', 4, 'contact_category', t('@label contact category'), 'contact.category'); - - // Filter. - $items[] = new ConfigEntityMapper('admin/config/content/formats/{filter_format}', 4, 'filter_format', t('@label text format'), 'filter.format', MENU_LOCAL_TASK, TRUE); - - // Menu. - $items[] = new ConfigEntityMapper('admin/structure/menu/manage/{menu}', 4, 'menu', t('@label menu'), 'menu.menu'); - - // Shortcut. - $items[] = new ConfigEntityMapper('admin/config/user-interface/shortcut/manage/{shortcut_set}', 5, 'shortcut', t('@label shortcut set'), 'shortcut.set'); - - // System. - $items[] = new ConfigGroupMapper('admin/config/development/maintenance', t('System maintenance'), array('system.maintenance'), TRUE); - $items[] = new ConfigGroupMapper('admin/config/system/site-information', t('Site information'), array('system.site'), MENU_LOCAL_TASK, TRUE); - - // Taxonomy. - $items[] = new ConfigEntityMapper('admin/structure/taxonomy/manage/{taxonomy_vocabulary}', 4, 'taxonomy_vocabulary', t('@label vocabulary'), 'taxonomy.vocabulary'); - - // User. - $items[] = new ConfigGroupMapper('admin/config/people/accounts', t('Account settings'), array('user.settings', 'user.mail')); - $items[] = new ConfigEntityMapper('admin/people/roles/edit/{user_role}', 4, 'user_role', t('@label user role'), 'user.role', MENU_LOCAL_TASK, TRUE); - - // Views. - $items[] = new ConfigEntityMapper('admin/structure/views/view/{view}', 4, 'view', t('@label view'), 'views.view', MENU_CALLBACK); - - return $items; -} - -/** - * Implements hook_entity_operation_alter(). - */ -function config_translation_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) { - $uri = $entity->uri(); - $operations['translate'] = array( - 'title' => t('Translate badabumm'), - 'href' => $uri['path'] . '/translate', - 'options' => $uri['options'], - 'weight' => 50, - ); -} - -/** - * Alters form operations since there is no operations API. - * - * @todo Rework this in favor of an operations API. See - * http://drupal.org/node/2004428 - */ -function config_translation_form_alter(&$form, &$form_state, $form_id) { - if (!user_access('translate configuration')) { - // Do not alter forms with links to translations, if no access. - return; - } - - // Alter the filter admin overview to add translation links. - if ($form_id == 'filter_admin_overview') { - foreach ($form['formats'] as $id => &$format) { - if (is_array($format) && isset($format['operations'])) { - $format['operations']['#links']['translate'] = array( - 'title' => t('Translate'), - 'href' => 'admin/config/content/formats/' . $id . '/translate', - ); - } - } - } - - // Alter the user roles form to add translation links. - if ($form_id == 'user_admin_roles') { - foreach ($form['roles'] as $id => &$role) { - if (is_array($role) && isset($role['operations'])) { - $role['operations']['#links']['translate'] = array( - 'title' => t('Translate'), - 'href' => 'admin/people/roles/edit/' . $id . '/translate', - ); - } - } - } - - // Alter the blocks form to add translation links. - if ($form_id == 'block_admin_display_form') { - foreach ($form['blocks'] as $id => &$block) { - if (is_array($block) && isset($block['operations'])) { - $block['operations']['#links']['translate'] = array( - 'title' => t('Translate'), - 'href' => 'admin/structure/block/manage/' . $id . '/translate', - ); - } - } - } -} - -/** - * Alters page operations since there is no operations API. - * - * @todo Rework this in favor of an operations API. See - * http://drupal.org/node/2004428 - */ -function config_translation_page_alter(&$page) { - if (!user_access('translate configuration')) { - // Do not alter pages with links to translations, if no access. - return; - } - - if (isset($page['content'])) { - // Grab the first content item, which is the content block hopefully. - $content_keys = array_keys($page['content']); - $content = &$page['content'][reset($content_keys)]; - - // Fingerprint the views entity list page structure. - if (isset($content['content'][0]['#attributes']['id']) && - $content['content'][0]['#attributes']['id'] == 'views-entity-list') { - $tables = &$content['content'][0]; - foreach (array('enabled', 'disabled') as $status) { - foreach ($tables[$status]['table']['#rows'] as $id => &$row) { - $row['data']['operations']['data']['#links']['translate'] = array( - 'title' => t('Translate'), - 'href' => 'admin/structure/views/view/' . $id . '/translate', - ); - } - } - } - - if (isset($content['content'][0]['#rows'])) { - $row_keys = array_keys($content['content'][0]['#rows']); - $first_key = reset($row_keys); - $rows = &$content['content'][0]['#rows']; - - // Fingerprint the menu summary table structure. - if (isset($rows[$first_key]['title']['class']) && - in_array('menu-label', $rows[$first_key]['title']['class'])) { - foreach ($rows as $id => &$row) { - $row['operations']['data']['#links']['translate'] = array( - 'title' => t('Translate'), - 'href' => 'admin/structure/menu/manage/' . $id . '/translate', - ); - } - } - } - } -} diff --git a/core/modules/config_translation/core/modules/config_translation/config_translation.services.yml b/core/modules/config_translation/core/modules/config_translation/config_translation.services.yml deleted file mode 100644 index 68fc96a..0000000 --- a/core/modules/config_translation/core/modules/config_translation/config_translation.services.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - config_translation.subscriber: - class: Drupal\config_translation\Routing\RouteSubscriber - tags: - - { name: event_subscriber } - config_translation.access_check: - class: Drupal\config_translation\Access\ConfigNameCheck - tags: - - { name: access_check } diff --git a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigNameCheck.php b/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigNameCheck.php deleted file mode 100644 index 1af1390..0000000 --- a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Access/ConfigNameCheck.php +++ /dev/null @@ -1,54 +0,0 @@ -getRequirements()); - } - - /** - * {@inheritdoc} - */ - public function access(Route $route, Request $request) { - $mapper = $route->getDefault('mapper'); - $entity = $request->attributes->get($mapper->getType()); - // Get configuration group for this mapper. - $group = $mapper->getConfigGroup($entity); - $group_language = $group->getLanguageWithFallback(); - - $langcode = $request->attributes->get('langcode'); - $language = empty($langcode) ? NULL : language_load($langcode); - - // Only allow access to translate configuration, if proper permissions are - // granted, the configuration has translatable pieces, the source language - // and target language are not locked, and the target language is not the - // original submission language. Although technically config can be - // overlayed with translations in the same language, that is logically not - // a good idea. - return ( - user_access('translate configuration') && - $group->hasSchema() && - $group->hasTranslatable() && - !$group_language->locked && - (empty($language) || (!$language->locked && $language->langcode != $group_language->langcode)) - ); - } - -} diff --git a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigEntityMapper.php b/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigEntityMapper.php deleted file mode 100644 index f7dba2e..0000000 --- a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigEntityMapper.php +++ /dev/null @@ -1,188 +0,0 @@ -base_path = $base_path; - $this->path_id_index = $path_id_index; - $this->entity_type = $entity_type; - $this->title = $title; - $this->config_prefix = $config_prefix; - $this->menu_type = $menu_type; - $this->add_edit_tab = $add_edit_tab; - $this->setRouteName(); - } - - /** - * {@inheritdoc} - */ - public function hasEditTab() { - return $this->add_edit_tab; - } - - /** - * {@inheritdoc} - */ - public function getBasePath() { - return $this->base_path; - } - - /** - * {@inheritdoc} - */ - public function getMenuType() { - return $this->menu_type; - } - - /** - * {@inheritdoc} - */ - public function getPathIdIndex() { - return $this->path_id_index; - } - - /** - * {@inheritdoc} - */ - public function getConfigGroup($arg = NULL) { - // In this implementation, $arg is the config entity loaded via the menu - // (for contact module for example) or a string (config entity ID), in - // which case we need to load the entity (for views for example). - if (!isset($arg)) { - return NULL; - } - if (is_string($arg)) { - $entity = entity_load($this->entity_type, $arg); - } - else { - $entity = $arg; - } - - // Replace path segment with the ID of the entity for further processing. - $path = explode('/', $this->base_path); - $path[$this->path_id_index] = $entity->id(); - $base_path = join('/', $path); - - // Replace entity label in template title. - $title = format_string($this->title, array('@label' => $entity->label())); - - // The list of config IDs belonging to this entity. - $names = array($this->config_prefix . '.' . $entity->id()); - - return new ConfigGroupMapper($base_path, $title, $names, $this->menu_type, $this->add_edit_tab); - } - - /** - * {@inheritdoc} - */ - public function setRouteName() { - $search = array('/', '-', '{', '}'); - $replace = array('.', '_', '_', '_'); - $this->route_name = 'config_translation.item.' . str_replace($search, $replace, $this->base_path); - } - - /** - * {@inheritdoc} - */ - public function getRouteName() { - return $this->route_name; - } - - /** - * {@inheritdoc} - */ - public function getType() { - return $this->entity_type; - } - -} diff --git a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigGroupMapper.php b/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigGroupMapper.php deleted file mode 100644 index 8ab5f3f..0000000 --- a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigGroupMapper.php +++ /dev/null @@ -1,263 +0,0 @@ -base_path = $base_path; - $this->title = $title; - $this->names = $names; - $this->menu_type = $menu_type; - $this->add_edit_tab = $add_edit_tab; - $this->setRouteName(); - } - - /** - * {@inheritdoc} - */ - public function hasEditTab() { - return $this->add_edit_tab; - } - - /** - * {@inheritdoc} - */ - public function getBasePath() { - return $this->base_path; - } - - /** - * Returns title of this configuration group. - * - * @return string - * The group title. - */ - public function getTitle() { - return $this->title; - } - - /** - * Returns list of names in this configuration group. - * - * @return array - * An array of configuration names in this group. - */ - public function getNames() { - return $this->names; - } - - /** - * {@inheritdoc} - */ - public function getMenuType() { - return $this->menu_type; - } - - /** - * {@inheritdoc} - */ - public function getPathIdIndex() { - return NULL; - } - - /** - * {@inheritdoc} - */ - public function getConfigGroup($arg = NULL) { - // This is already a config group. - return $this; - } - - /** - * Returns the original language code of the configuration group. - * - * @todo Revisit. This assumes the langcode of the first element for now and - * might lead to inconsistency. - */ - public function getLangcode() { - return config_translation_original_langcode($this->names[0]); - } - - /** - * Returns language object for the configuration group. - * - * If the language of the group is not a configured language on the site and - * it is English, we return a dummy language object to represent the - * built-in language. - * - * @return \Drupal\Core\Language\Language - * A configured language object instance or a dummy English language object. - */ - public function getLanguageWithFallback() { - $langcode = $this->getLangcode(); - $language = language_load($langcode); - if (empty($language) && $langcode == 'en') { - $language = new Language(array('langcode' => 'en', 'name' => t('Built-in English'))); - } - return $language; - } - - /** - * Returns an array with configuration data for the group. - * - * @return array - * Configuration data keyed by configuration names in the group. - */ - public function getConfigData() { - $config_data = array(); - foreach ($this->names as $name) { - $config_data[$name] = config($name)->get(); - } - return $config_data; - } - - /** - * Checks that all pieces of this configuration group has schema. - * - * @return bool - * TRUE if all of the group elements have schema, FALSE otherwise. - */ - public function hasSchema() { - foreach ($this->names as $name) { - if (!config_translation_has_schema($name)) { - return FALSE; - } - } - return TRUE; - } - - /** - * Checks that all pieces of this configuration group have translatables. - * - * @return bool - * TRUE if all of the group elements have translatables, FALSE otherwise. - */ - public function hasTranslatable() { - foreach ($this->names as $name) { - if (!config_translation_has_translatable($name)) { - return FALSE; - } - } - return TRUE; - } - - /** - * Checks whether there is already a translation for this group. - * - * @param \Drupal\Core\Language\Language $language - * A language object. - * - * @return bool - * TRUE if any of the group elements have a translation in the given - * language, FALSE otherwise. - */ - public function hasTranslation(Language $language) { - foreach ($this->names as $name) { - if (config_translation_exists($name, $language)) { - return TRUE; - } - } - return FALSE; - } - - /** - * Adds the given configuration name to the list of names in the group. - * - * @param string $name - * Configuration name. - */ - public function addName($name) { - $this->names[] = $name; - } - - /** - * {@inheritdoc} - */ - public function setRouteName() { - $this->route_name = 'config_translation.item.' . str_replace(array('/', '-'), array('.', '_'), $this->base_path); - } - - /** - * {@inheritdoc} - */ - public function getRouteName() { - return $this->route_name; - } - - /** - * {@inheritdoc} - */ - public function getType() { - return NULL; - } - -} diff --git a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperInterface.php b/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperInterface.php deleted file mode 100644 index 4a0c4b1..0000000 --- a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperInterface.php +++ /dev/null @@ -1,76 +0,0 @@ -get('database')); - } - - /** - * Language translations overview page for a configuration name. - * - * @param Request $request - * Page request object. - * @param ConfigMapperInterface $mapper - * Configuration mapper. - * - * @return array - * Page render array. - */ - public function itemOverviewPage(Request $request, ConfigMapperInterface $mapper) { - $group = $this->getConfigGroup($request, $mapper); - drupal_set_title(t('Translations for %label', array('%label' => $group->getTitle())), PASS_THROUGH); - - // It is possible the original language this configuration was saved with is - // not on the system. For example, the configuration shipped in English but - // the site has no English configured. Represent the original language in the - // table even if it is not currently configured. - $languages = language_list(); - $original_langcode = $group->getLangcode(); - if (!isset($languages[$original_langcode])) { - $language_name = language_name($original_langcode); - if ($original_langcode == 'en') { - $language_name = t('Built-in English'); - } - // Create a dummy language object for this listing only. - $languages[$original_langcode] = new Language(array('langcode' => $original_langcode, 'name' => $language_name)); - } - - $path = $group->getBasePath(); - $header = array(t('Language'), t('Operations')); - $page = array(); - $page['languages'] = array( - '#type' => 'table', - '#header' => $header, - ); - foreach ($languages as $language) { - if ($language->langcode == $original_langcode) { - $page['languages'][$language->langcode]['language'] = array( - '#markup' => '' . t('@language (original)', array('@language' => $language->name)) . '' - ); - - // @todo: the user translating might as well not have access to - // edit the original configuration. They will get a 403 for this - // link when clicked. Do we know better? - $operations = array(); - $operations['edit'] = array( - 'title' => t('Edit'), - 'href' => $path, - ); - $page['languages'][$language->langcode]['operations'] = array( - '#type' => 'operations', - '#links' => $operations, - ); - } - else { - $page['languages'][$language->langcode]['language'] = array( - '#markup' => $language->name, - ); - $operations = array(); - - // Check if translation exist for this language. - if (!$group->hasTranslation($language)) { - $operations['add'] = array( - 'title' => t('Add'), - 'href' => $path . '/translate/add/' . $language->langcode, - ); - } - else { - $operations['edit'] = array( - 'title' => t('Edit'), - 'href' => $path . '/translate/edit/' . $language->langcode, - ); - $operations['delete'] = array( - 'title' => t('Delete'), - 'href' => $path . '/translate/delete/' . $language->langcode, - ); - } - $page['languages'][$language->langcode]['operations'] = array( - '#type' => 'operations', - '#links' => $operations, - ); - } - } - return $page; - } - - /** - * Renders translation item manage form. - * - * @param Request $request - * Page request object. - * @param string $action - * Action identifier, either 'add' or 'edit'. Used to provide proper - * labeling on the screen. - * @param ConfigMapperInterface $mapper - * Configuration mapper. - * - * @return array - */ - public function itemTranslatePage(Request $request, $action, ConfigMapperInterface $mapper) { - $group = $this->getConfigGroup($request, $mapper); - $language = $this->getLanguage($request, $mapper); - - $replacement = array( - '%label' => $group->getTitle(), - '@language' => strtolower($language->name), - ); - switch ($action) { - case 'add': - drupal_set_title(t('Add @language translation for %label', $replacement), PASS_THROUGH); - break; - case 'edit': - drupal_set_title(t('Edit @language translation for %label', $replacement), PASS_THROUGH); - break; - } - - // Make sure we are in the override free config context. For example, - // visiting the configuration page in another language would make those - // language overrides active by default. But we need the original values. - config_context_enter('config.context.free'); - - // Get base language configuration to display in the form before entering - // into the language context for the form. This avoids repetitively going - // in and out of the language context to get original values later. - $base_config = $group->getConfigData(); - - // Leave override free context. - config_context_leave(); - - // Enter context for the translation target language requested and generate - // form with translation data in that language. - config_context_enter('Drupal\language\LanguageConfigContext')->setLanguage($language); - $locale_storage = \Drupal::service('locale.storage'); - return drupal_get_form(new ConfigTranslationManageForm($locale_storage), $group, $language, $base_config); - } - - /** - * Item delete form. - * - * @param Request $request - * @param ConfigMapperInterface $mapper - * @return array|mixed - */ - public function itemDeletePage(Request $request, ConfigMapperInterface $mapper) { - return drupal_get_form(new ConfigTranslationDeleteForm(), $this->getConfigGroup($request, $mapper), $this->getLanguage($request, $mapper)); - } - - /** - * Helper to get config group. - * - * @param Request $request - * @param ConfigMapperInterface $mapper - * - * @return ConfigGroupMapper - */ - protected function getConfigGroup(Request $request, ConfigMapperInterface $mapper) { - // Get configuration group for this mapper. - $entity = $request->attributes->get($mapper->getType()); - return $mapper->getConfigGroup($entity); - } - - /** - * Helper to get language object. - * - * @param Request $request - * @param ConfigMapperInterface $mapper - * - * @return bool|\Drupal\core\Language\Language - * Returns Language object when langcode found in request; FALSE otherwise. - */ - protected function getLanguage(Request $request, ConfigMapperInterface $mapper) { - $langcode = $request->attributes->get('langcode'); - if ($langcode) { - return language_load($langcode); - } - return FALSE; - } - -} diff --git a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php deleted file mode 100644 index 29cf0f5..0000000 --- a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationDeleteForm.php +++ /dev/null @@ -1,91 +0,0 @@ - $this->group->getTitle(), '@language' => $this->language->name)); - - } - - /** - * {@inheritdoc} - */ - protected function getConfirmText() { - return t('Delete'); - } - - - /** - * {@inheritdoc} - */ - protected function getCancelPath() { - return $this->group->getBasePath() . '/translate'; - } - - /** - * {@inheritdoc} - */ - public function getFormID() { - return 'config_translation_delete_form'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state, ConfigMapperInterface $group = NULL, $language = NULL) { - $this->group = $group; - $this->language = $language; - return parent::buildForm($form, $form_state); - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - - $form_values = $form_state['values']; - - $storage = drupal_container()->get('config.storage'); - foreach ($this->group->getNames() as $name) { - $storage->delete('locale.config.' . $this->language->langcode . '.' . $name); - } - // @todo: do we need to flush caches? The config change may affect page display. - // drupal_flush_all_caches(); - - drupal_set_message(t('@language translation of %label was deleted', array('%label' => $this->group->getTitle(), '@language' => $this->language->name))); - $form_state['redirect'] = $this->group->getBasePath() . '/translate'; - } - -} diff --git a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php b/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php deleted file mode 100644 index e79ec9f..0000000 --- a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php +++ /dev/null @@ -1,299 +0,0 @@ -localeStorage = $locale_storage; - } - - /** - * {@inheritdoc}. - */ - public function getFormID() { - return 'config_translation_form'; - } - - /** - * Build configuration form with metadata and values. - */ - public function buildForm(array $form, array &$form_state, ConfigMapperInterface $group = NULL, Language $language = NULL, array $base_config = NULL) { - $this->group = $group; - $this->language = $language; - $this->source_language = $this->group->getConfigGroup()->getLanguageWithFallback(); - $this->base_config = $base_config; - - foreach ($this->group->getNames() as $id => $name) { - $form[$id] = array( - '#type' => 'container', - '#tree' => TRUE, - ); - $form[$id] += $this->buildConfigForm(config_typed()->get($name), config($name)->get(), $this->base_config[$name]); - } - - $form['#attached']['css'] = array(drupal_get_path('module', 'config_translation') . '/config_translation.admin.css'); - $form['actions']['#type'] = 'actions'; - $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save translation')); - return $form; - } - - /** - * @inheritdoc - */ - public function validateForm(array &$form, array &$form_state) { - - } - - /** - * @inheritdoc - */ - public function submitForm(array &$form, array &$form_state) { - $form_values = $form_state['values']; - - // For the form submission handling, use the override free context. - config_context_enter('config.context.free'); - - foreach ($this->group->getNames() as $id => $name) { - // Set config values based on form submission and original values. - $base_config = config($name); - $translation_config = config('locale.config.' . $this->language->langcode . '.' . $name); - $locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $name)); - - $this->setConfig($this->language, $base_config, $translation_config, $form_values[$id], !empty($locations)); - - // If no overrides, delete language specific config file. - $saved_config = $translation_config->get(); - if (empty($saved_config)) { - $translation_config->delete(); - } - else { - $translation_config->save(); - } - } - - config_context_leave(); - - drupal_set_message(t('Updated @language configuration translations successfully.', array('@language' => $this->language->name))); - $form_state['redirect'] = $this->group->getBasePath() . '/translate'; - } - - /** - * Formats configuration schema as a form tree. - * - * @param $schema - * Schema definition of configuration. - * @param $config - * Configuration object of requested language. - * @param $base_config - * Configuration object of base language. - * @param bool $collapsed - * Flag to set collapsed state. - * @param string|NULL $base_key - * Base configuration key. - * - * @return array - * An associative array containing the structure of the form. - * - * @todo - * Make this conditional on the translatable schema property from - * http://drupal.org/node/1905152 - currently hardcodes label and text. - */ - protected function buildConfigForm($schema, $config, $base_config, $collapsed = FALSE, $base_key = '') { - $build = array(); - foreach ($schema as $key => $element) { - $element_key = implode('.', array_filter(array($base_key, $key))); - $definition = $element->getDefinition() + array('label' => t('N/A')); - if ($element instanceof Element) { - // Build sub-structure and include it with a wrapper in the form - // if there are any translatable elements there. - $sub_build = $this->buildConfigForm($element, $config[$key], $base_config[$key], TRUE, $element_key); - if (!empty($sub_build)) { - // For some configuration elements the same element structure can - // repeat multiple times, (like views displays, filters, etc.). - // So try to find a more usable title for the details summary. First - // check if there is an element which is called title or label, then - // check if there is an element which contains these words. - $title = ''; - if (isset($sub_build['title']['source'])) { - $title = $sub_build['title']['source']['#markup']; - } - elseif (isset($sub_build['label']['source'])) { - $title = $sub_build['label']['source']['#markup']; - } - else { - foreach (array_keys($sub_build) as $title_key) { - if (isset($sub_build[$title_key]['source']) && (strpos($title_key, 'title') !== FALSE || strpos($title_key, 'label') !== FALSE)) { - $title = $sub_build[$title_key]['source']['#markup']; - break; - } - } - } - $build[$key] = array( - '#type' => 'details', - '#title' => (!empty($title) ? (strip_tags($title) . ' ') : '') . t($definition['label']), - '#collapsible' => TRUE, - '#collapsed' => $collapsed, - ) + $sub_build; - } - } - else { - $type = $element->getType(); - switch ($type) { - case 'label': - $type = 'textfield'; - break; - case 'text': - $type = 'textarea'; - break; - default: - continue(2); - break; - } - $value = $config[$key]; - $build[$element_key] = array( - '#theme' => 'config_translation_manage_form_element', - ); - $build[$element_key]['source'] = array( - '#markup' => $base_config[$key] ? ('' . nl2br($base_config[$key] . '')) : t('(Empty)'), - '#title' => t($definition['label']) . ' ('. $this->source_language->name . ')', - '#type' => 'item', - ); - $rows_words = ceil(str_word_count($value) / 5); - $rows_newlines = substr_count($value, "\n" ) + 1; - $rows = max($rows_words, $rows_newlines); - $build[$element_key]['translation'] = array( - '#type' => $type, - '#default_value' => $value, - '#title' => t($definition['label']) . ' (' . $this->language->name . ')', - '#rows' => $rows, - '#attributes' => array('lang' => $this->language->langcode), - ); - } - } - return $build; - } - - /** - * Sets configuration based on a nested form value array. - * - * @param Language $language - * Language object. - * @param \Drupal\Core\Config\Config $base_config - * Base language configuration values instance. - * @param \Drupal\Core\Config\Config $translation_config - * Translation configuration instance. Values from $config_values will be set - * in this instance. - * @param array $config_values - * A simple one dimensional or recursive array: - * - simple: - * array(name => array('translation' => 'French site name')) - * - recursive: - * cancel_confirm => array( - * cancel_confirm.subject => array('translation' => 'Subject') - * cancel_confirm.body => array('translation' => 'Body content') - * ); - * Either format is used, the nested arrays are just containers and not - * needed for saving the data. - * @param bool $shipped_config - * Flag to specify whether the configuration had a shipped version and - * therefore should also be stored in the locale database. - */ - protected function setConfig(Language $language, Config $base_config, Config $translation_config, array $config_values, $shipped_config = FALSE) { - //dpm($config_values); - foreach ($config_values as $key => $value) { - if (is_array($value) && !isset($value['translation'])) { - // Traverse into this level in the configuration. - $this->setConfig($language, $base_config, $translation_config, $value, $shipped_config); - } - else { - - // If the config file being translated was originally shipped, we should - // update the locale translation storage. The string should already be - // there, but we make sure to check. - if ($shipped_config && $source_string = $this->localeStorage->findString(array('source' => $base_config->get($key)))) { - - // Get the translation for this original source string from locale. - $conditions = array( - 'lid' => $source_string->lid, - 'language' => $language->langcode, - ); - $translations = $this->localeStorage->getTranslations($conditions + array('translated' => TRUE)); - // If we got a translation, take that, otherwise create a new one. - $translation = reset($translations) ?: $this->localeStorage->createTranslation($conditions); - - // If we have a new translation or different from what is stored in - // locale before, save this as an updated customize translation. - if ($translation->isNew() || $translation->getString() != $value['translation']) { - $translation->setString($value['translation']) - ->setCustomized() - ->save(); - } - } - - // Save value, if different from original configuration. If same as - // original configuration, remove override. - if ($base_config->get($key) !== $value['translation']) { - $translation_config->set($key, $value['translation']); - } - else { - $translation_config->clear($key); - } - } - } - } -} diff --git a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Routing/RouteSubscriber.php b/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Routing/RouteSubscriber.php deleted file mode 100644 index 3c1a63b..0000000 --- a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Routing/RouteSubscriber.php +++ /dev/null @@ -1,83 +0,0 @@ -getRouteCollection(); - $config_groups = config_translation_get_groups(); - foreach ($config_groups as $group) { - $path = $group->getBasePath(); - - $route = new Route($path . '/translate', array( - '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemOverviewPage', - 'mapper' => $group, - ),array( - '_config_translation_config_name_access' => 'TRUE', - )); - $collection->add($group->getRouteName(), $route); - - $route = new Route($path . '/translate/add/{langcode}', array( - '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemTranslatePage', - 'action' => 'add', - 'mapper' => $group, - ),array( - '_config_translation_config_name_access' => 'TRUE', - )); - $collection->add($group->getRouteName() . '.add', $route); - - $route = new Route($path . '/translate/edit/{langcode}', array( - '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemTranslatePage', - 'action' => 'edit', - 'mapper' => $group, - ),array( - '_config_translation_config_name_access' => 'TRUE', - )); - $collection->add($group->getRouteName() . '.edit', $route); - - $route = new Route($path . '/translate/delete/{langcode}', array( - '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemDeletePage', - 'mapper' => $group, - ),array( - '_config_translation_config_name_access' => 'TRUE', - )); - $collection->add($group->getRouteName() . '.delete', $route); - } - } - -} diff --git a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUITest.php b/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUITest.php deleted file mode 100644 index e6525f7..0000000 --- a/core/modules/config_translation/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationUITest.php +++ /dev/null @@ -1,466 +0,0 @@ - 'Configuration Translation', - 'description' => 'Translate settings and entities to various languages', - 'group' => 'Configuration Translation', - ); - } - - function setUp() { - parent::setUp(); - $permissions = array( - 'translate configuration', - 'administer languages', - 'administer site configuration', - 'administer contact forms', - 'access site-wide contact form' - ); - // Create and login user. - $admin_user = $this->drupalCreateUser($permissions); - $this->drupalLogin($admin_user); - - // Add languages. - foreach ($this->langcodes as $langcode) { - $language = new Language(array('langcode' => $langcode)); - language_save($language); - } - $this->localeStorage = $this->container->get('locale.storage'); - } - - /** - * Test case for site information translation interface. - */ - function testSiteInformationTranslationUI() { - $site_name = 'Site name for testing configuration translation'; - $site_slogan = 'Site slogan for testing configuration translation'; - $fr_site_name = 'Nom du site pour tester la configuration traduction'; - $fr_site_slogan = 'Slogan du site pour tester la traduction de configuration'; - $translation_base_url = 'admin/config/system/site-information/translate'; - - // Set site name and slogan for default language. - $this->setSiteInformation($site_name, $site_slogan); - - $this->drupalGet('admin/config/system/site-information'); - // Check translation tab exist. - $this->assertLinkByHref($translation_base_url); - - $this->drupalGet($translation_base_url); - - // Check 'Add' link of French to visit add page. - $this->assertLinkByHref($translation_base_url . '/add/fr'); - $this->clickLink(t('Add')); - - // Make sure original text is present on this page. - $this->assertRaw($site_name); - $this->assertRaw($site_slogan); - - // Update site name and slogan for French. - $edit = array( - '0[name][translation]' => $fr_site_name, - '0[slogan][translation]' => $fr_site_slogan, - ); - $this->drupalPost($translation_base_url . '/add/fr', $edit, t('Save translation')); - $this->assertRaw(t('Updated French configuration translations successfully.')); - - // Check for edit, delete links (and no 'add' link) for French language. - $this->assertNoLinkByHref($translation_base_url . '/add/fr'); - $this->assertLinkByHref($translation_base_url . '/edit/fr'); - $this->assertLinkByHref($translation_base_url . '/delete/fr'); - - // Check translation saved proper. - $this->drupalGet($translation_base_url . '/edit/fr'); - $this->assertFieldByName('0[name][translation]', $fr_site_name); - $this->assertFieldByName('0[slogan][translation]', $fr_site_slogan); - - // Check French translation of site name and slogan are in place. - $this->drupalGet('fr'); - $this->assertRaw($fr_site_name); - $this->assertRaw($fr_site_slogan); - - // Visit French site to ensure base language string present as source. - $this->drupalGet('fr/' . $translation_base_url . '/edit/fr'); - $this->assertText($site_name); - $this->assertText($site_slogan); - } - - /** - * Test case for site information translation interface. - */ - function testSourceValueDuplicateSave() { - $site_name = 'Site name for testing configuration translation'; - $site_slogan = 'Site slogan for testing configuration translation'; - $translation_base_url = 'admin/config/system/site-information/translate'; - $this->setSiteInformation($site_name, $site_slogan); - - $this->drupalGet($translation_base_url); - - // Case 1: Update new value for site slogan and site name. - $edit = array( - '0[name][translation]' => 'FR ' . $site_name, - '0[slogan][translation]' => 'FR ' . $site_slogan, - ); - // First time, no overrides, so just Add link. - $this->drupalPost($translation_base_url . '/add/fr', $edit, t('Save translation')); - - // Read overridden file from active config. - $file_storage = new FileStorage($this->configDirectories[CONFIG_ACTIVE_DIRECTORY]); - $config_parsed = $file_storage->read('locale.config.fr.system.site'); - - // Expect both name and slogan in language specific file. - $expected = array( - 'name' => 'FR ' . $site_name, - 'slogan' => 'FR ' . $site_slogan - ); - $this->assertEqual($expected, $config_parsed); - - // Case 2: Update new value for site slogan and default value for site name. - $edit = array( - '0[name][translation]' => $site_name, - '0[slogan][translation]' => 'FR ' . $site_slogan, - ); - $this->drupalPost($translation_base_url . '/edit/fr', $edit, t('Save translation')); - $config_parsed = $file_storage->read('locale.config.fr.system.site'); - - // Expect only slogan in language specific file. - $expected = array( - 'slogan' => 'FR ' . $site_slogan - ); - $this->assertEqual($expected, $config_parsed); - - // Case 3: Keep default value for site name and slogan. - $edit = array( - '0[name][translation]' => $site_name, - '0[slogan][translation]' => $site_slogan, - ); - $this->drupalPost($translation_base_url . '/edit/fr', $edit, t('Save translation')); - $config_parsed = $file_storage->read('locale.config.fr.system.site'); - - // Expect no language specific file. - $this->assertFalse($config_parsed); - } - - /** - * Test case for contact category translation. - */ - function testContactConfigEntityTranslation() { - $this->drupalGet('admin/structure/contact'); - - // Check for default contact form config entity from Contact module. - $this->assertLinkByHref('admin/structure/contact/manage/feedback'); - - // Save default language configuration. - $edit = array( - 'label' => 'Send your feedback', - 'recipients' => 'sales@example.com,support@example.com', - 'reply' => 'Thank you for your mail' - ); - $this->drupalPost('admin/structure/contact/manage/feedback', $edit, t('Save')); - - // Visit the form to confirm the changes. - $this->drupalGet('contact/feedback'); - $this->assertText('Send your feedback'); - - foreach ($this->langcodes as $langcode) { - // Update translatable fields. - $edit = array( - '0[label][translation]' => 'Website feedback - ' . $langcode, - '0[reply][translation]' => 'Thank you for your mail - ' . $langcode - ); - - // Save language specific version of form. - $this->drupalPost('admin/structure/contact/manage/feedback/translate/add/' . $langcode, $edit, t('Save translation')); - - // Visit language specific version of form to check label exists. - $this->drupalGet($langcode . '/contact/feedback'); - $this->assertText('Website feedback - ' . $langcode); - - // Submit feedback. - $edit = array( - 'subject' => 'Test subject', - 'message' => 'Test message' - ); - $this->drupalPost(NULL, $edit, t('Send message')); - } - - // We get all emails so no need to check inside the loop. - $captured_emails = $this->drupalGetMails(); - - // Check language specific auto reply text in email body. - foreach ($captured_emails as $email) { - if ($email['id'] == 'contact_page_autoreply') { - // Trim because we get an added newline for the body. - $this->assertEqual(trim($email['body']), 'Thank you for your mail - ' . $email['langcode']); - } - } - - } - - /** - * Test case for account settings translation interface. - * - * This is the only special case so far where we have multiple config names - * involved building up one configuration translation form. Test that the - * translations are saved for all configuration names properly. - */ - function testAccountSettingsConfigurationTranslation() { - $this->drupalGet('admin/config/people/accounts/translate'); - $this->assertLinkByHref('admin/config/people/accounts/translate/add/fr'); - - // Update account settings fields for French. - $edit = array( - '0[anonymous][translation]' => 'Anonyme', - '1[status_blocked][status_blocked.subject][translation]' => 'Testing, your account is blocked.', - '1[status_blocked][status_blocked.body][translation]' => 'Testing account blocked body.' - ); - - $this->drupalPost('admin/config/people/accounts/translate/add/fr', $edit, t('Save translation')); - - // Make sure the changes are saved and loaded back properly. - $this->drupalGet('admin/config/people/accounts/translate/edit/fr'); - foreach ($edit as $value) { - $this->assertRaw($value); - } - } - - /** - * Test source and target language edge cases. - */ - function testSourceAndTargetLanguage() { - // Loading translation page for not-specified language (und) - // should return 403. - $this->drupalGet('admin/config/system/site-information/translate/add/und'); - $this->assertResponse(403); - - // Check the source language doesn't have 'Add' or 'Delete' link and - // make sure source language edit goes to original configuration page - // not the translation specific edit page. - $this->drupalGet('admin/config/system/site-information/translate'); - $this->assertNoLinkByHref('admin/config/system/site-information/translate/edit/en'); - $this->assertNoLinkByHref('admin/config/system/site-information/translate/add/en'); - $this->assertNoLinkByHref('admin/config/system/site-information/translate/delete/en'); - $this->assertLinkByHref('admin/config/system/site-information'); - - // Translation addition to source language should return 403. - $this->drupalGet('admin/config/system/site-information/translate/add/en'); - $this->assertResponse(403); - - // Translation editing in source language should return 403. - $this->drupalGet('admin/config/system/site-information/translate/edit/en'); - $this->assertResponse(403); - - // Translation deletion in source language should return 403. - $this->drupalGet('admin/config/system/site-information/translate/delete/en'); - $this->assertResponse(403); - - // Set default language of site information to not-specified language (und). - config('system.site') - ->set('langcode', Language::LANGCODE_NOT_SPECIFIED) - ->save(); - - // Make sure translation tab does not exist on the config page. - $this->drupalGet('admin/config/system/site-information'); - $this->assertNoLinkByHref('admin/config/system/site-information/translate'); - - // If source language is not specified, translation page should be 403. - $this->drupalGet('admin/config/system/site-information/translate'); - $this->assertResponse(403); - } - - /** - * Test case for views translation interface. - */ - function testViewsTranslationUI() { - $description = 'A list of nodes marked for display on the front page.'; - $human_readable_name = 'Frontpage'; - $display_settings_master = 'Master'; - $display_options_master = '(Empty)'; - $translation_base_url = 'admin/structure/views/view/frontpage/translate'; - - $this->drupalGet($translation_base_url); - - // Check 'Add' link of French to visit add page. - $this->assertLinkByHref($translation_base_url . '/add/fr'); - $this->clickLink(t('Add')); - - // Make sure original text is present on this page. - $this->assertRaw($description); - $this->assertRaw($human_readable_name); - - // Update Views Fields for French. - $edit = array( - '0[description][translation]' => $description . " FR", - '0[label][translation]' => $human_readable_name . " FR", - '0[display][default][display.default.display_title][translation]' => $display_settings_master . " FR", - '0[display][default][display_options][display.default.display_options.title][translation]' => $display_options_master . " FR", - ); - $this->drupalPost($translation_base_url . '/add/fr', $edit, t('Save translation')); - $this->assertRaw(t('Updated French configuration translations successfully.')); - - // Check for edit, delete links (and no 'add' link) for French language. - $this->assertNoLinkByHref($translation_base_url . '/add/fr'); - $this->assertLinkByHref($translation_base_url . '/edit/fr'); - $this->assertLinkByHref($translation_base_url . '/delete/fr'); - - // Check translation saved proper. - $this->drupalGet($translation_base_url . '/edit/fr'); - $this->assertFieldByName('0[description][translation]', $description . " FR"); - $this->assertFieldByName('0[label][translation]', $human_readable_name . " FR"); - $this->assertFieldByName('0[display][default][display.default.display_title][translation]', $display_settings_master . " FR"); - $this->assertFieldByName('0[display][default][display_options][display.default.display_options.title][translation]', $display_options_master . " FR"); - } - - /** - * Test translation storage in locale storage. - */ - function testLocaleDBStorage() { - $langcode = 'xx'; - $name = $this->randomName(16); - $edit = array( - 'predefined_langcode' => 'custom', - 'langcode' => $langcode, - 'name' => $name, - 'direction' => '0', - ); - $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); - - // Make sure there is no translation stored in locale storage before edit. - $translation = $this->getTranslation('user.settings', 'anonymous', 'fr'); - $this->assertTrue(empty($translation)); - - // Add custom translation. - $edit = array( - '0[anonymous][translation]' => 'Anonyme', - ); - $this->drupalPost('admin/config/people/accounts/translate/add/fr', $edit, t('Save translation')); - - // Make sure translation stored in locale storage after saved language - // specific configuration translation. - $translation = $this->getTranslation('user.settings', 'anonymous', 'fr'); - $this->assertEqual('Anonyme', $translation->getString()); - - // revert custom translations to base translation. - $edit = array( - '0[anonymous][translation]' => 'Anonymous', - ); - $this->drupalPost('admin/config/people/accounts/translate/edit/fr', $edit, t('Save translation')); - - // Make sure there is no translation stored in locale storage after revert. - $translation = $this->getTranslation('user.settings', 'anonymous', 'fr'); - $this->assertEqual('Anonymous', $translation->getString()); - } - - /** - * Test case for single language existing. - */ - function testSingleLanguageUI() { - // Delete French language - $this->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete')); - $this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'French', '%langcode' => 'fr'))); - - // Change default language to Tamil. - $edit = array( - 'site_default_language' => 'ta', - ); - $this->drupalPost('admin/config/regional/settings', $edit, t('Save configuration')); - $this->assertRaw(t('The configuration options have been saved.')); - - // Delete English language - $this->drupalPost('admin/config/regional/language/delete/en', array(), t('Delete')); - $this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'English', '%langcode' => 'en'))); - - // Visit account setting translation page, this should not - // throw any notices. - $this->drupalGet('admin/config/people/accounts/translate'); - $this->assertResponse(200); - } - - /** - * Gets translation from locale storage. - * - * @param $config_name - * Configuration object. - * @param $key - * Translation config field key. - * @param $langcode - * String language code to load translation. - * - * @return bool|mixed - * Returns translation if exists, FALSE otherwise. - */ - protected function getTranslation($config_name, $key, $langcode) { - $settings_locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $config_name)); - $this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', array('%config_name' => $config_name))); - - if (!empty($settings_locations)) { - $source = $this->container->get('config.factory')->get($config_name)->get($key); - $source_string = $this->localeStorage->findString(array('source' => $source, 'type' => 'configuration')); - $this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', array('%config_name' => $config_name, '%key' => $key))); - - if (!empty($source_string)) { - $conditions = array( - 'lid' => $source_string->lid, - 'language' => $langcode, - ); - $translations = $this->localeStorage->getTranslations($conditions + array('translated' => TRUE)); - return reset($translations); - } - } - return FALSE; - } - - /** - * Helper to set site name and slogan for default language. - * - * @param string $site_name - * @param string $site_slogan - */ - protected function setSiteInformation($site_name, $site_slogan) { - $edit = array( - 'site_name' => $site_name, - 'site_slogan' => $site_slogan - ); - $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration')); - $this->assertRaw(t('The configuration options have been saved.')); - - } -} diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php index f11aa3c..659ff39 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationListUITest.php @@ -188,11 +188,11 @@ function doCustomBlockTypeListTest() { )); $custom_block_type->save(); - // Get the custom block listing. - $this->drupalGet('admin/structure/custom-blocks'); + // Get the custom block type listing. + $this->drupalGet('admin/structure/custom-blocks/types'); $translate_link = 'admin/structure/custom-blocks/manage/' . $custom_block_type->id() . '/translate'; - // Test if the link to translate the custom block is on the page. + // Test if the link to translate the custom block type is on the page. $this->assertLinkByHref($translate_link); // Test if the link to translate actually goes to the translate page. diff --git a/core/modules/config_translation/templates/config_translation_manage_form_element.html.twig b/core/modules/config_translation/templates/config_translation_manage_form_element.html.twig new file mode 100644 index 0000000..6bbee3d --- /dev/null +++ b/core/modules/config_translation/templates/config_translation_manage_form_element.html.twig @@ -0,0 +1,24 @@ +{# +/** +* @file +* Default theme implementation for a form element in config_translation. +* +* Available variables: +* - element: Array that represents the element shown in the form. +* - source: The source of the translation. +* - translation: The translation for the target language. +* +* @see template_preprocess() +* @see template_preprocess_config_translation_manage_form_element() +* +* @ingroup themeable +*/ +#} +
+
+ {{ element.source }} +
+
+ {{ element.translation }} +
+