diff --git a/src/Form/PhotoswipeAdminSettings.php b/src/Form/PhotoswipeAdminSettings.php
index a005140..e6f12c5 100644
--- a/src/Form/PhotoswipeAdminSettings.php
+++ b/src/Form/PhotoswipeAdminSettings.php
@@ -48,9 +48,9 @@ class PhotoswipeAdminSettings extends ConfigFormBase {
   public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
     $form['photoswipe_always_load_non_admin'] = [
       '#type' => 'checkbox',
-      '#title' => t('Load PhotoSwipe on all non-admin pages'),
+      '#title' => $this->t('Load PhotoSwipe on all non-admin pages'),
       '#default_value' => \Drupal::config('photoswipe.settings')->get('photoswipe_always_load_non_admin'),
-      '#description' => t('Useful if you want to use photoswipe elsewhere by just adding the <code>.photoswipe</code> CSS class.'),
+      '#description' => $this->t('Useful if you want to use photoswipe elsewhere by just adding the <code>.photoswipe</code> CSS class.'),
     ];
 
     return parent::buildForm($form, $form_state);
diff --git a/src/Plugin/Field/FieldFormatter/PhotoswipeFieldFormatter.php b/src/Plugin/Field/FieldFormatter/PhotoswipeFieldFormatter.php
index 4545e0a..ae5900a 100644
--- a/src/Plugin/Field/FieldFormatter/PhotoswipeFieldFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/PhotoswipeFieldFormatter.php
@@ -41,22 +41,22 @@ class PhotoswipeFieldFormatter extends FormatterBase {
   public function settingsForm(array $form, FormStateInterface $form_state) {
     $image_styles = image_style_options(FALSE);
     $image_styles_hide = $image_styles;
-    $image_styles_hide['hide'] = t('Hide (do not display image)');
+    $image_styles_hide['hide'] = $this->t('Hide (do not display image)');
     $element['photoswipe_node_style'] = array(
-      '#title' => t('Node image style'),
+      '#title' => $this->t('Node image style'),
       '#type' => 'select',
       '#default_value' => $this->getSetting('photoswipe_node_style'),
-      '#empty_option' => t('None (original image)'),
+      '#empty_option' => $this->t('None (original image)'),
       '#options' => $image_styles_hide,
-      '#description' => t('Image style to use in the node.'),
+      '#description' => $this->t('Image style to use in the node.'),
     );
     $element['photoswipe_image_style'] = array(
-      '#title' => t('Photoswipe image style'),
+      '#title' => $this->t('Photoswipe image style'),
       '#type' => 'select',
       '#default_value' => $this->getSetting('photoswipe_image_style'),
-      '#empty_option' => t('None (original image)'),
+      '#empty_option' => $this->t('None (original image)'),
       '#options' => $image_styles,
-      '#description' => t('Image style to use in the Photoswipe.'),
+      '#description' => $this->t('Image style to use in the Photoswipe.'),
     );
 
     // Set our caption options
@@ -73,11 +73,11 @@ class PhotoswipeFieldFormatter extends FormatterBase {
     }
 
     $element['photoswipe_caption'] = array(
-      '#title' => t('Photoswipe image caption'),
+      '#title' => $this->t('Photoswipe image caption'),
       '#type' => 'select',
       '#default_value' => $this->getSetting('photoswipe_caption'),
       '#options' => $caption_options,
-      '#description' => t('Field that should be used for the caption.'),
+      '#description' => $this->t('Field that should be used for the caption.'),
     );
 
     // Add the current view mode so we can control the view mode for node fields.
@@ -101,20 +101,20 @@ class PhotoswipeFieldFormatter extends FormatterBase {
     // Styles could be lost because of enabled/disabled modules that defines
     // their styles in code.
     if (isset($image_styles[$this->getSetting('photoswipe_node_style')])) {
-      $summary[] = t('Node image style: @style', array('@style' => $image_styles[$this->getSetting('photoswipe_node_style')]));
+      $summary[] = $this->t('Node image style: @style', array('@style' => $image_styles[$this->getSetting('photoswipe_node_style')]));
     }
     else if ($this->getSetting('photoswipe_node_style') == 'hide') {
-      $summary[] = t('Node image style: Hide');
+      $summary[] = $this->t('Node image style: Hide');
     }
     else {
-      $summary[] = t('Node image style: Original image');
+      $summary[] = $this->t('Node image style: Original image');
     }
 
     if (isset($image_styles[$this->getSetting('photoswipe_image_style')])) {
-      $summary[] = t('Photoswipe image style: @style', array('@style' => $image_styles[$this->getSetting('photoswipe_image_style')]));
+      $summary[] = $this->t('Photoswipe image style: @style', array('@style' => $image_styles[$this->getSetting('photoswipe_image_style')]));
     }
     else {
-      $summary[] = t('photoswipe image style: Original image');
+      $summary[] = $this->t('photoswipe image style: Original image');
     }
 
     if ($this->getSetting('photoswipe_caption')) {
@@ -129,7 +129,7 @@ class PhotoswipeFieldFormatter extends FormatterBase {
       else {
         $caption_setting = $this->getSetting('photoswipe_caption');
       }
-      $summary[] = t('Photoswipe Caption: @field', array('@field' => $caption_setting));
+      $summary[] = $this->t('Photoswipe Caption: @field', array('@field' => $caption_setting));
     }
 
     return $summary;
