From: Timo Tijhof Date: Tue, 21 Aug 2018 04:45:43 +0000 (+0100) Subject: jquery.accessKeyLabel: Optimise by using mw.message().plain() X-Git-Tag: 1.34.0-rc.0~4349^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=504707af186e3b8d286a8455845d56f6f7362e24;p=lhc%2Fweb%2Fwiklou.git jquery.accessKeyLabel: Optimise by using mw.message().plain() Avoids invoking mw.message#text, which uses the parser() of jqueryMsg, twice for each call to jquery.accessKeyLabel. These two messages do not contain any wikitext features, and are not expected to need them in the future. To make this explicit, add `{{format|plain}}` to their documentation, and change the code to use plain(). Bug: T202357 Change-Id: I642f09afda4a93a1208550d44072f0909dcabdd0 --- diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 4b1717d900..b6558b690d 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -3874,11 +3874,11 @@ "colon-separator": "{{optional}}\nChange it only if your language uses another character for ':' or it needs an extra space before the colon.", "autocomment-prefix": "{{notranslate}}", "pipe-separator": "{{optional}}", - "word-separator": "{{optional}}\nThis is a string which is (usually) put between words of the language. It is used, e.g. when messages are concatenated (appended to each other). Note that you must express a space as html entity   because the editing and updating process strips leading and trailing spaces from messages.\n\nMost languages use a space, but some Asian languages, such as Thai and Chinese, do not.", + "word-separator": "{{optional}}\nThis is a string which is (usually) put between words of the language. It is used, e.g. when messages are concatenated (appended to each other). Note that you must express a space as html entity   because the editing and updating process strips leading and trailing spaces from messages.\n\nMost languages use a space, but some Asian languages, such as Thai and Chinese, do not.\n{{Format|plain}}", "ellipsis": "{{optional}}", "percent": "{{optional}}", "parentheses": "{{optional}}", - "brackets": "{{Optional}}", + "brackets": "{{Optional}}\n{{Format|plain}}", "quotation-marks": "Quotation marks, for quoting, sometimes titles etc., depending on the language.\n\nSee: [[w:Non-English usage of quotation marks|Non-English usage of quotation marks on Wikipedia]].\n\nParameters:\n* $1 - text to be wrapped in quotation marks", "imgmultipageprev": "{{Identical|Previous page}}", "imgmultipagenext": "{{Identical|Next page}}", diff --git a/resources/src/jquery/jquery.accessKeyLabel.js b/resources/src/jquery/jquery.accessKeyLabel.js index 91b7035955..674f62cd74 100644 --- a/resources/src/jquery/jquery.accessKeyLabel.js +++ b/resources/src/jquery/jquery.accessKeyLabel.js @@ -128,7 +128,8 @@ * @param {HTMLElement} titleElement Element with the title to update (may be the same as `element`) */ function updateTooltipOnElement( element, titleElement ) { - var oldTitle, parts, regexp, newTitle, accessKeyLabel; + var oldTitle, parts, regexp, newTitle, accessKeyLabel, + separatorMsg = mw.message( 'word-separator' ).plain(); oldTitle = titleElement.title; if ( !oldTitle ) { @@ -136,14 +137,14 @@ return; } - parts = ( mw.msg( 'word-separator' ) + mw.msg( 'brackets' ) ).split( '$1' ); + parts = ( separatorMsg + mw.message( 'brackets' ).plain() ).split( '$1' ); regexp = new RegExp( parts.map( mw.RegExp.escape ).join( '.*?' ) + '$' ); newTitle = oldTitle.replace( regexp, '' ); accessKeyLabel = getAccessKeyLabel( element ); if ( accessKeyLabel ) { // Should be build the same as in Linker::titleAttrib - newTitle += mw.msg( 'word-separator' ) + mw.msg( 'brackets', accessKeyLabel ); + newTitle += separatorMsg + mw.message( 'brackets', accessKeyLabel ).plain(); } if ( oldTitle !== newTitle ) { titleElement.title = newTitle;