Skip to content
Snippets Groups Projects
Commit b8738b8d authored by Steven Jones's avatar Steven Jones Committed by Steven Jones
Browse files

Issue #2843310 by nehakhadke, Steven Jones: $this->t() should be used instead...

Issue #2843310 by nehakhadke, Steven Jones: $this->t() should be used instead of t() for Drupal 8 version
parent e024ecde
Branches
Tags
No related merge requests found
......@@ -4,3 +4,4 @@ services:
parent: default_plugin_manager
imageapi_optimize.hooks:
class: Drupal\imageapi_optimize\ImageAPIOptimizeHookImplementations
arguments: ['@string_translation']
......@@ -2,11 +2,33 @@
namespace Drupal\imageapi_optimize;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
/**
* Hook implementations for the Image Optimize module.
*/
class ImageAPIOptimizeHookImplementations {
use StringTranslationTrait;
/**
* The stream wrapper manager service.
*
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
*/
protected $stringTranslation;
/**
* Constructs a new ImageAPIOptimizeHookImplementations object.
*
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The stream translation service.
*/
public function __construct(TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
}
/**
* Implements hook_entity_type_alter().
*/
......@@ -29,10 +51,10 @@ class ImageAPIOptimizeHookImplementations {
$entity = $form_state->getFormObject()->getEntity();
$form['pipeline'] = [
'#type' => 'select',
'#title' => t('Image Optimize Pipeline'),
'#title' => $this->t('Image Optimize Pipeline'),
'#options' => imageapi_optimize_pipeline_options(),
'#default_value' => $entity->getPipeline(),
'#description' => t('Optionally select an Image Optimization pipeline which will be applied after all effects in this image style.'),
'#description' => $this->t('Optionally select an Image Optimization pipeline which will be applied after all effects in this image style.'),
'#weight' => 10,
];
}
......
......@@ -70,7 +70,7 @@ class ImageAPIOptimizePipelineListBuilder extends ConfigEntityListBuilder {
*/
public function getDefaultOperations(EntityInterface $entity) {
$flush = array(
'title' => t('Flush'),
'title' => $this->t('Flush'),
'weight' => 200,
'url' => $entity->urlInfo('flush-form'),
);
......
......@@ -61,22 +61,22 @@ abstract class ImageAPIOptimizeProcessorBinaryBase extends ConfigurableImageAPIO
if (!$this->findExecutablePath()) {
$form['executable'] = array(
'#type' => 'item',
'#title' => t('Executable'),
'#markup' => t('The @binary binary must be installed, please install or specify the path to the @binary executable directly.', array('@binary' => $this->executableName())),
'#title' => $this->t('Executable'),
'#markup' => $this->t('The @binary binary must be installed, please install or specify the path to the @binary executable directly.', array('@binary' => $this->executableName())),
);
}
else {
$form['executable'] = array(
'#type' => 'item',
'#title' => t('Executable'),
'#markup' => t('The @binary executable has been automatically located: @path. To override, set a different executate path below.', array('@path' => $this->findExecutablePath(), '@binary' => $this->executableName())),
'#title' => $this->t('Executable'),
'#markup' => $this->t('The @binary executable has been automatically located: @path. To override, set a different executate path below.', array('@path' => $this->findExecutablePath(), '@binary' => $this->executableName())),
);
}
$form['manual_executable_path'] = array(
'#type' => 'textfield',
'#title' => t('Manually set path'),
'#description' => t('Specify the full path to the @binary executable.', array('@binary' => $this->executableName())),
'#title' => $this->t('Manually set path'),
'#description' => $this->t('Specify the full path to the @binary executable.', array('@binary' => $this->executableName())),
'#default_value' => $this->configuration['manual_executable_path'],
);
return $form;
......@@ -186,7 +186,7 @@ abstract class ImageAPIOptimizeProcessorBinaryBase extends ConfigurableImageAPIO
$description = '';
if (!$this->getFullPathToBinary()) {
$description .= t('<strong>Command not found</strong>');
$description .= $this->t('<strong>Command not found</strong>');
}
$summary = array(
......
......@@ -60,20 +60,20 @@ class AdvDef extends ImageAPIOptimizeProcessorBinaryBase {
$form = parent::buildConfigurationForm($form, $form_state);
$form['recompress'] = array(
'#title' => t('Recompress'),
'#title' => $this->t('Recompress'),
'#type' => 'checkbox',
'#default_value' => $this->configuration['recomporess'],
);
$form['mode'] = array(
'#title' => t('Compression mode'),
'#title' => $this->t('Compression mode'),
'#type' => 'select',
'#options' => array(
0 => t('Disabled'),
1 => t('Fast'),
2 => t('Normal'),
3 => t('Extra'),
4 => t('Insane'),
0 => $this->t('Disabled'),
1 => $this->t('Fast'),
2 => $this->t('Normal'),
3 => $this->t('Extra'),
4 => $this->t('Insane'),
),
'#default_value' => $this->configuration['mode'],
);
......
......@@ -60,20 +60,20 @@ class AdvPng extends ImageAPIOptimizeProcessorBinaryBase {
$form = parent::buildConfigurationForm($form, $form_state);
$form['recompress'] = array(
'#title' => t('Recompress'),
'#title' => $this->t('Recompress'),
'#type' => 'checkbox',
'#default_value' => $this->configuration['recomporess'],
);
$form['mode'] = array(
'#title' => t('Compression mode'),
'#title' => $this->t('Compression mode'),
'#type' => 'select',
'#options' => array(
0 => t('Disabled'),
1 => t('Fast'),
2 => t('Normal'),
3 => t('Extra'),
4 => t('Insane'),
0 => $this->t('Disabled'),
1 => $this->t('Fast'),
2 => $this->t('Normal'),
3 => $this->t('Extra'),
4 => $this->t('Insane'),
),
'#default_value' => $this->configuration['mode'],
);
......
......@@ -77,33 +77,33 @@ class JpegOptim extends ImageAPIOptimizeProcessorBinaryBase {
$form = parent::buildConfigurationForm($form, $form_state);
$form['progressive'] = array(
'#title' => t('Progressive'),
'#title' => $this->t('Progressive'),
'#type' => 'select',
'#options' => array(
'' => t('No change'),
0 => t('Non-progressive'),
1 => t('Progressive'),
'' => $this->t('No change'),
0 => $this->t('Non-progressive'),
1 => $this->t('Progressive'),
),
'#default_value' => $this->configuration['progressive'],
'#description' => t('If "No change" is selected, the output will have the same as the input.'),
'#description' => $this->t('If "No change" is selected, the output will have the same as the input.'),
);
$form['quality'] = array(
'#title' => t('Quality'),
'#title' => $this->t('Quality'),
'#type' => 'number',
'#min' => 0,
'#max' => 100,
'#description' => t('Optionally enter a JPEG quality setting to use, 0 - 100. WARNING: LOSSY'),
'#description' => $this->t('Optionally enter a JPEG quality setting to use, 0 - 100. WARNING: LOSSY'),
'#default_value' => $this->configuration['quality'],
);
$form['size'] = array(
'#title' => t('Target size'),
'#title' => $this->t('Target size'),
'#type' => 'number',
'#min' => 1,
'#max' => 100,
'#field_suffix' => '%',
'#description' => t('Optionally enter a target percentage of filesize for optimisation. WARNING: LOSSY'),
'#description' => $this->t('Optionally enter a target percentage of filesize for optimisation. WARNING: LOSSY'),
'#default_value' => $this->configuration['size'],
);
......
......@@ -61,7 +61,7 @@ class JpegTran extends ImageAPIOptimizeProcessorBinaryBase {
$form = parent::buildConfigurationForm($form, $form_state);
$form['progressive'] = array(
'#title' => t('Progressive'),
'#title' => $this->t('Progressive'),
'#type' => 'checkbox',
'#default_value' => $this->configuration['progressive'],
);
......
......@@ -68,12 +68,12 @@ class OptiPng extends ImageAPIOptimizeProcessorBinaryBase {
);
$form['interlace'] = array(
'#title' => t('Interlace'),
'#title' => $this->t('Interlace'),
'#type' => 'select',
'#options' => array(
'' => t('No change'),
0 => t('Non-interlaced'),
1 => t('Interlaced'),
'' => $this->t('No change'),
0 => $this->t('Non-interlaced'),
1 => $this->t('Interlaced'),
),
'#default_value' => $this->configuration['interlace'],
'#description' => t('If "No change" is select, the output will have the same interlace type as the input.'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment