mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Updating bake templates and Scaffold to use less sprintf() and more complete sentences in i18n strings. This should make translations easier to do in a gender correct way. Fixes #210
This commit is contained in:
parent
afa0e6b8f9
commit
6d092552e5
5 changed files with 50 additions and 50 deletions
|
@ -27,10 +27,10 @@
|
|||
function <?php echo $admin ?>view($id = null) {
|
||||
if (!$id) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('Invalid %s', true), '<?php echo strtolower($singularHumanName) ?>'));
|
||||
$this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName) ?>', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('Invalid %s', true), '<?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('Invalid <?php echo strtolower($singularHumanName); ?>', true), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
$this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id));
|
||||
|
@ -42,14 +42,14 @@
|
|||
$this-><?php echo $currentModelName; ?>->create();
|
||||
if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('The %s has been saved', true), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('%s saved.', true), '<?php echo ucfirst(strtolower($currentModelName)); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.', true), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
} else {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.', true), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.', true));
|
||||
<?php endif; ?>
|
||||
}
|
||||
}
|
||||
|
@ -74,23 +74,23 @@
|
|||
function <?php echo $admin; ?>edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('Invalid %s', true), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName); ?>', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('Invalid %s', true), '<?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
$this->flash(sprintf(__('Invalid <?php echo strtolower($singularHumanName); ?>', true)), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('The %s has been saved', true), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved', true));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('The %s has been saved.', true), '<?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.', true), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
} else {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.', true), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.', true));
|
||||
<?php endif; ?>
|
||||
}
|
||||
}
|
||||
|
@ -117,24 +117,24 @@
|
|||
function <?php echo $admin; ?>delete($id = null) {
|
||||
if (!$id) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('Invalid id for %s', true), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('Invalid id for <?php echo strtolower($singularHumanName); ?>', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('Invalid %s', true), '<?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
$this->flash(sprintf(__('Invalid <?php echo strtolower($singularHumanName); ?>', true)), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
if ($this-><?php echo $currentModelName; ?>->delete($id)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('%s deleted', true), '<?php echo ucfirst(strtolower($singularHumanName)); ?>'));
|
||||
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('%s deleted', true), '<?php echo ucfirst(strtolower($singularHumanName)); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted', true), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('%s was not deleted', true), '<?php echo ucfirst(strtolower($singularHumanName)); ?>'));
|
||||
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted', true));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('%s was not deleted', true), '<?php echo ucfirst(strtolower($singularHumanName)); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted', true), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
<div class="<?php echo $pluralVar;?> form">
|
||||
<?php echo "<?php echo \$this->Form->create('{$modelClass}');?>\n";?>
|
||||
<fieldset>
|
||||
<legend><?php echo "<?php printf(__('" . Inflector::humanize($action) . " %s', true), __('{$singularHumanName}', true)); ?>";?></legend>
|
||||
<legend><?php printf("<?php __('%s %s'); ?>", Inflector::humanize($action), $singularHumanName); ?></legend>
|
||||
<?php
|
||||
echo "\t<?php\n";
|
||||
foreach ($fields as $field) {
|
||||
|
@ -49,14 +49,14 @@
|
|||
<?php if (strpos($action, 'add') === false): ?>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('Delete', true), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?', true), \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
|
||||
<?php endif;?>
|
||||
<li><?php echo "<?php echo \$this->Html->link(sprintf(__('List %s', true), __('{$pluralHumanName}', true)), array('action' => 'index'));?>";?></li>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('List " . $pluralHumanName . "', true), array('action' => 'index'));?>";?></li>
|
||||
<?php
|
||||
$done = array();
|
||||
foreach ($associations as $type => $data) {
|
||||
foreach ($data as $alias => $details) {
|
||||
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('List %s', true), __('" . Inflector::humanize($details['controller']) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('New %s', true), __('" . Inflector::humanize(Inflector::underscore($alias)) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
$done[] = $details['controller'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,22 +71,22 @@
|
|||
</p>
|
||||
|
||||
<div class="paging">
|
||||
<?php echo "\t<?php echo \$this->Paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>\n";?>
|
||||
<?php echo "\t<?php echo \$this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>\n";?>
|
||||
| <?php echo "\t<?php echo \$this->Paginator->numbers();?>\n"?> |
|
||||
<?php echo "\t<?php echo \$this->Paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>\n";?>
|
||||
<?php echo "\t<?php echo \$this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>\n";?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<h3><?php echo "<?php __('Actions'); ?>"; ?></h3>
|
||||
<ul>
|
||||
<li><?php echo "<?php echo \$this->Html->link(sprintf(__('New %s', true), __('{$singularHumanName}', true)), array('action' => 'add')); ?>";?></li>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('New " . $singularHumanName . "', true), array('action' => 'add')); ?>";?></li>
|
||||
<?php
|
||||
$done = array();
|
||||
foreach ($associations as $type => $data) {
|
||||
foreach ($data as $alias => $details) {
|
||||
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('List %s', true), __('" . Inflector::humanize($details['controller']) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('New %s', true), __('" . Inflector::humanize(Inflector::underscore($alias)) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
$done[] = $details['controller'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,17 +45,17 @@ foreach ($fields as $field) {
|
|||
<h3><?php echo "<?php __('Actions'); ?>"; ?></h3>
|
||||
<ul>
|
||||
<?php
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('Edit %s', true), __('{$singularHumanName}', true)), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('Delete %s', true), __('{$singularHumanName}', true)), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('List %s', true), __('{$pluralHumanName}', true)), array('action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('New %s', true), __('{$singularHumanName}', true)), array('action' => 'add')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('Edit " . $singularHumanName ."', true), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('Delete " . $singularHumanName . "', true), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . $pluralHumanName . "', true), array('action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . $singularHumanName . "', true), array('action' => 'add')); ?> </li>\n";
|
||||
|
||||
$done = array();
|
||||
foreach ($associations as $type => $data) {
|
||||
foreach ($data as $alias => $details) {
|
||||
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('List %s', true), __('" . Inflector::humanize($details['controller']) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('New %s', true), __('" . Inflector::humanize(Inflector::underscore($alias)) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
$done[] = $details['controller'];
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ foreach ($fields as $field) {
|
|||
if (!empty($associations['hasOne'])) :
|
||||
foreach ($associations['hasOne'] as $alias => $details): ?>
|
||||
<div class="related">
|
||||
<h3><?php echo "<?php printf(__('Related %s', true), __('" . Inflector::humanize($details['controller']) . "', true));?>";?></h3>
|
||||
<h3><?php echo "<?php __('Related " . Inflector::humanize($details['controller']) . "');?>";?></h3>
|
||||
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
|
||||
<dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
|
||||
<?php
|
||||
|
@ -80,7 +80,7 @@ if (!empty($associations['hasOne'])) :
|
|||
<?php echo "<?php endif; ?>\n";?>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo "<?php echo \$this->Html->link(sprintf(__('Edit %s', true), __('" . Inflector::humanize(Inflector::underscore($alias)) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('Edit " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -100,7 +100,7 @@ foreach ($relations as $alias => $details):
|
|||
$otherPluralHumanName = Inflector::humanize($details['controller']);
|
||||
?>
|
||||
<div class="related">
|
||||
<h3><?php echo "<?php printf(__('Related %s', true), __('{$otherPluralHumanName}', true));?>";?></h3>
|
||||
<h3><?php echo "<?php __('Related " . $otherPluralHumanName . "');?>";?></h3>
|
||||
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
|
||||
<table cellpadding = "0" cellspacing = "0">
|
||||
<tr>
|
||||
|
@ -139,7 +139,7 @@ echo "\t<?php endforeach; ?>\n";
|
|||
<?php echo "<?php endif; ?>\n\n";?>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo "<?php echo \$this->Html->link(sprintf(__('New %s', true), __('" . Inflector::humanize(Inflector::underscore($alias)) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -223,7 +223,7 @@ class Scaffold extends Object {
|
|||
function __scaffoldView($params) {
|
||||
if ($this->controller->_beforeScaffold('view')) {
|
||||
|
||||
$message = sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey));
|
||||
$message = __(sprintf("No id set for %s::view()", Inflector::humanize($this->modelKey), true));
|
||||
if (isset($params['pass'][0])) {
|
||||
$this->ScaffoldModel->id = $params['pass'][0];
|
||||
} elseif ($this->_validSession) {
|
||||
|
@ -303,7 +303,7 @@ class Scaffold extends Object {
|
|||
}
|
||||
|
||||
if (!$this->ScaffoldModel->exists()) {
|
||||
$message = sprintf(__("Invalid id for %s::edit()", true), Inflector::humanize($this->modelKey));
|
||||
$message = __(sprintf("Invalid id for %s::edit()", Inflector::humanize($this->modelKey), true));
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash($message);
|
||||
$this->controller->redirect($this->redirect);
|
||||
|
@ -321,9 +321,9 @@ class Scaffold extends Object {
|
|||
|
||||
if ($this->ScaffoldModel->save($this->controller->data)) {
|
||||
if ($this->controller->_afterScaffoldSave($action)) {
|
||||
$message = sprintf(__('The %1$s has been %2$s', true),
|
||||
Inflector::humanize($this->modelKey),
|
||||
$success
|
||||
$message = __(
|
||||
sprintf('The %1$s has been %2$s', Inflector::humanize($this->modelKey), $success),
|
||||
true
|
||||
);
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash($message);
|
||||
|
@ -337,9 +337,7 @@ class Scaffold extends Object {
|
|||
}
|
||||
} else {
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash(
|
||||
__('Please correct errors below.', true
|
||||
));
|
||||
$this->controller->Session->setFlash(__('Please correct errors below.', true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +376,9 @@ class Scaffold extends Object {
|
|||
*/
|
||||
function __scaffoldDelete($params = array()) {
|
||||
if ($this->controller->_beforeScaffold('delete')) {
|
||||
$message = sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey));
|
||||
$message = __(
|
||||
sprintf("No id set for %s::delete()", Inflector::humanize($this->modelKey)), true
|
||||
);
|
||||
if (isset($params['pass'][0])) {
|
||||
$id = $params['pass'][0];
|
||||
} elseif ($this->_validSession) {
|
||||
|
@ -390,9 +390,9 @@ class Scaffold extends Object {
|
|||
}
|
||||
|
||||
if ($this->ScaffoldModel->delete($id)) {
|
||||
$message = sprintf(
|
||||
__('The %1$s with id: %2$d has been deleted.', true),
|
||||
Inflector::humanize($this->modelClass), $id
|
||||
$message = __(
|
||||
sprintf('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id),
|
||||
true
|
||||
);
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash($message);
|
||||
|
@ -402,10 +402,10 @@ class Scaffold extends Object {
|
|||
return $this->_output();
|
||||
}
|
||||
} else {
|
||||
$message = sprintf(
|
||||
__('There was an error deleting the %1$s with id: %2$d', true),
|
||||
$message = __(sprintf(
|
||||
'There was an error deleting the %1$s with id: %2$d',
|
||||
Inflector::humanize($this->modelClass), $id
|
||||
);
|
||||
), true));
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash($message);
|
||||
$this->controller->redirect($this->redirect);
|
||||
|
|
Loading…
Reference in a new issue