diff --git a/src/FillPdfAccessController.php b/src/FillPdfAccessController.php index 2b39752d425c228a8c1065e821a891c10504f576..a5ff1bddbf109daa69e353459d09444edbd8ad94 100644 --- a/src/FillPdfAccessController.php +++ b/src/FillPdfAccessController.php @@ -4,6 +4,7 @@ namespace Drupal\fillpdf; use Drupal\Core\Access\AccessResult; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; use Drupal\Core\Logger\LoggerChannelTrait; @@ -17,6 +18,7 @@ class FillPdfAccessController implements ContainerInjectionInterface { use MessengerTrait; use LoggerChannelTrait; + use StringTranslationTrait; /** * The FillPDF access helper. @@ -107,7 +109,7 @@ class FillPdfAccessController implements ContainerInjectionInterface { catch (\InvalidArgumentException $exception) { $message = $exception->getMessage(); $is_admin = $this->currentUser->hasPermission('administer pdfs'); - $this->messenger()->addError($is_admin ? $message : t('An error occurred. Please notify the administrator.')); + $this->messenger()->addError($is_admin ? $message : $this->t('An error occurred. Please notify the administrator.')); $this->getLogger('fillpdf')->error($message); return AccessResult::forbidden(); } diff --git a/src/FillPdfFormListBuilder.php b/src/FillPdfFormListBuilder.php index 4cbb6c7d42416115e3660826ed677cf64f30532c..324343a8aea088743c042eb4d21aa735248f3e2a 100644 --- a/src/FillPdfFormListBuilder.php +++ b/src/FillPdfFormListBuilder.php @@ -24,17 +24,17 @@ class FillPdfFormListBuilder extends EntityListBuilder { public function getDefaultOperations(EntityInterface $entity) { $duplicate = [ - 'title' => t('Duplicate'), + 'title' => $this->t('Duplicate'), 'weight' => 10, 'url' => $this->ensureDestination($entity->toUrl('duplicate-form')), ]; $export = [ - 'title' => t('Export configuration'), + 'title' => $this->t('Export configuration'), 'weight' => 20, 'url' => $this->ensureDestination($entity->toUrl('export-form')), ]; $import = [ - 'title' => t('Import configuration'), + 'title' => $this->t('Import configuration'), 'weight' => 30, 'url' => $this->ensureDestination($entity->toUrl('import-form')), ]; diff --git a/src/Form/FillPdfFormForm.php b/src/Form/FillPdfFormForm.php index e502ab52e232ff4700a3de4270ec10eb96896844..267e11455db2ff3c833055afddbb114335c68897 100644 --- a/src/Form/FillPdfFormForm.php +++ b/src/Form/FillPdfFormForm.php @@ -373,7 +373,7 @@ class FillPdfFormForm extends ContentEntityForm { $form['additional_settings']['security'] = [ '#name' => 'security', '#type' => 'details', - '#title' => t('PDF Security (currently only works with pdftk)'), + '#title' => $this->t('PDF Security (currently only works with pdftk)'), '#weight' => 100, '#open' => $fillpdf_form && ( !empty($fillpdf_form->pdftk_encryption->value) || diff --git a/src/Form/FillPdfSettingsForm.php b/src/Form/FillPdfSettingsForm.php index beb44a87084369a9612317885198ff6edbd668ac..69f67032e2996a87e3bce4486ef641bb85a3827b 100644 --- a/src/Form/FillPdfSettingsForm.php +++ b/src/Form/FillPdfSettingsForm.php @@ -198,7 +198,7 @@ class FillPdfSettingsForm extends ConfigFormBase { '#default_value' => array_key_exists($template_scheme, $template_scheme_options) ? $template_scheme : $file_default_scheme, '#options' => $template_scheme_options, '#description' => $this->t('This setting is used as the storage for uploaded templates; note that the use of %public is more efficient, but does not provide any access control.<br />Changing this setting will require you to migrate associated files and data yourself and is not recommended after you have uploaded a template.', [ - '%public' => t('Public files'), + '%public' => $this->t('Public files'), ]), ]; diff --git a/tests/src/Functional/FillPdfTestBase.php b/tests/src/Functional/FillPdfTestBase.php index f70081e046afea43ab9a7bcc3fe9570ebfca71fe..cfff89fc10844f5f003eb86d102fa143ec75032f 100644 --- a/tests/src/Functional/FillPdfTestBase.php +++ b/tests/src/Functional/FillPdfTestBase.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\fillpdf\Functional; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Tests\file\Functional\FileFieldTestBase; use Drupal\Tests\fillpdf\Traits\TestFillPdfTrait; use Drupal\Tests\fillpdf\Traits\TestImageFieldTrait; @@ -12,6 +13,7 @@ use Drupal\user\Entity\Role; */ abstract class FillPdfTestBase extends FileFieldTestBase { + use StringTranslationTrait; use TestFillPdfTrait; use TestImageFieldTrait; diff --git a/tests/src/Functional/PdfWebformPopulationTest.php b/tests/src/Functional/PdfWebformPopulationTest.php index 616fb8a62e49d308264118fa128ceee53a5a00d2..775004853b1c2ef7618b10b0c951f8ea26900946 100644 --- a/tests/src/Functional/PdfWebformPopulationTest.php +++ b/tests/src/Functional/PdfWebformPopulationTest.php @@ -59,7 +59,7 @@ class PdfWebformPopulationTest extends FillPdfTestBase { // Create a test submission for our Contact form. $contact_form = Webform::load('fillpdf_contact'); $contact_form_test_route = Url::fromRoute('entity.webform.test_form', ['webform' => $contact_form->id()]); - $this->drupalPostForm($contact_form_test_route, [], t('Send message')); + $this->drupalPostForm($contact_form_test_route, [], $this->t('Send message')); // Load the submission. $this->testSubmission = WebformSubmission::load($this->getLastSubmissionId($contact_form));