diff --git a/captcha.install b/captcha.install
index f3f8783..a0d672d 100755
--- a/captcha.install
+++ b/captcha.install
@@ -5,8 +5,6 @@
  * Install, update and uninstall functions for the CAPTCHA module.
  */
 
-use Drupal\Core\Url;
-
 /**
  * Implements hook_schema().
  */
diff --git a/image_captcha/src/Form/ImageCaptchaSettingsForm.php b/image_captcha/src/Form/ImageCaptchaSettingsForm.php
index 139ad4f..60339c1 100755
--- a/image_captcha/src/Form/ImageCaptchaSettingsForm.php
+++ b/image_captcha/src/Form/ImageCaptchaSettingsForm.php
@@ -72,7 +72,7 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
     // First some error checking.
     $setup_status = _image_captcha_check_setup(FALSE);
     if ($setup_status & IMAGE_CAPTCHA_ERROR_NO_GDLIB) {
-      drupal_set_message(t(
+      drupal_set_message($this->t(
         'The Image CAPTCHA module can not generate images because your PHP setup does not support it (no <a href="!gdlib" target="_blank">GD library</a> with JPEG support).',
         ['!gdlib' => 'http://php.net/manual/en/book.image.php']
       ), 'error');
@@ -82,8 +82,8 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
 
     $form['image_captcha_example'] = [
       '#type' => 'details',
-      '#title' => t('Example'),
-      '#description' => t('Presolved image CAPTCHA example, generated with the current settings.'),
+      '#title' => $this->t('Example'),
+      '#description' => $this->t('Presolved image CAPTCHA example, generated with the current settings.'),
     ];
 
     $form['image_captcha_example']['image'] = [
@@ -95,29 +95,29 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
     // General code settings.
     $form['image_captcha_code_settings'] = [
       '#type' => 'details',
-      '#title' => t('Code settings'),
+      '#title' => $this->t('Code settings'),
     ];
 
     $form['image_captcha_code_settings']['image_captcha_image_allowed_chars'] = [
       '#type' => 'textfield',
-      '#title' => t('Characters to use in the code'),
+      '#title' => $this->t('Characters to use in the code'),
       '#default_value' => $config->get('image_captcha_image_allowed_chars'),
     ];
     $form['image_captcha_code_settings']['image_captcha_code_length'] = [
       '#type' => 'select',
-      '#title' => t('Code length'),
+      '#title' => $this->t('Code length'),
       '#options' => [2 => 2, 3, 4, 5, 6, 7, 8, 9, 10],
       '#default_value' => $config->get('image_captcha_code_length'),
-      '#description' => t('The code length influences the size of the image. Note that larger values make the image generation more CPU intensive.'),
+      '#description' => $this->t('The code length influences the size of the image. Note that larger values make the image generation more CPU intensive.'),
     ];
     // RTL support option (only show this option when there are RTL languages).
     $language = $this->languageManager->getCurrentLanguage();
     if ($language->getDirection() == Language::DIRECTION_RTL) {
       $form['image_captcha_code_settings']['image_captcha_rtl_support'] = [
-        '#title' => t('RTL support'),
+        '#title' => $this->t('RTL support'),
         '#type' => 'checkbox',
         '#default_value' => $config->get('image_captcha_rtl_support'),
-        '#description' => t('Enable this option to render the code from right to left for right to left languages.'),
+        '#description' => $this->t('Enable this option to render the code from right to left for right to left languages.'),
       ];
     }
 
@@ -127,109 +127,109 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
     // Color and file format settings.
     $form['image_captcha_color_settings'] = [
       '#type' => 'details',
-      '#title' => t('Color and image settings'),
-      '#description' => t('Configuration of the background, text colors and file format of the image CAPTCHA.'),
+      '#title' => $this->t('Color and image settings'),
+      '#description' => $this->t('Configuration of the background, text colors and file format of the image CAPTCHA.'),
     ];
 
     $form['image_captcha_color_settings']['image_captcha_background_color'] = [
       '#type' => 'textfield',
-      '#title' => t('Background color'),
-      '#description' => t('Enter the hexadecimal code for the background color (e.g. #FFF or #FFCE90). When using the PNG file format with transparent background, it is recommended to set this close to the underlying background color.'),
+      '#title' => $this->t('Background color'),
+      '#description' => $this->t('Enter the hexadecimal code for the background color (e.g. #FFF or #FFCE90). When using the PNG file format with transparent background, it is recommended to set this close to the underlying background color.'),
       '#default_value' => $config->get('image_captcha_background_color'),
       '#maxlength' => 7,
       '#size' => 8,
     ];
     $form['image_captcha_color_settings']['image_captcha_foreground_color'] = [
       '#type' => 'textfield',
-      '#title' => t('Text color'),
-      '#description' => t('Enter the hexadecimal code for the text color (e.g. #000 or #004283).'),
+      '#title' => $this->t('Text color'),
+      '#description' => $this->t('Enter the hexadecimal code for the text color (e.g. #000 or #004283).'),
       '#default_value' => $config->get('image_captcha_foreground_color'),
       '#maxlength' => 7,
       '#size' => 8,
     ];
     $form['image_captcha_color_settings']['image_captcha_foreground_color_randomness'] = [
       '#type' => 'select',
-      '#title' => t('Additional variation of text color'),
+      '#title' => $this->t('Additional variation of text color'),
       '#options' => [
-        0 => t('No variation'),
-        50 => t('Little variation'),
-        100 => t('Medium variation'),
-        150 => t('High variation'),
-        200 => t('Very high variation'),
+        0 => $this->t('No variation'),
+        50 => $this->t('Little variation'),
+        100 => $this->t('Medium variation'),
+        150 => $this->t('High variation'),
+        200 => $this->t('Very high variation'),
       ],
       '#default_value' => $config->get('image_captcha_foreground_color_randomness'),
-      '#description' => t('The different characters will have randomized colors in the specified range around the text color.'),
+      '#description' => $this->t('The different characters will have randomized colors in the specified range around the text color.'),
     ];
     $form['image_captcha_color_settings']['image_captcha_file_format'] = [
       '#type' => 'select',
-      '#title' => t('File format'),
-      '#description' => t('Select the file format for the image. JPEG usually results in smaller files, PNG allows tranparency.'),
+      '#title' => $this->t('File format'),
+      '#description' => $this->t('Select the file format for the image. JPEG usually results in smaller files, PNG allows tranparency.'),
       '#default_value' => $config->get('image_captcha_file_format'),
       '#options' => [
-        IMAGE_CAPTCHA_FILE_FORMAT_JPG => t('JPEG'),
-        IMAGE_CAPTCHA_FILE_FORMAT_PNG => t('PNG'),
-        IMAGE_CAPTCHA_FILE_FORMAT_TRANSPARENT_PNG => t('PNG with transparent background'),
+        IMAGE_CAPTCHA_FILE_FORMAT_JPG => $this->t('JPEG'),
+        IMAGE_CAPTCHA_FILE_FORMAT_PNG => $this->t('PNG'),
+        IMAGE_CAPTCHA_FILE_FORMAT_TRANSPARENT_PNG => $this->t('PNG with transparent background'),
       ],
     ];
 
     // Distortion and noise settings.
     $form['image_captcha_distortion_and_noise'] = [
       '#type' => 'details',
-      '#title' => t('Distortion and noise'),
-      '#description' => t('With these settings you can control the degree of obfuscation by distortion and added noise. Do not exaggerate the obfuscation and assure that the code in the image is reasonably readable. For example, do not combine high levels of distortion and noise.'),
+      '#title' => $this->t('Distortion and noise'),
+      '#description' => $this->t('With these settings you can control the degree of obfuscation by distortion and added noise. Do not exaggerate the obfuscation and assure that the code in the image is reasonably readable. For example, do not combine high levels of distortion and noise.'),
     ];
 
     $form['image_captcha_distortion_and_noise']['image_captcha_distortion_amplitude'] = [
       '#type' => 'select',
-      '#title' => t('Distortion level'),
+      '#title' => $this->t('Distortion level'),
       '#options' => [
-        0 => t('@level - no distortion', ['@level' => '0']),
-        1 => t('@level - low', ['@level' => '1']),
+        0 => $this->t('@level - no distortion', ['@level' => '0']),
+        1 => $this->t('@level - low', ['@level' => '1']),
         2 => '2',
         3 => '3',
         4 => '4',
-        5 => t('@level - medium', ['@level' => '5']),
+        5 => $this->t('@level - medium', ['@level' => '5']),
         6 => '6',
         7 => '7',
         8 => '8',
         9 => '9',
-        10 => t('@level - high', ['@level' => '10']),
+        10 => $this->t('@level - high', ['@level' => '10']),
       ],
       '#default_value' => $config->get('image_captcha_distortion_amplitude'),
-      '#description' => t('Set the degree of wave distortion in the image.'),
+      '#description' => $this->t('Set the degree of wave distortion in the image.'),
     ];
     $form['image_captcha_distortion_and_noise']['image_captcha_bilinear_interpolation'] = [
       '#type' => 'checkbox',
-      '#title' => t('Smooth distortion'),
+      '#title' => $this->t('Smooth distortion'),
       '#default_value' => $config->get('image_captcha_bilinear_interpolation'),
-      '#description' => t('This option enables bilinear interpolation of the distortion which makes the image look smoother, but it is more CPU intensive.'),
+      '#description' => $this->t('This option enables bilinear interpolation of the distortion which makes the image look smoother, but it is more CPU intensive.'),
     ];
 
     $form['image_captcha_distortion_and_noise']['image_captcha_dot_noise'] = [
       '#type' => 'checkbox',
-      '#title' => t('Add salt and pepper noise'),
+      '#title' => $this->t('Add salt and pepper noise'),
       '#default_value' => $config->get('image_captcha_dot_noise'),
-      '#description' => t('This option adds randomly colored point noise.'),
+      '#description' => $this->t('This option adds randomly colored point noise.'),
     ];
 
     $form['image_captcha_distortion_and_noise']['image_captcha_line_noise'] = [
       '#type' => 'checkbox',
-      '#title' => t('Add line noise'),
+      '#title' => $this->t('Add line noise'),
       '#default_value' => $config->get('image_captcha_line_noise', 0),
-      '#description' => t('This option enables lines randomly drawn on top of the text code.'),
+      '#description' => $this->t('This option enables lines randomly drawn on top of the text code.'),
     ];
 
     $form['image_captcha_distortion_and_noise']['image_captcha_noise_level'] = [
       '#type' => 'select',
-      '#title' => t('Noise level'),
+      '#title' => $this->t('Noise level'),
       '#options' => [
-        1 => '1 - ' . t('low'),
+        1 => '1 - ' . $this->t('low'),
         2 => '2',
-        3 => '3 - ' . t('medium'),
+        3 => '3 - ' . $this->t('medium'),
         4 => '4',
-        5 => '5 - ' . t('high'),
+        5 => '5 - ' . $this->t('high'),
         7 => '7',
-        10 => '10 - ' . t('severe'),
+        10 => '10 - ' . $this->t('severe'),
       ],
       '#default_value' => (int) $config->get('image_captcha_noise_level'),
     ];
@@ -244,7 +244,7 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
 
     // Check image_captcha_image_allowed_chars for spaces.
     if (preg_match('/\s/', $form_state->getValue('image_captcha_image_allowed_chars'))) {
-      $form_state->setErrorByName('image_captcha_image_allowed_chars', t('The list of characters to use should not contain spaces.'));
+      $form_state->setErrorByName('image_captcha_image_allowed_chars', $this->t('The list of characters to use should not contain spaces.'));
     }
 
     if (!isset($form['image_captcha_font_settings']['no_ttf_support'])) {
@@ -252,28 +252,28 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
       // Filter the image_captcha fonts array to pick out the selected ones.
       $fonts = array_filter($form_state->getValue('image_captcha_fonts'));
       if (count($fonts) < 1) {
-        $form_state->setErrorByName('image_captcha_fonts', t('You need to select at least one font.'));
+        $form_state->setErrorByName('image_captcha_fonts', $this->t('You need to select at least one font.'));
       }
       if ($form_state->getValue('image_captcha_fonts')['BUILTIN']) {
         // With the built in font, only latin2 characters should be used.
         if (preg_match('/[^a-zA-Z0-9]/', $form_state->getValue('image_captcha_image_allowed_chars'))) {
-          $form_state->setErrorByName('image_captcha_image_allowed_chars', t('The built-in font only supports Latin2 characters. Only use "a" to "z" and numbers.'));
+          $form_state->setErrorByName('image_captcha_image_allowed_chars', $this->t('The built-in font only supports Latin2 characters. Only use "a" to "z" and numbers.'));
         }
       }
 
       $readable_fonts = array();
       list($readable_fonts, $problem_fonts) = _image_captcha_check_fonts($fonts);
       if (count($problem_fonts) > 0) {
-        $form_state->setErrorByName('image_captcha_fonts', t('The following fonts are not readable: %fonts.', ['%fonts' => implode(', ', $problem_fonts)]));
+        $form_state->setErrorByName('image_captcha_fonts', $this->t('The following fonts are not readable: %fonts.', ['%fonts' => implode(', ', $problem_fonts)]));
       }
     }
 
     // Check color settings.
     if (!preg_match('/^#([0-9a-fA-F]{3}){1,2}$/', $form_state->getValue('image_captcha_background_color'))) {
-      $form_state->setErrorByName('image_captcha_background_color', t('Background color is not a valid hexadecimal color value.'));
+      $form_state->setErrorByName('image_captcha_background_color', $this->t('Background color is not a valid hexadecimal color value.'));
     }
     if (!preg_match('/^#([0-9a-fA-F]{3}){1,2}$/', $form_state->getValue('image_captcha_foreground_color'))) {
-      $form_state->setErrorByName('image_captcha_foreground_color', t('Text color is not a valid hexadecimal color value.'));
+      $form_state->setErrorByName('image_captcha_foreground_color', $this->t('Text color is not a valid hexadecimal color value.'));
     }
 
     parent::validateForm($form, $form_state);
@@ -309,7 +309,7 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
     // Put it all in a details element.
     $form = [
       '#type' => 'details',
-      '#title' => t('Font settings'),
+      '#title' => $this->t('Font settings'),
     ];
 
     // First check if there is TrueType support.
@@ -318,8 +318,8 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
       // Show a warning that there is no TrueType support.
       $form['no_ttf_support'] = [
         '#type' => 'item',
-        '#title' => t('No TrueType support'),
-        '#markup' => t('The Image CAPTCHA module can not use TrueType fonts because your PHP setup does not support it. You can only use a PHP built-in bitmap font of fixed size.'),
+        '#title' => $this->t('No TrueType support'),
+        '#markup' => $this->t('The Image CAPTCHA module can not use TrueType fonts because your PHP setup does not support it. You can only use a PHP built-in bitmap font of fixed size.'),
       ];
     }
     else {
@@ -366,9 +366,9 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
 
       $form['image_captcha_fonts'] = [
         '#type' => 'checkboxes',
-        '#title' => t('Fonts'),
+        '#title' => $this->t('Fonts'),
         '#default_value' => $default_fonts,
-        '#description' => t('Select the fonts to use for the text in the image CAPTCHA. Apart from the provided defaults, you can also use your own TrueType fonts (filename extension .ttf) by putting them in %fonts_library_general or %fonts_library_specific.',
+        '#description' => $this->t('Select the fonts to use for the text in the image CAPTCHA. Apart from the provided defaults, you can also use your own TrueType fonts (filename extension .ttf) by putting them in %fonts_library_general or %fonts_library_specific.',
           [
             '%fonts_library_general' => 'sites/all/libraries/fonts',
             '%fonts_library_specific' => $conf_path . '/libraries/fonts',
@@ -380,19 +380,19 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
 
       $form['image_captcha_font_size'] = [
         '#type' => 'select',
-        '#title' => t('Font size'),
+        '#title' => $this->t('Font size'),
         '#options' => [
-          9 => '9 pt - ' . t('tiny'),
-          12 => '12 pt - ' . t('small'),
+          9 => '9 pt - ' . $this->t('tiny'),
+          12 => '12 pt - ' . $this->t('small'),
           18 => '18 pt',
-          24 => '24 pt - ' . t('normal'),
+          24 => '24 pt - ' . $this->t('normal'),
           30 => '30 pt',
-          36 => '36 pt - ' . t('large'),
+          36 => '36 pt - ' . $this->t('large'),
           48 => '48 pt',
-          64 => '64 pt - ' . t('extra large'),
+          64 => '64 pt - ' . $this->t('extra large'),
         ],
         '#default_value' => (int) $config->get('image_captcha_font_size'),
-        '#description' => t('The font size influences the size of the image. Note that larger values make the image generation more CPU intensive.'),
+        '#description' => $this->t('The font size influences the size of the image. Note that larger values make the image generation more CPU intensive.'),
       ];
     }
 
@@ -400,14 +400,14 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
     // fonts and the builtin font.
     $form['image_captcha_font_settings']['image_captcha_character_spacing'] = [
       '#type' => 'select',
-      '#title' => t('Character spacing'),
-      '#description' => t('Define the average spacing between characters. Note that larger values make the image generation more CPU intensive.'),
+      '#title' => $this->t('Character spacing'),
+      '#description' => $this->t('Define the average spacing between characters. Note that larger values make the image generation more CPU intensive.'),
       '#default_value' => $config->get('image_captcha_character_spacing'),
       '#options' => [
-        '0.75' => t('tight'),
-        '1' => t('normal'),
-        '1.2' => t('wide'),
-        '1.5' => t('extra wide'),
+        '0.75' => $this->t('tight'),
+        '1' => $this->t('normal'),
+        '1.2' => $this->t('wide'),
+        '1.5' => $this->t('extra wide'),
       ],
     ];
 
diff --git a/src/Form/CaptchaSettingsForm.php b/src/Form/CaptchaSettingsForm.php
index 24eb912..a9ecbd4 100755
--- a/src/Form/CaptchaSettingsForm.php
+++ b/src/Form/CaptchaSettingsForm.php
@@ -101,20 +101,20 @@ class CaptchaSettingsForm extends ConfigFormBase {
     // Based on Drupal core's "Clear all caches" (performance settings page).
     $form['form_protection']['placement_caching'] = [
       '#type' => 'item',
-      '#title' => t('CAPTCHA placement caching'),
-      '#description' => t('For efficiency, the positions of the CAPTCHA elements in each of the configured forms are cached. Most of the time, the structure of a form does not change and it would be a waste to recalculate the positions every time. Occasionally however, the form structure can change (e.g. during site building) and clearing the CAPTCHA placement cache can be required to fix the CAPTCHA placement.'),
+      '#title' => $this->t('CAPTCHA placement caching'),
+      '#description' => $this->t('For efficiency, the positions of the CAPTCHA elements in each of the configured forms are cached. Most of the time, the structure of a form does not change and it would be a waste to recalculate the positions every time. Occasionally however, the form structure can change (e.g. during site building) and clearing the CAPTCHA placement cache can be required to fix the CAPTCHA placement.'),
     ];
     $form['form_protection']['placement_caching']['placement_cache_clear'] = [
       '#type' => 'submit',
-      '#value' => t('Clear the CAPTCHA placement cache'),
+      '#value' => $this->t('Clear the CAPTCHA placement cache'),
       '#submit' => ['::clearCaptchaPlacementCacheSubmit'],
     ];
 
     // Configuration option for adding a CAPTCHA description.
     $form['add_captcha_description'] = [
       '#type' => 'checkbox',
-      '#title' => t('Add a description to the CAPTCHA'),
-      '#description' => t('Add a configurable description to explain the purpose of the CAPTCHA to the visitor.'),
+      '#title' => $this->t('Add a description to the CAPTCHA'),
+      '#description' => $this->t('Add a configurable description to explain the purpose of the CAPTCHA to the visitor.'),
       '#default_value' => $config->get('add_captcha_description'),
     ];
     $form['description'] = [
@@ -136,8 +136,8 @@ class CaptchaSettingsForm extends ConfigFormBase {
     // Option for case sensitive/insensitive validation of the responses.
     $form['default_validation'] = [
       '#type' => 'radios',
-      '#title' => t('Default CAPTCHA validation'),
-      '#description' => t('Define how the response should be processed by default. Note that the modules that provide the actual challenges can override or ignore this.'),
+      '#title' => $this->t('Default CAPTCHA validation'),
+      '#description' => $this->t('Define how the response should be processed by default. Note that the modules that provide the actual challenges can override or ignore this.'),
       '#options' => [
         CAPTCHA_DEFAULT_VALIDATION_CASE_SENSITIVE => $this->t('Case sensitive validation: the response has to exactly match the solution.'),
         CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE => $this->t('Case insensitive validation: lowercase/uppercase errors are ignored.'),
@@ -149,7 +149,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
     // TODO for D7: Rethink/simplify the explanation and UI strings.
     $form['persistence'] = [
       '#type' => 'radios',
-      '#title' => t('Persistence'),
+      '#title' => $this->t('Persistence'),
       '#default_value' => $config->get('persistence'),
       '#options' => [
         CAPTCHA_PERSISTENCE_SHOW_ALWAYS => $this->t('Always add a challenge.'),
@@ -157,7 +157,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
         CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL_PER_FORM_TYPE => $this->t('Omit challenges on a form type once the user successfully responds to a challenge on a form of that type.'),
         CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL => $this->t('Omit challenges on all forms once the user successfully responds to any challenge on the site.'),
       ],
-      '#description' => t('Define if challenges should be omitted during the rest of a session once the user successfully responds to a challenge.'),
+      '#description' => $this->t('Define if challenges should be omitted during the rest of a session once the user successfully responds to a challenge.'),
     ];
 
     // Enable wrong response counter.
@@ -189,7 +189,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
     $form['actions'] = ['#type' => 'actions'];
     $form['actions']['submit'] = [
       '#type' => 'submit',
-      '#value' => t('Save configuration'),
+      '#value' => $this->t('Save configuration'),
     ];
 
     return parent::buildForm($form, $form_state);
@@ -214,7 +214,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
     $config->set('enable_stats', $form_state->getValue('enable_stats'));
     $config->set('log_wrong_responses', $form_state->getValue('log_wrong_responses'));
     $config->save();
-    drupal_set_message(t('The CAPTCHA settings have been saved.'), 'status');
+    drupal_set_message($this->t('The CAPTCHA settings have been saved.'), 'status');
 
     parent::submitForm($form, $form_state);
   }
