Skip to content

Commit 4314e47

Browse files
bembelimenwilsonge
authored andcommitted
[4.0] Translate stages via language files (#21506)
* Make states translatable * Fix double factory * Fix missing translations Thanks @infograf768 * Clean up variables + use * state => stage * Escape after Text::_(...) * Add missing Text::_(...) * postgresql & update * update mysql * update postgresql
1 parent bec4cd0 commit 4314e47

File tree

10 files changed

+36
-30
lines changed

10 files changed

+36
-30
lines changed

administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-05-15.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ CREATE TABLE IF NOT EXISTS `#__workflow_stages` (
7373
--
7474

7575
INSERT INTO `#__workflow_stages` (`id`, `asset_id`, `ordering`, `workflow_id`, `published`, `title`, `description`, `condition`, `default`) VALUES
76-
(1, 0, 1, 1, 1, 'Unpublished', '', 0, 0),
77-
(2, 0, 2, 1, 1, 'Published', '', 1, 1),
78-
(3, 0, 3, 1, 1, 'Trashed', '', -2, 0),
79-
(4, 0, 4, 1, 1, 'Archived', '', 2, 0);
76+
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 0),
77+
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 1),
78+
(3, 0, 3, 1, 1, 'JTRASHED', '', -2, 0),
79+
(4, 0, 4, 1, 1, 'JARCHIVED', '', 2, 0);
8080

8181
--
8282
-- Table structure for table `#__workflow_transitions`

administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-05-15.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ CREATE INDEX "#__workflow_stages_idx_default" ON "#__workflow_stages" ("default"
7373
--
7474

7575
INSERT INTO "#__workflow_stages" ("id", "asset_id", "ordering", "workflow_id", "published", "title", "description", "condition", "default") VALUES
76-
(1, 0, 1, 1, 1, 'Unpublished', '', 0, 0),
77-
(2, 0, 2, 1, 1, 'Published', '', 1, 1),
78-
(3, 0, 3, 1, 1, 'Trashed', '', -2, 0),
79-
(4, 0, 4, 1, 1, 'Archived', '', 2, 0);
76+
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 0),
77+
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 1),
78+
(3, 0, 3, 1, 1, 'JTRASHED', '', -2, 0),
79+
(4, 0, 4, 1, 1, 'JARCHIVED', '', 2, 0);
8080

8181
--
8282
-- Table structure for table "#__workflow_transitions"

administrator/components/com_content/tmpl/articles/default.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
$hasTransitions = count($transitions) > 0;
166166

167167
$default = [
168-
JHtml::_('select.option', '', $this->escape($item->stage_title)),
168+
JHtml::_('select.option', '', $this->escape(Text::_($item->stage_title))),
169169
JHtml::_('select.option', '-1', '--------', ['disable' => true])
170170
];
171171

@@ -222,7 +222,7 @@
222222
<span class="icon-<?php echo $icon; ?>"></span>
223223
<?php endif; ?>
224224
</div>
225-
<div class="mr-auto"><?php echo $this->escape($item->stage_title); ?></div>
225+
<div class="mr-auto"><?php echo $this->escape(Text::_($item->stage_title)); ?></div>
226226
<?php if ($hasTransitions) : ?>
227227
<div class="d-none">
228228
<?php

administrator/components/com_workflow/forms/transition.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
required="true"
2626
sql_select="id as value, title as from_stage_id"
2727
sql_from="#__workflow_stages"
28+
translate="true"
2829
>
2930
<option value="-1">JALL</option>
3031
</field>
@@ -35,6 +36,7 @@
3536
required="true"
3637
sql_select="id as value, title as to_stage_id"
3738
sql_from="#__workflow_stages"
39+
translate="true"
3840
/>
3941
<field
4042
name="description"

administrator/components/com_workflow/tmpl/stages/default.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*/
1212
defined('_JEXEC') or die;
1313

14-
use Joomla\CMS\Language\Text;
1514
use Joomla\CMS\HTML\HTMLHelper;
15+
use Joomla\CMS\Language\Text;
1616
use Joomla\CMS\Router\Route;
1717
use Joomla\CMS\Session\Session;
1818
use Joomla\CMS\Factory;
@@ -120,11 +120,11 @@
120120
<th scope="row">
121121
<?php if ($canEdit) : ?>
122122
<?php $editIcon = '<span class="fa fa-pencil-square mr-2" aria-hidden="true"></span>'; ?>
123-
<a href="<?php echo $edit; ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape(addslashes($item->title)); ?>">
124-
<?php echo $editIcon; ?><?php echo $item->title; ?>
123+
<a href="<?php echo $edit; ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape(addslashes(Text::_($item->title))); ?>">
124+
<?php echo $editIcon; ?><?php echo $this->escape(Text::_($item->title)); ?>
125125
</a>
126126
<?php else: ?>
127-
<?php echo $item->title; ?>
127+
<?php echo $this->escape(Text::_($item->title)); ?>
128128
<?php endif; ?>
129129
</th>
130130
<td class="text-center">

administrator/components/com_workflow/tmpl/transitions/default.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
HTMLHelper::_('behavior.tooltip');
2222
HTMLHelper::_('behavior.multiselect');
2323

24-
$user = Factory::getUser();
24+
$user = Factory::getUser();
2525

