Include a number in messages showing a number with a unit

Extension should not enforce English order with number being followed
by unit "bytes" in messages related to byte size.
This also splits a message into two messages: one for page size value,
and other for change size. The latter size is signed and value to be
shown is colour-coded HTML element so it is a bit more complicated
case than the page size.

Bug: T141507
Change-Id: I96992eafd4cd8a5aed3fcd5944129bcd83139a16
This commit is contained in:
Leszek Manicki 2016-07-28 14:49:12 +02:00
parent 6aea17b627
commit 3cc218391c
4 changed files with 8 additions and 10 deletions

View file

@ -121,8 +121,8 @@
], ],
"messages": [ "messages": [
"colon-separator", "colon-separator",
"word-separator", "revisionslider-page-size",
"revisionslider-bytes", "revisionslider-change-size",
"revisionslider-label-date", "revisionslider-label-date",
"revisionslider-label-page-size", "revisionslider-label-page-size",
"revisionslider-label-change-size", "revisionslider-label-change-size",

View file

@ -8,7 +8,8 @@
"revisionslider-desc": "Shows a slider allowing selecting and comparing of revisions on a diff page", "revisionslider-desc": "Shows a slider allowing selecting and comparing of revisions on a diff page",
"revisionslider-beta-feature-message": "RevisionSlider", "revisionslider-beta-feature-message": "RevisionSlider",
"revisionslider-beta-feature-description": "Show a revision slider when comparing two revisions of a page.", "revisionslider-beta-feature-description": "Show a revision slider when comparing two revisions of a page.",
"revisionslider-bytes": "{{PLURAL:$1|byte|bytes}}", "revisionslider-page-size": "$1 {{PLURAL:$2|byte|bytes}}",
"revisionslider-change-size": "$1 {{PLURAL:$3|byte|bytes}}",
"revisionslider-label-date": "Date", "revisionslider-label-date": "Date",
"revisionslider-label-page-size": "Page size", "revisionslider-label-page-size": "Page size",
"revisionslider-label-change-size": "Change size", "revisionslider-label-change-size": "Change size",

View file

@ -10,7 +10,8 @@
"revisionslider-desc": "{{desc|name=RevisionSlider|url=https://www.mediawiki.org/wiki/Extension:RevisionSlider}}", "revisionslider-desc": "{{desc|name=RevisionSlider|url=https://www.mediawiki.org/wiki/Extension:RevisionSlider}}",
"revisionslider-beta-feature-message": "Label for the RevisionSlider Beta Feature.", "revisionslider-beta-feature-message": "Label for the RevisionSlider Beta Feature.",
"revisionslider-beta-feature-description": "Description for the RevisionSlider Beta Feature, describing the feature that will be enabled.", "revisionslider-beta-feature-description": "Description for the RevisionSlider Beta Feature, describing the feature that will be enabled.",
"revisionslider-bytes": "Unit (bytes) used along with revision/change size.\n\nParameters:\n$1 - number of bytes\n{{Identical|Byte}}", "revisionslider-page-size": "Page size after the revision.\n\nParameters:\n$1 - number of bytes formatted for output (with mw.language.converNumber)\n$2 - number of bytes, could be used with PLURAL",
"revisionslider-change-size": "Change size, ie. number of bytes added or removed in the revision.\n\nParameters:\n$1 - change size formatted for output (colour-coded HTML element, including plus or minus sign)\n$2 - change size (in bytes), can be negative\n$3 - change size (in bytes) without a sign",
"revisionslider-label-date": "Label for the creation date of the revision.\n{{Identical|Date}}", "revisionslider-label-date": "Label for the creation date of the revision.\n{{Identical|Date}}",
"revisionslider-label-page-size": "Label for the size of the revision.\n{{Identical|Page size}}", "revisionslider-label-page-size": "Label for the size of the revision.\n{{Identical|Page size}}",
"revisionslider-label-change-size": "Label for the size of the change compared to the revision before.", "revisionslider-label-change-size": "Label for the size of the change compared to the revision before.",

View file

@ -260,9 +260,7 @@
makePageSizeLine: function ( size ) { makePageSizeLine: function ( size ) {
return $( '<p>' ).append( return $( '<p>' ).append(
$( '<strong>' ).text( mw.msg( 'revisionslider-label-page-size' ) + mw.msg( 'colon-separator' ) ), $( '<strong>' ).text( mw.msg( 'revisionslider-label-page-size' ) + mw.msg( 'colon-separator' ) ),
mw.language.convertNumber( size ), mw.msg( 'revisionslider-page-size', mw.language.convertNumber( size ), size )
mw.msg( 'word-separator' ),
mw.msg( 'revisionslider-bytes', size )
); );
}, },
@ -293,9 +291,7 @@
return $( '<p>' ).append( return $( '<p>' ).append(
$( '<strong>' ).text( mw.msg( 'revisionslider-label-change-size' ) + mw.msg( 'colon-separator' ) ), $( '<strong>' ).text( mw.msg( 'revisionslider-label-change-size' ) + mw.msg( 'colon-separator' ) ),
$changeNumber, mw.message( 'revisionslider-change-size', $changeNumber, relativeSize, Math.abs( relativeSize ) ).parse()
mw.msg( 'word-separator' ),
mw.msg( 'revisionslider-bytes', relativeSize )
); );
} }
} ); } );