Skip to content

Commit 07dedec

Browse files
iMarbotFO-nTTaX
andauthored
Add i18n to resource types (#10)
* Add priority functionality * Add new i18n strings * Disable fields on delete form Should just be there for information purposes. Can also be misleading if user thinks `rla_page` is used to delete and not the hidden `rla_id`. * Update sql/resourceloaderarticlesPriorityMigration.sql Co-authored-by: Alex Winkler <[email protected]> * Add priority help text Explain the load order - higher loaded first * Fix `ORDER BY` statements Also added separating header rows in the special page between scripts and styles. * Use `help-message` to get i18n key instead Co-authored-by: Alex Winkler <[email protected]> * Fix composer requiring permission for plugin * Update src/SpecialPage/SpecialResourceLoaderArticles.php * Update sql/resourceloaderarticlesPriorityMigration.sql Co-authored-by: Alex Winkler <[email protected]> * Update sql/resourceloaderarticlesPriorityMigration.sql Co-authored-by: Martin B <[email protected]> * make line shorter by cutting down comment * Update SpecialResourceLoaderArticles.php * Add i18n to resource types * fix weird upstream merge --------- Co-authored-by: Alex Winkler <[email protected]>
1 parent 5c3e5aa commit 07dedec

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

i18n/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"resourceloaderarticles-priority": "Priority",
2222
"resourceloaderarticles-id": "ID",
2323

24+
"resourceloaderarticles-resourcetype-script": "JavaScript",
25+
"resourceloaderarticles-resourcetype-style": "Style Sheet",
26+
2427
"resourceloaderarticles-error-page-empty": "The page parameter cannot be empty!",
2528
"resourceloaderarticles-error-page-invalid": "The page name is invalid!",
2629
"resourceloaderarticles-error-priority-empty": "The priority parameter cannot be empty!",

src/SpecialPage/SpecialResourceLoaderArticles.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ private function listPages() {
8383
$deleteTitle = Title::newFromText( 'ResourceLoaderArticles/delete/' . $row->rla_id, NS_SPECIAL );
8484
$editTitle = Title::newFromText( 'ResourceLoaderArticles/edit/' . $row->rla_id, NS_SPECIAL );
8585
if ( $prevResType !== $row->rla_type ) {
86-
$output->addHTML( "<tr><th colspan='6'>{ $row->rla_type }s</th></tr>" );
86+
$output->addHTML(
87+
'<tr><th colspan="6">'
88+
. $this->msg( 'resourceloaderarticles-resourcetype-' . $row->rla_type )->text()
89+
. '</th></tr>'
90+
);
8791
$prevResType = $row->rla_type;
8892
}
8993
$output->addHTML(
@@ -121,9 +125,9 @@ private function addPage() {
121125
'Type' => [
122126
'class' => 'HTMLSelectField',
123127
'label' => 'Select an option',
124-
'options' => [
125-
'JavaScript' => 'script',
126-
'CSS' => 'style',
128+
'options-messages' => [
129+
'resourceloaderarticles-resourcetype-script' => 'script',
130+
'resourceloaderarticles-resourcetype-style' => 'style',
127131
],
128132
],
129133
'Priority' => [
@@ -240,9 +244,9 @@ private function editPage( $id ) {
240244
'Type' => [
241245
'class' => 'HTMLSelectField',
242246
'label' => 'Select an option',
243-
'options' => [
244-
'JavaScript' => 'script',
245-
'CSS' => 'style',
247+
'options-messages' => [
248+
'resourceloaderarticles-resourcetype-script' => 'script',
249+
'resourceloaderarticles-resourcetype-style' => 'style',
246250
],
247251
'default' => $row->rla_type,
248252
],
@@ -366,9 +370,9 @@ private function deletePage( $id ) {
366370
'Type' => [
367371
'class' => 'HTMLSelectField',
368372
'label' => 'Select an option',
369-
'options' => [
370-
'JavaScript' => 'script',
371-
'CSS' => 'style',
373+
'options-messages' => [
374+
'resourceloaderarticles-resourcetype-script' => 'script',
375+
'resourceloaderarticles-resourcetype-style' => 'style',
372376
],
373377
'disabled' => true,
374378
'default' => $row->rla_type,

0 commit comments

Comments
 (0)