From 28c455feafc0682de84744d3544165e03bae6fdf Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Thu, 8 Feb 2018 10:38:06 +0530 Subject: [PATCH] Custom no-results message for compact links search Bug: T182539 Change-Id: I0e3bb7104015a5244290058dc0ac5b3c17b1ea20 --- UniversalLanguageSelector.hooks.php | 3 ++- i18n/en.json | 3 ++- i18n/qqq.json | 3 ++- resources/js/ext.uls.compactlinks.js | 10 +++++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/UniversalLanguageSelector.hooks.php b/UniversalLanguageSelector.hooks.php index 3dc19ad9..3d8c9e69 100644 --- a/UniversalLanguageSelector.hooks.php +++ b/UniversalLanguageSelector.hooks.php @@ -505,7 +505,8 @@ class UniversalLanguageSelectorHooks { ], 'messages' => [ 'ext-uls-compact-link-count', - 'ext-uls-compact-link-info' + 'ext-uls-compact-link-info', + 'ext-uls-compact-no-results' ], 'localBasePath' => __DIR__ . '/resources', 'remoteExtPath' => 'UniversalLanguageSelector/resources' diff --git a/i18n/en.json b/i18n/en.json index f8b79b26..b0a7346f 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -63,5 +63,6 @@ "ext-uls-compact-link-count": "{{PLURAL:$1|One more|$1 more}}", "ext-uls-compact-link-info": "All languages (initial selection from common choices by you and others)", "prefs-languages": "Languages", - "ext-uls-compact-language-links-preference": "Use a [[$1|compact language list]], with languages relevant to you." + "ext-uls-compact-language-links-preference": "Use a [[$1|compact language list]], with languages relevant to you.", + "ext-uls-compact-no-results": "This page is not available in the language you searched for." } diff --git a/i18n/qqq.json b/i18n/qqq.json index 1d81bae3..ae59bddd 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -67,5 +67,6 @@ "ext-uls-compact-link-count": "Message next to the list of languages which indicates that there are more languages than the ones shown. Parameter $1 is the number of languages.\n\nIf your language has a singular form for number 1, then the number should be explicitly mentioned. If it's possible in your language, please write \"1 more\" or \"one more\". Another option is to write \"more\" in a way that doesn't depend on a particular number.", "ext-uls-compact-link-info": "A tooltip for a button that shows all available languages next to a short list of relevant languages.", "prefs-languages": "Field set legend for user preferences regarding display of language lists\n{{Identical|Language}}", - "ext-uls-compact-language-links-preference": "Label for compact language links user preference" + "ext-uls-compact-language-links-preference": "Label for compact language links user preference", + "ext-uls-compact-no-results": "Message shown when the language search does not have any results." } diff --git a/resources/js/ext.uls.compactlinks.js b/resources/js/ext.uls.compactlinks.js index 5391ed09..d3edf7b7 100644 --- a/resources/js/ext.uls.compactlinks.js +++ b/resources/js/ext.uls.compactlinks.js @@ -191,7 +191,15 @@ }, languages: ulsLanguageList, // Show common languages - quickList: self.getCommonLanguages( languages ) + quickList: self.getCommonLanguages( languages ), + noResultsTemplate: function () { + var $defaultTemplate = $.proxy( $.fn.lcd.defaults.noResultsTemplate, this )(); + // Customize the message + $defaultTemplate + .find( '.uls-no-results-found-title' ) + .text( mw.msg( 'ext-uls-compact-no-results' ) ); + return $defaultTemplate; + } } ); };