From 07dedecaae0f39810a3bc11ba927db895f60183a Mon Sep 17 00:00:00 2001 From: Martin B Date: Tue, 16 Apr 2024 15:22:26 +0100 Subject: [PATCH] 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 * 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 * Fix composer requiring permission for plugin * Update src/SpecialPage/SpecialResourceLoaderArticles.php * Update sql/resourceloaderarticlesPriorityMigration.sql Co-authored-by: Alex Winkler * Update sql/resourceloaderarticlesPriorityMigration.sql Co-authored-by: Martin B * make line shorter by cutting down comment * Update SpecialResourceLoaderArticles.php * Add i18n to resource types * fix weird upstream merge --------- Co-authored-by: Alex Winkler --- i18n/en.json | 3 +++ .../SpecialResourceLoaderArticles.php | 24 +++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index dcb371b..fc7a918 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -21,6 +21,9 @@ "resourceloaderarticles-priority": "Priority", "resourceloaderarticles-id": "ID", + "resourceloaderarticles-resourcetype-script": "JavaScript", + "resourceloaderarticles-resourcetype-style": "Style Sheet", + "resourceloaderarticles-error-page-empty": "The page parameter cannot be empty!", "resourceloaderarticles-error-page-invalid": "The page name is invalid!", "resourceloaderarticles-error-priority-empty": "The priority parameter cannot be empty!", diff --git a/src/SpecialPage/SpecialResourceLoaderArticles.php b/src/SpecialPage/SpecialResourceLoaderArticles.php index cdf7c18..baeb486 100644 --- a/src/SpecialPage/SpecialResourceLoaderArticles.php +++ b/src/SpecialPage/SpecialResourceLoaderArticles.php @@ -83,7 +83,11 @@ private function listPages() { $deleteTitle = Title::newFromText( 'ResourceLoaderArticles/delete/' . $row->rla_id, NS_SPECIAL ); $editTitle = Title::newFromText( 'ResourceLoaderArticles/edit/' . $row->rla_id, NS_SPECIAL ); if ( $prevResType !== $row->rla_type ) { - $output->addHTML( "{ $row->rla_type }s" ); + $output->addHTML( + '' + . $this->msg( 'resourceloaderarticles-resourcetype-' . $row->rla_type )->text() + . '' + ); $prevResType = $row->rla_type; } $output->addHTML( @@ -121,9 +125,9 @@ private function addPage() { 'Type' => [ 'class' => 'HTMLSelectField', 'label' => 'Select an option', - 'options' => [ - 'JavaScript' => 'script', - 'CSS' => 'style', + 'options-messages' => [ + 'resourceloaderarticles-resourcetype-script' => 'script', + 'resourceloaderarticles-resourcetype-style' => 'style', ], ], 'Priority' => [ @@ -240,9 +244,9 @@ private function editPage( $id ) { 'Type' => [ 'class' => 'HTMLSelectField', 'label' => 'Select an option', - 'options' => [ - 'JavaScript' => 'script', - 'CSS' => 'style', + 'options-messages' => [ + 'resourceloaderarticles-resourcetype-script' => 'script', + 'resourceloaderarticles-resourcetype-style' => 'style', ], 'default' => $row->rla_type, ], @@ -366,9 +370,9 @@ private function deletePage( $id ) { 'Type' => [ 'class' => 'HTMLSelectField', 'label' => 'Select an option', - 'options' => [ - 'JavaScript' => 'script', - 'CSS' => 'style', + 'options-messages' => [ + 'resourceloaderarticles-resourcetype-script' => 'script', + 'resourceloaderarticles-resourcetype-style' => 'style', ], 'disabled' => true, 'default' => $row->rla_type,