Fix incorrect uses of translation around sprintf

This commit is contained in:
Markus Frosch 2017-11-09 14:17:46 +01:00 committed by Johannes Meyer
parent 67e207f781
commit 2493cb8d63
4 changed files with 27 additions and 23 deletions

View File

@ -215,7 +215,7 @@ class NavigationConfigForm extends ConfigForm
foreach ($this->getShareConfig($type) as $sectionName => $sectionConfig) { foreach ($this->getShareConfig($type) as $sectionName => $sectionConfig) {
if ($sectionName !== $this->itemToLoad if ($sectionName !== $this->itemToLoad
&& $sectionConfig->owner === ($owner ?: $this->getUser()->getUsername()) && $sectionConfig->owner === ($owner ?: $this->getUser()->getUsername())
&& !in_array($sectionName, $children, true) && ! in_array($sectionName, $children, true)
) { ) {
$names[] = $sectionName; $names[] = $sectionName;
} }
@ -223,7 +223,7 @@ class NavigationConfigForm extends ConfigForm
foreach ($this->getUserConfig($type) as $sectionName => $sectionConfig) { foreach ($this->getUserConfig($type) as $sectionName => $sectionConfig) {
if ($sectionName !== $this->itemToLoad if ($sectionName !== $this->itemToLoad
&& !in_array($sectionName, $children, true) && ! in_array($sectionName, $children, true)
) { ) {
$names[] = $sectionName; $names[] = $sectionName;
} }
@ -363,8 +363,8 @@ class NavigationConfigForm extends ConfigForm
$shared = false; $shared = false;
if ($this->hasBeenShared($name)) { if ($this->hasBeenShared($name)) {
if (isset($data['parent']) && $data['parent'] if (isset($data['parent']) && $data['parent']
? !$this->hasBeenShared($data['parent']) ? ! $this->hasBeenShared($data['parent'])
: ((! isset($data['users']) || !$data['users']) && (! isset($data['groups']) || !$data['groups'])) : ((! isset($data['users']) || ! $data['users']) && (! isset($data['groups']) || ! $data['groups']))
) { ) {
// It is shared but shouldn't anymore // It is shared but shouldn't anymore
$config = $this->unshare($name, isset($data['parent']) ? $data['parent'] : null); $config = $this->unshare($name, isset($data['parent']) ? $data['parent'] : null);
@ -579,7 +579,7 @@ class NavigationConfigForm extends ConfigForm
) )
); );
if ((! $itemForm->requiresParentSelection() || !isset($formData['parent']) || !$formData['parent']) if ((! $itemForm->requiresParentSelection() || ! isset($formData['parent']) || ! $formData['parent'])
&& $this->getUser()->can('application/share/navigation') && $this->getUser()->can('application/share/navigation')
) { ) {
$checked = isset($formData['shared']) ? null : (isset($formData['users']) || isset($formData['groups'])); $checked = isset($formData['shared']) ? null : (isset($formData['users']) || isset($formData['groups']));
@ -719,10 +719,12 @@ class NavigationConfigForm extends ConfigForm
if (! empty($forbiddenUsers)) { if (! empty($forbiddenUsers)) {
$valid = false; $valid = false;
$this->getElement('users')->addError( $this->getElement('users')->addError(
$this->translate(sprintf( sprintf(
'You are not permitted to share this navigation item with the following users: %s', $this->translate(
'You are not permitted to share this navigation item with the following users: %s'
),
implode(', ', $forbiddenUsers) implode(', ', $forbiddenUsers)
)) )
); );
} }
} }
@ -741,10 +743,12 @@ class NavigationConfigForm extends ConfigForm
if (! empty($forbiddenGroups)) { if (! empty($forbiddenGroups)) {
$valid = false; $valid = false;
$this->getElement('groups')->addError( $this->getElement('groups')->addError(
$this->translate(sprintf( sprintf(
'You are not permitted to share this navigation item with the following groups: %s', $this->translate(
'You are not permitted to share this navigation item with the following groups: %s'
),
implode(', ', $forbiddenGroups) implode(', ', $forbiddenGroups)
)) )
); );
} }
} }

View File

@ -332,7 +332,7 @@ EOT;
$caption = t('Content'); $caption = t('Content');
} }
$label = t(sprintf('Refresh the %s', $caption)); $label = sprintf(t('Refresh the %s'), $caption);
$title = $label; $title = $label;
$tpl = str_replace( $tpl = str_replace(

View File

@ -158,11 +158,11 @@ class IdoResourcePage extends Form
$db = new DbTool($this->getValues()); $db = new DbTool($this->getValues());
$version = $db->connectToDb()->getServerVersion(); $version = $db->connectToDb()->getServerVersion();
if (version_compare($version, '9.1', '<')) { if (version_compare($version, '9.1', '<')) {
$this->error($this->translate(sprintf( $this->error(sprintf(
'The server\'s version %s is too old. The minimum required version is %s.', $this->translate('The server\'s version %s is too old. The minimum required version is %s.'),
$version, $version,
'9.1' '9.1'
))); ));
return false; return false;
} }
} }

View File

@ -141,22 +141,22 @@ class DbResourcePage extends Form
if ($this->getValue('db') === 'pgsql') { if ($this->getValue('db') === 'pgsql') {
if ($connectionError !== null) { if ($connectionError !== null) {
$this->warning($this->translate(sprintf( $this->warning(sprintf(
'Unable to check the server\'s version. This is usually not a critical error as there is' $this->translate('Unable to check the server\'s version. This is usually not a critical error'
. ' probably only access to the database permitted which does not exist yet. If you are' . ' as there is probably only access to the database permitted which does not exist yet. If you are'
. ' absolutely sure you are running PostgreSQL in a version equal to or newer than 9.1,' . ' absolutely sure you are running PostgreSQL in a version equal to or newer than 9.1,'
. ' you can skip the validation and safely proceed to the next step. The error was: %s', . ' you can skip the validation and safely proceed to the next step. The error was: %s'),
$connectionError->getMessage() $connectionError->getMessage()
))); ));
$state = false; $state = false;
} else { } else {
$version = $db->getServerVersion(); $version = $db->getServerVersion();
if (version_compare($version, '9.1', '<')) { if (version_compare($version, '9.1', '<')) {
$this->error($this->translate(sprintf( $this->error(sprintf(
'The server\'s version %s is too old. The minimum required version is %s.', $this->translate('The server\'s version %s is too old. The minimum required version is %s.'),
$version, $version,
'9.1' '9.1'
))); ));
$state = false; $state = false;
} }
} }