Skip to content

Commit 87c7b1a

Browse files
authored
Introduce a language aware interface (#40614)
* Introduce a language aware interface * Support in plugin * cs * Remove Factory::getLanguage in views * Remove Factory * set when available * set when available in plugin * pagenavigation * Load the language during init in install app * also base class * simplify * docs * Inject the command in finder command * no assignment in if ---------
1 parent 83dc7fa commit 87c7b1a

File tree

54 files changed

+345
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+345
-111
lines changed

administrator/components/com_admin/tmpl/help/langforum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Joomla\CMS\Factory;
1414
use Joomla\CMS\Language\Text;
1515

16-
Factory::getLanguage()->load('mod_menu', JPATH_ADMINISTRATOR);
16+
$this->getLanguage()->load('mod_menu', JPATH_ADMINISTRATOR);
1717

1818
$forumId = (int) Text::_('MOD_MENU_HELP_SUPPORT_OFFICIAL_LANGUAGE_FORUM_VALUE');
1919

administrator/components/com_categories/src/View/Categories/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function addToolbar()
172172
}
173173

174174
// Need to load the menu language file as mod_menu hasn't been loaded yet.
175-
$lang = Factory::getLanguage();
175+
$lang = $this->getLanguage();
176176
$lang->load($component, JPATH_BASE)
177177
|| $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component);
178178

administrator/components/com_categories/src/View/Category/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function addToolbar()
152152
$componentParams = ComponentHelper::getParams($component);
153153