2626
$listOrder = $this->escape($this->state->get('list.ordering'));
2727
$listDirn = $this->escape($this->state->get('list.direction'));
@@ -115,7 +115,7 @@
115115
<th scope="row">
116116
<?php if ($canEdit) : ?>
117117
<?php $editIcon = '<span class="fa fa-pencil-square mr-2" aria-hidden="true"></span>'; ?>
118-
<a href="<?php echo $edit; ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape(addslashes($item->title)); ?>">
118+
<a href="<?php echo $edit; ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape(addslashes(Text::_($item->title))); ?>">
119119
<?php echo $editIcon; ?><?php echo $item->title; ?>
120120
</a>
121121
<?php else: ?>
@@ -126,11 +126,11 @@
126126
<?php if ($item->from_stage_id < 0) : ?>
127127
<?php echo Text::_('JALL'); ?>
128128
<?php else : ?>
129-
<?php echo $item->from_stage; ?>
129+
<?php echo $this->escape(Text::_($item->from_stage)); ?>
130130
<?php endif; ?>
131131
</td>
132132
<td class="text-center">
133-
<?php echo $this->escape($item->to_stage); ?>
133+
<?php echo $this->escape(Text::_($item->to_stage)); ?>
134134
</td>
135135
<td class="text-right">
136136
<?php echo $item->id; ?>

installation/sql/mysql/joomla.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,10 +2007,10 @@ CREATE TABLE IF NOT EXISTS `#__workflow_stages` (
20072007
--
20082008

20092009
INSERT INTO `#__workflow_stages` (`id`, `asset_id`, `ordering`, `workflow_id`, `published`, `title`, `description`, `condition`, `default`) VALUES
2010-
(1, 57, 1, 1, 1, 'Unpublished', '', 0, 0),
2011-
(2, 58, 2, 1, 1, 'Published', '', 1, 1),
2012-
(3, 59, 3, 1, 1, 'Trashed', '', -2, 0),
2013-
(4, 60, 4, 1, 1, 'Archived', '', 2, 0);
2010+
(1, 57, 1, 1, 1, 'JUNPUBLISHED', '', '0', 0),
2011+
(2, 58, 2, 1, 1, 'JPUBLISHED', '', '1', 1),
2012+
(3, 59, 3, 1, 1, 'JTRASHED', '', '-2', 0),
2013+
(4, 60, 4, 1, 1, 'JARCHIVED', '', '2', 0);
20142014

20152015
--
20162016
-- Table structure for table `#__workflow_transitions`

installation/sql/postgresql/joomla.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,10 +2009,10 @@ CREATE INDEX "#__workflow_stages_idx_default" ON "#__workflow_stages" ("default"
20092009
--
20102010

20112011
INSERT INTO "#__workflow_stages" ("id", "asset_id", "ordering", "workflow_id", "published", "title", "description", "condition", "default") VALUES
2012-
(1, 0, 1, 1, 1, 'Unpublished', '', 0, 0),
2013-
(2, 0, 2, 1, 1, 'Published', '', 1, 1),
2014-
(3, 0, 3, 1, 1, 'Trashed', '', -2, 0),
2015-
(4, 0, 4, 1, 1, 'Archived', '', 2, 0);
2012+
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 0),
2013+
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 1),
2014+
(3, 0, 3, 1, 1, 'JTRASHED', '', -2, 0),
2015+
(4, 0, 4, 1, 1, 'JARCHIVED', '', 2, 0);
20162016

20172017
SELECT setval('#__workflow_stages_id_seq', 5, false);
20182018

libraries/src/Form/Field/TransitionField.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Joomla\CMS\Factory;
1414
use Joomla\CMS\Form\FormHelper;
1515
use Joomla\CMS\Workflow\Workflow;
16+
use Joomla\CMS\HTML\HTMLHelper;
17+
use Joomla\CMS\Language\Text;
1618
use Joomla\Utilities\ArrayHelper;
1719

1820
FormHelper::loadFieldClass('list');
@@ -68,7 +70,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
6870
/**
6971
* Method to get a list of options for a list input.
7072
*
71-
* @return array An array of JHtml options.
73+
* @return array An array of HTMLHelper options.
7274
*
7375
* @since __DEPLOY_VERSION__
7476
*/
@@ -134,13 +136,13 @@ function ($item) use ($user, $extension)
134136

135137
$workflowName = $db->setQuery($query)->loadResult();
136138

137-
$default = [\JHtml::_('select.option', '', $workflowName)];
139+
$default = [HTMLHelper::_('select.option', '', Text::_($workflowName))];
138140

139141
$options = array_merge(parent::getOptions(), $items);
140142

141143
if (count($options))
142144
{
143-
$default[] = \JHtml::_('select.option', '-1', '--------', ['disable' => true]);
145+
$default[] = HTMLHelper::_('select.option', '-1', '--------', ['disable' => true]);
144146
}
145147

146148
// Merge with defaults

libraries/src/Form/Field/WorkflowstageField.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
defined('_JEXEC') or die;
1212

1313
use Joomla\CMS\Factory;
14+
use Joomla\CMS\Form\Field\GroupedlistField;
1415
use Joomla\CMS\HTML\HTMLHelper;
16+
use Joomla\CMS\Language\Text;
1517

1618
/**
1719
* Workflow Stages field.
@@ -124,7 +126,7 @@ protected function getGroups()
124126
$workflowStages[$workflowStageKey] = array();
125127
}
126128

127-
$workflowStages[$workflowStageKey][] = HTMLHelper::_('select.option', $stage->workflow_stage_id, $stage->workflow_stage_title);
129+
$workflowStages[$workflowStageKey][] = HTMLHelper::_('select.option', $stage->workflow_stage_id, Text::_($stage->workflow_stage_title));
128130
}
129131

130132
// Merge any additional options in the XML definition.

0 commit comments

Comments
 (0)