Skip to content

Commit

Permalink
Fix translation button renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
e-spin committed Jan 5, 2024
1 parent 75286c1 commit 85b406b
Show file tree
Hide file tree
Showing 15 changed files with 269 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2023 Contao Community Alliance.
* (c) 2013-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -16,7 +16,7 @@
* @author David Molineus <[email protected]>
* @author Richard Henkenjohann <[email protected]>
* @author Ingolf Steinhardt <[email protected]>
* @copyright 2013-2023 Contao Community Alliance.
* @copyright 2013-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand Down Expand Up @@ -280,7 +280,7 @@ private function languageSwitcher(EnvironmentInterface $environment)
return $template
->set('languages', $controller->getSupportedLanguages(null))
->set('language', $dataProvider->getCurrentLanguage())
->set('submit', $this->translator->trans('MSC.showSelected', [], 'contao_default'))
->set('submit', $this->translator->trans('MSC.showSelected', 'default'))
->set('REQUEST_TOKEN', $this->tokenManager->getToken($this->tokenName))
->parse();
}
Expand Down Expand Up @@ -402,7 +402,7 @@ protected function renderTemplate(ContaoBackendViewTemplate $template, Environme
$showColumn = $this->getViewSection($definition)->getListingConfig()->getShowColumns();

$template
->set('subHeadline', $this->translate('MSC.select_models', 'contao_default'))
->set('subHeadline', $this->translate('MSC.select_models', 'default'))
->set('tableName', ($definition->getName() ?: 'none'))
->set('select', 'select' === $provider->getParameter('act'))
->set('action', StringUtil::ampersand(Environment::get('request')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private function renderEditFields(

$fields[] = \sprintf(
'<p>&nbsp;</p><strong>%s</strong><p>&nbsp;</p>',
$translator->translate('MSC.no_properties_available')
$translator->translate('MSC.no_properties_available', 'default')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2023 Contao Community Alliance.
* (c) 2013-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,7 +14,7 @@
* @author Sven Baumann <[email protected]>
* @author Richard Henkenjohann <[email protected]>
* @author Ingolf Steinhardt <[email protected]>
* @copyright 2013-2023 Contao Community Alliance.
* @copyright 2013-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -332,7 +332,7 @@ private function renderFieldSets(
if (empty($fieldSet['palette'])) {
$fieldSet['palette'] = \sprintf(
'<p>&nbsp;</p><strong>%s</strong><p>&nbsp;</p>',
$translator->translate('MSC.no_properties_available')
$translator->translate('MSC.no_properties_available', 'default')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2023 Contao Community Alliance.
* (c) 2013-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -13,7 +13,7 @@
* @package contao-community-alliance/dc-general
* @author Sven Baumann <[email protected]>
* @author Ingolf Steinhardt <[email protected]>
* @copyright 2013-2023 Contao Community Alliance.
* @copyright 2013-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0
* @filesource
*/
Expand Down Expand Up @@ -234,10 +234,15 @@ private function isPropertyAllowed(PropertyInterface $property, EnvironmentInter
assert($inputProvider instanceof InputProviderInterface);

Message::addInfo(
\sprintf(
$translator->translate('MSC.not_allowed_property_info'),
$property->getLabel() ?: $property->getName(),
$translator->translate('MSC.' . $inputProvider->getParameter('mode') . 'Selected')
$translator->translate(
'MSC.not_allowed_property_info', 'default',

Check failure on line 238 in src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php

View workflow job for this annotation

GitHub Actions / PHP: 8.1 Contao: ~4.13.0

Only one argument is allowed per line in a multi-line function call (reported by phpcs: PSR2.Methods.FunctionCallSignature.MultipleArguments)

Check failure on line 238 in src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php

View workflow job for this annotation

GitHub Actions / PHP: 8.2 Contao: ~4.13.0

Only one argument is allowed per line in a multi-line function call (reported by phpcs: PSR2.Methods.FunctionCallSignature.MultipleArguments)

Check failure on line 238 in src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php

View workflow job for this annotation

GitHub Actions / PHP: 8.1 Contao: ~4.13.0

Only one argument is allowed per line in a multi-line function call (reported by phpcs: PSR2.Methods.FunctionCallSignature.MultipleArguments)

Check failure on line 238 in src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php

View workflow job for this annotation

GitHub Actions / PHP: 8.2 Contao: ~4.13.0

Only one argument is allowed per line in a multi-line function call (reported by phpcs: PSR2.Methods.FunctionCallSignature.MultipleArguments)
[
'%property%' => $property->getLabel() ?: $property->getName(),
'%mode%' => $translator->translate(
'MSC.' . $inputProvider->getParameter('mode') . 'Selected',
'default'
)
]
)
);

Expand Down Expand Up @@ -392,7 +397,7 @@ protected function renderTemplate(ContaoBackendViewTemplate $template, Environme
\sprintf(
'%s: %s',
$this->translate('MSC.' . $inputProvider->getParameter('mode') . 'Selected', $languageDomain),
$this->translate('MSC.edit_all_select_properties', $languageDomain)
$this->translate('MSC.edit_all_select_properties', 'default')
)
)
->set('mode', 'none')
Expand Down Expand Up @@ -436,7 +441,7 @@ protected function getSelectButtons(EnvironmentInterface $environment)
'<div class="tl_submit_container">' .
'<input class="%s" value="%s" onclick="%s">' .
'</div>',
StringUtil::specialchars($this->translate('MSC.nothingSelect', $languageDomain)),
StringUtil::specialchars($this->translate('MSC.nothingSelect','default')),

Check failure on line 444 in src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php

View workflow job for this annotation

GitHub Actions / PHP: 8.1 Contao: ~4.13.0

No space found after comma in argument list (reported by phpcs: Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma)

Check failure on line 444 in src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php

View workflow job for this annotation

GitHub Actions / PHP: 8.2 Contao: ~4.13.0

No space found after comma in argument list (reported by phpcs: Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma)

Check failure on line 444 in src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php

View workflow job for this annotation

GitHub Actions / PHP: 8.1 Contao: ~4.13.0

No space found after comma in argument list (reported by phpcs: Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma)

Check failure on line 444 in src/Contao/View/Contao2BackendView/ActionHandler/MultipleHandler/SelectPropertyAllHandler.php

View workflow job for this annotation

GitHub Actions / PHP: 8.2 Contao: ~4.13.0

No space found after comma in argument list (reported by phpcs: Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma)
'tl_submit',
StringUtil::specialchars($this->translate('MSC.close', $languageDomain)),
'BackendGeneral.hideMessage(); return false;'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2023 Contao Community Alliance.
* (c) 2013-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -16,7 +16,7 @@
* @author Sven Baumann <[email protected]>
* @author David Molineus <[email protected]>
* @author Ingolf Steinhardt <[email protected]>
* @copyright 2013-2023 Contao Community Alliance.
* @copyright 2013-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand Down Expand Up @@ -354,7 +354,7 @@ protected function process(Action $action, EnvironmentInterface $environment)
$template
->set('languages', $controller->getSupportedLanguages($model->getId()))
->set('currentLanguage', $dataProvider->getCurrentLanguage())
->set('languageSubmit', $translator->translate('MSC.showSelected'))
->set('languageSubmit', $translator->translate('MSC.showSelected', 'default'))
->set('backBT', StringUtil::specialchars($translator->translate('MSC.backBT')))
->set('REQUEST_TOKEN', $this->tokenManager->getToken($this->tokenName));
} else {
Expand Down
18 changes: 9 additions & 9 deletions src/Contao/View/Contao2BackendView/ButtonRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,49 +69,49 @@ class ButtonRenderer
*
* @var list<string>
*/
private $circularModelIds;
private array $circularModelIds;

/**
* The clipboard items in use.
*
* @var list<ItemInterface>
*/
private $clipboardItems;
private array $clipboardItems;

/**
* The models for the clipboard items.
*
* @var CollectionInterface
*/
private $clipboardModels;
private CollectionInterface $clipboardModels;

/**
* The clipboard in use.
*
* @var CommandCollectionInterface
*/
private $commands;
private CommandCollectionInterface $commands;

/**
* The environment.
*
* @var EnvironmentInterface
*/
private $environment;
private EnvironmentInterface $environment;

/**
* The event dispatcher.
*
* @var EventDispatcherInterface
*/
private $eventDispatcher;
private EventDispatcherInterface $eventDispatcher;

/**
* The translator in use.
*
* @var TranslatorInterface
*/
private $translator;
private TranslatorInterface $translator;

/**
* Create a new instance.
Expand Down Expand Up @@ -369,8 +369,8 @@ private function buildCommand($command, $model, $previous, $next, $isCircularRef
'title="%s" class="%s"',
StringUtil::specialchars($this->translator->translate(
'MSC.dc_general_disabled',
'contao_default',
[$buttonEvent->getTitle()]
'default',
['%title%' => $buttonEvent->getTitle()]
)),
'cursor_disabled'
)
Expand Down
8 changes: 4 additions & 4 deletions src/Contao/View/Contao2BackendView/EditMask.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2023 Contao Community Alliance.
* (c) 2013-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -18,7 +18,7 @@
* @author Stefan Heimes <[email protected]>
* @author Sven Baumann <[email protected]>
* @author Richard Henkenjohann <[email protected]>
* @copyright 2013-2023 Contao Community Alliance.
* @copyright 2013-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand Down Expand Up @@ -884,7 +884,7 @@ protected function allValuesUnique()
if (!$dataProvider->isUniqueValue($propertyName, $value, $this->model->getId())) {
$editInformation->setModelError(
$this->model,
[$translator->translate('MSC.not_unique', null, [$propertyName])],
[$translator->translate('MSC.not_unique', 'default', ['%property%' => $propertyName])],
$definition
);

Expand Down Expand Up @@ -1039,7 +1039,7 @@ private function executeMultiLanguage(ContaoBackendViewTemplate $template)
$template
->set('languages', $controller->getSupportedLanguages($this->model->getId()))
->set('language', $dataProvider->getCurrentLanguage())
->set('languageSubmit', $translator->translate('MSC.showSelected'))
->set('languageSubmit', $translator->translate('MSC.showSelected', 'default'))
->set('languageHeadline', $languages[$dataProvider->getCurrentLanguage()] ?? '');

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private function createSubHeadline(string $status, GetEditMaskSubHeadlineEvent $
if ($status !== $headline) {
$subHeadline = $headline;
} else {
$subHeadline = $translator->translate('MSC.' . $status, null, [$event->getModel()->getId()]);
$subHeadline = $translator->translate('MSC.' . $status, 'default', [$event->getModel()->getId()]);
}

$event->setHeadline($subHeadline);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2023 Contao Community Alliance.
* (c) 2013-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,7 +12,8 @@
*
* @package contao-community-alliance/dc-general
* @author Sven Baumann <[email protected]>
* @copyright 2013-2023 Contao Community Alliance.
* @author Ingolf Steinhardt <[email protected]>
* @copyright 2013-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand Down Expand Up @@ -57,7 +58,7 @@ public function handleEvent(GetSelectModeButtonsEvent $event)
'<div class="tl_submit_container">' .
'<input type="submit" name="close" class="%s" value="%s" onclick="%s">' .
'</div>',
StringUtil::specialchars($translator->translate('MSC.nothingSelect', 'contao_default')),
StringUtil::specialchars($translator->translate('MSC.nothingSelect', 'default')),
'tl_submit',
StringUtil::specialchars($translator->translate('MSC.close', 'contao_default')),
'this.blur(); BackendGeneral.hideMessage(); return false;'
Expand All @@ -74,8 +75,8 @@ public function handleEvent(GetSelectModeButtonsEvent $event)
'models[]',
$confirmMessage,
StringUtil::specialchars($translator->translate('MSC.delAllConfirm', 'contao_default')),
StringUtil::specialchars($translator->translate('MSC.confirmOk', 'contao_default')),
StringUtil::specialchars($translator->translate('MSC.confirmAbort', 'contao_default'))
StringUtil::specialchars($translator->translate('MSC.confirmOk', 'default')),
StringUtil::specialchars($translator->translate('MSC.confirmAbort', 'default'))
);

$buttons['delete'] = \sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2023 Contao Community Alliance.
* (c) 2013-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -17,7 +17,7 @@
* @author Sven Baumann <[email protected]>
* @author Ingolf Steinhardt <[email protected]>
* @author Cliff Parnitzky <[email protected]>
* @copyright 2013-2023 Contao Community Alliance.
* @copyright 2013-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand Down Expand Up @@ -272,7 +272,7 @@ private function formatByWeekGrouping(int $value): string
return '-';
}

$event = new ParseDateEvent($value, $this->translator->translate('MSC.week_format'));
$event = new ParseDateEvent($value, $this->translator->translate('MSC.week_format', 'default'));
$this->dispatcher->dispatch($event, ContaoEvents::DATE_PARSE);

return $event->getResult();
Expand Down
14 changes: 10 additions & 4 deletions src/Contao/View/Contao2BackendView/TreePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2023 Contao Community Alliance.
* (c) 2013-2024 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -19,7 +19,7 @@
* @author Ingolf Steinhardt <[email protected]>
* @author David Molineus <[email protected]>
* @author Kim Wormer <[email protected]>
* @copyright 2013-2023 Contao Community Alliance.
* @copyright 2013-2024 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand Down Expand Up @@ -645,7 +645,10 @@ public function generate()
/** @psalm-suppress PropertyNotSetInConstructor */
->set('class', ($this->strClass ? ' ' . $this->strClass : ''))
->set('icon', $icon->getHtml())
->set('title', $translator->translate($this->title ?: 'MSC.treePicker', null, [$this->sourceName]))
->set(
'title',
$translator->translate($this->title ?: 'MSC.treePicker', 'default', ['%table%' => $this->sourceName])
)
->set('changeSelection', $translator->translate('MSC.changeSelection'))
->set('dragItemsHint', $translator->translate('MSC.dragItemsHint'))
->set('fieldType', $this->fieldType)
Expand Down Expand Up @@ -909,7 +912,10 @@ public function generatePopup()
/** @psalm-suppress PropertyNotSetInConstructor */
->set('class', ($this->strClass ? ' ' . $this->strClass : ''))
->set('icon', $icon->getHtml())
->set('title', $translator->translate($this->title ?: 'MSC.treePicker', null, [$this->sourceName]))
->set(
'title',
$translator->translate($this->title ?: 'MSC.treePicker', 'default', ['%table%' => $this->sourceName])
)
->set('fieldType', $this->fieldType)
->set('resetSelected', $translator->translate('MSC.resetSelected'))
->set('selectAll', $translator->translate('MSC.selectAll'))
Expand Down
Loading

0 comments on commit 85b406b

Please sign in to comment.