summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGábor Hojtsy2018-11-02 11:58:11 (GMT)
committerGábor Hojtsy2018-11-02 11:58:37 (GMT)
commitafd686b4fa4809bddc1143bd58fad3d89abba9c4 (patch)
tree39de69bf4cb64ad85a9d27b3587904aeef8d88c4
parentf7978e86d13b0c6d6b1766ec4f1762fb2ce0e0c9 (diff)
Issue #2970849 by quietone, phenaproxima: i18n Variable to config: user settings and user.mail
(cherry picked from commit 29155fdb8196ccdd4097806177525053e12515ca)
-rw-r--r--core/modules/config_translation/migrations/d7_user_mail_translation.yml79
-rw-r--r--core/modules/config_translation/migrations/d7_user_settings_translation.yml17
-rw-r--r--core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateUserConfigsTranslationTest.php74
-rw-r--r--core/modules/migrate_drupal/tests/fixtures/drupal7.php133
4 files changed, 303 insertions, 0 deletions
diff --git a/core/modules/config_translation/migrations/d7_user_mail_translation.yml b/core/modules/config_translation/migrations/d7_user_mail_translation.yml
new file mode 100644
index 0000000..73b6b1d
--- /dev/null
+++ b/core/modules/config_translation/migrations/d7_user_mail_translation.yml
@@ -0,0 +1,79 @@
+id: d7_user_mail_translation
+label: User mail configuration translation
+migration_tags:
+ - Drupal 7
+ - Configuration
+ - Multilingual
+source:
+ plugin: d7_variable_translation
+ variables:
+ - user_mail_cancel_confirm_subject
+ - user_mail_cancel_confirm_body
+ - user_mail_password_reset_subject
+ - user_mail_password_reset_body
+ - user_mail_register_admin_created_subject
+ - user_mail_register_admin_created_body
+ - user_mail_register_no_approval_required_subject
+ - user_mail_register_no_approval_required_body
+ - user_mail_register_pending_approval_subject
+ - user_mail_register_pending_approval_body
+ - user_mail_status_activated_subject
+ - user_mail_status_activated_body
+ - user_mail_status_blocked_subject
+ - user_mail_status_blocked_body
+ - user_mail_status_canceled_subject
+ - user_mail_status_canceled_body
+process:
+ langcode: language
+ 'cancel_confirm/subject':
+ plugin: convert_tokens
+ source: user_mail_cancel_confirm_subject
+ 'cancel_confirm/body':
+ plugin: convert_tokens
+ source: user_mail_cancel_confirm_body
+ 'password_reset/subject':
+ plugin: convert_tokens
+ source: user_mail_password_reset_subject
+ 'password_reset/body':
+ plugin: convert_tokens
+ source: user_mail_password_reset_body
+ 'register_admin_created/subject':
+ plugin: convert_tokens
+ source: user_mail_register_admin_created_subject
+ 'register_admin_created/body':
+ plugin: convert_tokens
+ source: user_mail_register_admin_created_body
+ 'register_no_approval_required/subject':
+ plugin: convert_tokens
+ source: user_mail_register_no_approval_required_subject
+ 'register_no_approval_required/body':
+ plugin: convert_tokens
+ source: user_mail_register_no_approval_required_body
+ 'register_pending_approval/subject':
+ plugin: convert_tokens
+ source: user_mail_register_pending_approval_subject
+ 'register_pending_approval/body':
+ plugin: convert_tokens
+ source: user_mail_register_pending_approval_body
+ 'status_activated/subject':
+ plugin: convert_tokens
+ source: user_mail_status_activated_subject
+ 'status_activated/body':
+ plugin: convert_tokens
+ source: user_mail_status_activated_body
+ 'status_blocked/subject':
+ plugin: convert_tokens
+ source: user_mail_status_blocked_subject
+ 'status_blocked/body':
+ plugin: convert_tokens
+ source: user_mail_status_blocked_body
+ 'status_canceled/subject':
+ plugin: convert_tokens
+ source: user_mail_status_canceled_subject
+ 'status_canceled/body':
+ plugin: convert_tokens
+ source: user_mail_status_canceled_body
+destination:
+ plugin: config
+ config_name: user.mail
+ translations: true
diff --git a/core/modules/config_translation/migrations/d7_user_settings_translation.yml b/core/modules/config_translation/migrations/d7_user_settings_translation.yml
new file mode 100644
index 0000000..56c3880
--- /dev/null
+++ b/core/modules/config_translation/migrations/d7_user_settings_translation.yml
@@ -0,0 +1,17 @@
+id: d7_user_settings_translation
+label: User settings configuration translation
+migration_tags:
+ - Drupal 7
+ - Configuration
+ - Multilingual
+source:
+ plugin: d7_variable_translation
+ variables:
+ - anonymous
+process:
+ langcode: language
+ anonymous: anonymous
+destination:
+ plugin: config
+ config_name: user.settings
+ translations: true
diff --git a/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateUserConfigsTranslationTest.php b/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateUserConfigsTranslationTest.php
new file mode 100644
index 0000000..85d6867
--- /dev/null
+++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d7/MigrateUserConfigsTranslationTest.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Drupal\Tests\config_translation\Kernel\Migrate\d7;
+
+use Drupal\Tests\SchemaCheckTestTrait;
+use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
+
+/**
+ * Test migration of i18n user variables.
+ *
+ * @group migrate_drupal_7
+ */
+class MigrateUserConfigsTranslationTest extends MigrateDrupal7TestBase {
+
+ use SchemaCheckTestTrait;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'language',
+ 'locale',
+ 'config_translation',
+ // Required for translation migrations.
+ 'migrate_drupal_multilingual',
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $this->installSchema('locale', [
+ 'locales_source',
+ 'locales_target',
+ 'locales_location',
+ ]);
+ $this->executeMigrations([
+ 'd7_user_mail_translation',
+ 'd7_user_settings_translation',
+ ]);
+ }
+
+ /**
+ * Tests migration of i18n user variables to user.mail and user.settings.
+ */
+ public function testUserConfig() {
+ // Tests migration of i18n user variables to user.mail.yml.
+ $language_manager = \Drupal::service('language_manager');
+ $config = $language_manager->getLanguageConfigOverride('is', 'user.mail');
+ $this->assertSame('is - Are you sure?', $config->get('cancel_confirm.subject'));
+ $this->assertSame('is - A little birdie said you wanted to cancel your account.', $config->get('cancel_confirm.body'));
+ $this->assertSame('is - Fix your password', $config->get('password_reset.subject'));
+ $this->assertSame("is - Nope! You're locked out forever.", $config->get('password_reset.body'));
+ $this->assertSame('is - Gawd made you an account', $config->get('register_admin_created.subject'));
+ $this->assertSame("is - ...and she could take it away.\r\n[site:name], [site:url]", $config->get('register_admin_created.body'));
+ $this->assertSame('is - Welcome!', $config->get('register_no_approval_required.subject'));
+ $this->assertSame('is - You can now log in if you can figure out how to use Drupal!', $config->get('register_no_approval_required.body'));
+ $this->assertSame('is - Soon...', $config->get('register_pending_approval.subject'));
+ $this->assertSame('is - ...you will join our Circle. Let the Drupal flow through you.', $config->get('register_pending_approval.body'));
+ $this->assertSame('is - Your account is approved!', $config->get('status_activated.subject'));
+ $this->assertSame('is - Your account was activated, and there was much rejoicing.', $config->get('status_activated.body'));
+ $this->assertSame('is - BEGONE!', $config->get('status_blocked.subject'));
+ $this->assertSame('is - You no longer please the robot overlords. Go to your room and chill out.', $config->get('status_blocked.body'));
+ $this->assertSame('is - So long, bub', $config->get('status_canceled.subject'));
+ $this->assertSame('is - The gates of Drupal are closed to you. Now you will work in the salt mines.', $config->get('status_canceled.body'));
+ $this->assertConfigSchema(\Drupal::service('config.typed'), 'user.mail', $config->get());
+
+ // Tests migration of i18n user variables to user.settings.yml.
+ $config = $language_manager->getLanguageConfigOverride('is', 'user.settings');
+ $this->assertSame('is - anonymous', $config->get('anonymous'));
+ }
+
+}
diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
index 25f9538..3f5242e 100644
--- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php
+++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php
@@ -51539,6 +51539,139 @@ $connection->insert('variable_store')
'value' => 'fr - The Slogan',
'serialized' => '0',
))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'en',
+ 'name' => 'user_default_timezone',
+ 'value' => '2',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'fr',
+ 'name' => 'user_default_timezone',
+ 'value' => '0',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_cancel_confirm_body',
+ 'value' => 'is - A little birdie said you wanted to cancel your account.',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_cancel_confirm_subject',
+ 'value' => 'is - Are you sure?',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_password_reset_body',
+ 'value' => "is - Nope! You're locked out forever.",
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_password_reset_subject',
+ 'value' => 'is - Fix your password',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_register_admin_created_body',
+ 'value' => "is - ...and she could take it away.\r\n[site:name], [site:url]",
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_register_admin_created_subject',
+ 'value' => 'is - Gawd made you an account',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_register_no_approval_required_body',
+ 'value' => 'is - You can now log in if you can figure out how to use Drupal!',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_register_no_approval_required_subject',
+ 'value' => 'is - Welcome!',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_register_pending_approval_body',
+ 'value' => 'is - ...you will join our Circle. Let the Drupal flow through you.',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_register_pending_approval_subject',
+ 'value' => 'is - Soon...',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_status_activated_body',
+ 'value' => 'is - Your account was activated, and there was much rejoicing.',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_status_activated_subject',
+ 'value' => 'is - Your account is approved!',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_status_blocked_body',
+ 'value' => 'is - You no longer please the robot overlords. Go to your room and chill out.',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_status_blocked_subject',
+ 'value' => 'is - BEGONE!',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_status_canceled_body',
+ 'value' => 'is - The gates of Drupal are closed to you. Now you will work in the salt mines.',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'user_mail_status_canceled_subject',
+ 'value' => 'is - So long, bub',
+ 'serialized' => '0',
+))
+->values(array(
+ 'realm' => 'language',
+ 'realm_key' => 'is',
+ 'name' => 'anonymous',
+ 'value' => 'is - anonymous',
+ 'serialized' => '0',
+))
->execute();
$connection->schema()->createTable('watchdog', array(