154154
// Need to load the menu language file as mod_menu hasn't been loaded yet.
155-
$lang = Factory::getLanguage();
155+
$lang = $this->getLanguage();
156156
$lang->load($component, JPATH_BASE)
157157
|| $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component);
158158

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@
7878
?>
7979
<?php if (empty($this->items)) : ?>
8080
<div class="alert alert-info">
81-
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
82-
<?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
81+
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo $this->_('INFO'); ?></span>
82+
<?php echo $this->_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
8383
</div>
8484
<?php else : ?>
8585
<table class="table itemList" id="articleList">
8686
<caption class="visually-hidden">
87-
<?php echo Text::_('COM_CONTENT_ARTICLES_TABLE_CAPTION'); ?>,
88-
<span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>,
89-
<span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span>
87+
<?php echo $this->_('COM_CONTENT_ARTICLES_TABLE_CAPTION'); ?>,
88+
<span id="orderedBy"><?php echo $this->_('JGLOBAL_SORTED_BY'); ?> </span>,
89+
<span id="filteredBy"><?php echo $this->_('JGLOBAL_FILTERED_BY'); ?></span>
9090
</caption>
9191
<thead>
9292
<tr>
@@ -179,7 +179,7 @@
179179
if (!$canChange) {
180180
$iconClass = ' inactive';
181181
} elseif (!$saveOrder) {
182-
$iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED');
182+
$iconClass = ' inactive" title="' . $this->_('JORDERINGDISABLED');
183183
}
184184
?>
185185
<span class="sortable-handler<?php echo $iconClass ?>">
@@ -194,8 +194,8 @@
194194
<?php
195195
$options = [
196196
'transitions' => $transitions,
197-
'title' => Text::_($item->stage_title),
198-
'tip_content' => Text::sprintf('JWORKFLOW', Text::_($item->workflow_title)),
197+
'title' => $this->_($item->stage_title),
198+
'tip_content' => Text::sprintf('JWORKFLOW', $this->_($item->workflow_title)),
199199
'id' => 'workflow-' . $item->id,
200200
'task' => 'articles.runTransition'
201201
];
@@ -204,7 +204,7 @@
204204
->render(0, $i);
205205
?>
206206
<div class="small">
207-
<?php echo Text::_($item->stage_title); ?>
207+
<?php echo $this->_($item->stage_title); ?>
208208
</div>
209209
</td>
210210
<?php endif; ?>
@@ -238,7 +238,7 @@
238238
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'articles.', $canCheckin); ?>
239239
<?php endif; ?>
240240
<?php if ($canEdit || $canEditOwn) : ?>
241-
<a href="<?php echo Route::_('index.php?option=com_content&task=article.edit&id=' . $item->id); ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->title); ?>">
241+
<a href="<?php echo Route::_('index.php?option=com_content&task=article.edit&id=' . $item->id); ?>" title="<?php echo $this->_('JACTION_EDIT'); ?> <?php echo $this->escape($item->title); ?>">
242242
<?php echo $this->escape($item->title); ?></a>
243243
<?php else : ?>
244244
<span title="<?php echo Text::sprintf('JFIELD_ALIAS_LABEL', $this->escape($item->alias)); ?>"><?php echo $this->escape($item->title); ?></span>
@@ -254,14 +254,14 @@
254254
<?php
255255
$ParentCatUrl = Route::_('index.php?option=com_categories&task=category.edit&id=' . $item->parent_category_id . '&extension=com_content');
256256
$CurrentCatUrl = Route::_('index.php?option=com_categories&task=category.edit&id=' . $item->catid . '&extension=com_content');
257-
$EditCatTxt = Text::_('COM_CONTENT_EDIT_CATEGORY');
258-
echo Text::_('JCATEGORY') . ': ';
257+
$EditCatTxt = $this->_('COM_CONTENT_EDIT_CATEGORY');
258+
echo $this->_('JCATEGORY') . ': ';
259259
if ($item->category_level != '1') :
260260
if ($item->parent_category_level != '1') :
261261
echo ' &#187; ';
262262
endif;
263263
endif;
264-
if (Factory::getLanguage()->isRtl()) {
264+
if ($this->getLanguage()->isRtl()) {
265265
if ($canEditCat || $canEditOwnCat) :
266266
echo '<a href="' . $CurrentCatUrl . '" title="' . $EditCatTxt . '">';
267267
endif;
@@ -299,7 +299,7 @@
299299
endif;
300300
}
301301
if ($item->category_published < '1') :
302-
echo $item->category_published == '0' ? ' (' . Text::_('JUNPUBLISHED') . ')' : ' (' . Text::_('JTRASHED') . ')';
302+
echo $item->category_published == '0' ? ' (' . $this->_('JUNPUBLISHED') . ')' : ' (' . $this->_('JTRASHED') . ')';
303303
endif;
304304
?>
305305
</div>
@@ -314,7 +314,7 @@
314314
<?php echo $this->escape($item->author_name); ?>
315315
</a>
316316
<?php else : ?>
317-
<?php echo Text::_('JNONE'); ?>
317+
<?php echo $this->_('JNONE'); ?>
318318
<?php endif; ?>
319319
<?php if ($item->created_by_alias) : ?>
320320
<div class="smallsub"><?php echo Text::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->created_by_alias)); ?></div>
@@ -335,7 +335,7 @@
335335
<td class="small d-none d-md-table-cell text-center">
336336
<?php
337337
$date = $item->{$orderingColumn};
338-
echo $date > 0 ? HTMLHelper::_('date', $date, Text::_('DATE_FORMAT_LC4')) : '-';
338+
echo $date > 0 ? HTMLHelper::_('date', $date, $this->_('DATE_FORMAT_LC4')) : '-';
339339
?>
340340
</td>
341341
<?php if ($this->hits) : ?>
@@ -379,7 +379,7 @@
379379
'bootstrap.renderModal',
380380
'collapseModal',
381381
[
382-
'title' => Text::_('COM_CONTENT_BATCH_OPTIONS'),
382+
'title' => $this->_('COM_CONTENT_BATCH_OPTIONS'),
383383
'footer' => $this->loadTemplate('batch_footer'),
384384
],
385385
$this->loadTemplate('batch_body')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
echo ' &#187; ';
266266
endif;
267267
endif;
268-
if (Factory::getLanguage()->isRtl()) {
268+
if ($this->getLanguage()->isRtl()) {
269269
if ($canEditCat || $canEditOwnCat) :
270270
echo '<a href="' . $CurrentCatUrl . '" title="' . $EditCatTxt . '">';
271271
endif;

administrator/components/com_contenthistory/src/View/Preview/HtmlView.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
namespace Joomla\Component\Contenthistory\Administrator\View\Preview;
1212

13-
use Joomla\CMS\Factory;
1413
use Joomla\CMS\Language\Text;
1514
use Joomla\CMS\MVC\View\GenericDataException;
1615
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
@@ -55,7 +54,7 @@ public function display($tpl = null)
5554
$this->item = $this->get('Item');
5655

5756
if (false === $this->item) {
58-
Factory::getLanguage()->load('com_content', JPATH_SITE, null, true);
57+
$this->getLanguage()->load('com_content', JPATH_SITE, null, true);
5958

6059
throw new \Exception(Text::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND'), 404);
6160
}

administrator/components/com_cpanel/src/View/Cpanel/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function display($tpl = null)
7575
}
7676

7777
// Need to load the language file
78-
$lang = Factory::getLanguage();
78+
$lang = $this->getLanguage();
7979
$lang->load($component, JPATH_BASE)
8080
|| $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component);
8181
$lang->load($component);

administrator/components/com_fields/src/View/Field/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ protected function addToolbar()
107107
}
108108

109109
// Load component language file
110-
$lang = Factory::getLanguage();
110+
$lang = $this->getLanguage();
111111
$lang->load($component, JPATH_ADMINISTRATOR)
112112
|| $lang->load($component, Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component));
113113

administrator/components/com_fields/src/View/Fields/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function addToolbar()
135135
}
136136

137137
// Load extension language file
138-
$lang = Factory::getLanguage();
138+
$lang = $this->getLanguage();
139139
$lang->load($component, JPATH_ADMINISTRATOR)
140140
|| $lang->load($component, Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component));
141141

administrator/components/com_fields/src/View/Group/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function addToolbar()
127127
}
128128

129129
// Load component language file
130-
$lang = Factory::getLanguage();
130+
$lang = $this->getLanguage();
131131
$lang->load($component, JPATH_ADMINISTRATOR)
132132
|| $lang->load($component, Path::clean(JPATH_ADMINISTRATOR . '/components/' . $component));
133133

0 commit comments

Comments
 (0)