Remove HTML tags from i18n messages

This moves all HTML formatting out of messages and makes all
formatting happen in code. This should make work of translator
easier and the UI of the extension no longer rely on HTML tags
being included or not in i18n messages.

In particular "tooltip" rows are now generated in code, with
only their labels being translatable.

Change-Id: I2af9b9f0e231a7b2827a202d9ac7161b8c95855a
This commit is contained in:
Leszek Manicki 2016-07-26 19:02:31 +02:00
parent 9b8fc8d968
commit 633e7421e1
4 changed files with 28 additions and 15 deletions

View file

@ -121,6 +121,9 @@
"modules/ext.RevisionSlider.RevisionListView.js"
],
"messages": [
"colon-separator",
"word-separator",
"revisionslider-bytes",
"revisionslider-label-date",
"revisionslider-label-page-size",
"revisionslider-label-change-size",

View file

@ -8,11 +8,12 @@
"revisionslider-desc": "Shows a slider allowing selecting and comparing of revisions on a diff page",
"revisionslider-beta-feature-message": "RevisionSlider",
"revisionslider-beta-feature-description": "Show a revision slider when comparing two revisions of a page.",
"revisionslider-label-date": "<strong>Date:</strong> $1",
"revisionslider-label-page-size": "<strong>Page size:</strong> $1 {{PLURAL:$2|byte|bytes}}",
"revisionslider-label-change-size": "<strong>Change size:</strong> $1 {{PLURAL:$2|byte|bytes}}",
"revisionslider-label-comment": "Comment: ",
"revisionslider-label-username": "<strong>{{GENDER:$2|Username}}:</strong> [[$3|$1]]",
"revisionslider-bytes": "{{PLURAL:$1|byte|bytes}}",
"revisionslider-label-date": "Date",
"revisionslider-label-page-size": "Page size",
"revisionslider-label-change-size": "Change size",
"revisionslider-label-comment": "Comment",
"revisionslider-label-username": "{{GENDER:$1|Username}}",
"revisionslider-minoredit": "This is a minor edit",
"revisionslider-loading-placeholder": "The RevisionSlider is loading...",
"revisionslider-loading-failed": "The RevisionSlider failed to load.",

View file

@ -10,11 +10,12 @@
"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-description": "Description for the RevisionSlider Beta Feature, describing the feature that will be enabled.",
"revisionslider-label-date": "Label describing the creation date of this revision.\nParameters:\n* $1 - Creation date.\n{{Identical|Date}}",
"revisionslider-label-page-size": "Label describing the size of this revision.\nParameters:\n* $1 - Formatted page size.\n* $2 - Page size as raw number used for PLURAL.\n{{Identical|Page size}}",
"revisionslider-label-change-size": "Label describing the size of the change compared to the revision before.\nParameters:\n* $1 - Formatted change size colored with markup.\n* $2 - Change size as raw number used for PLURAL",
"revisionslider-label-comment": "Label showing the edit summary of a revision.\n{{Identical|Comment}}",
"revisionslider-label-username": "Label for the revision's author's username.\nParameters:\n* $1 - Username,\n* $2 - Gender as in user preferences (\"male\", \"female\" or \"unknown\", passed to GENDER),\n* $3 - User page or Special:Contributors subpage for IP addresses.\n\n{{Identical|Username}}",
"revisionslider-bytes": "Unit (bytes) used along with revision/change size.\n\nParameters:\n$1 - number of bytes",
"revisionslider-label-date": "Label for the creation date of the revision.",
"revisionslider-label-page-size": "Label for the size of the revision.",
"revisionslider-label-change-size": "Label for the size of the change compared to the revision before.",
"revisionslider-label-comment": "Label for the edit summary of the revision.\n{{Identical|Comment}}",
"revisionslider-label-username": "Label for the revision's author's username.\n\nParameters:\n$1 - Gender as in user preferences (suitable for GENDER)",
"revisionslider-minoredit": "Text labeling a minor edit.",
"revisionslider-loading-placeholder": "Message shown while the RevisionSlider is still loading on a diff page. Once loaded the message is removed.",
"revisionslider-loading-failed": "Message shown if the RevisionSlider fails to initially load.",

View file

@ -139,7 +139,8 @@
var $tooltip = $( '<div>' )
.append(
$( '<p>' ).append(
mw.message( 'revisionslider-label-date', rev.getFormattedDate() ).parseDom()
$( '<strong>' ).text( mw.msg( 'revisionslider-label-date' ) + mw.msg( 'colon-separator' ) ),
rev.getFormattedDate()
),
this.makeUserLine( rev.getUser(), rev.getUserGender() ),
this.makeCommentLine( rev ),
@ -176,7 +177,8 @@
userGender = 'unknown';
}
return $( '<bdi>' ).append( $( '<p>' ).append(
mw.message( 'revisionslider-label-username', this.stripInvalidCharacters( userString ), userGender, this.getUserPage( userString ) ).parseDom()
$( '<strong>' ).text( mw.msg( 'revisionslider-label-username', userGender ) + mw.msg( 'colon-separator' ) ),
$( '<a>' ).addClass( 'mw-userlink' ).attr( 'href', mw.util.getUrl( this.getUserPage( userString ) ) ).text( this.stripInvalidCharacters( userString ) )
) );
},
@ -201,7 +203,7 @@
return $( '<bdi>' ).append(
$( '<p>' ).append(
$( '<strong>' ).text( mw.message( 'revisionslider-label-comment' ).text() ),
$( '<strong>' ).text( mw.msg( 'revisionslider-label-comment' ) + mw.msg( 'colon-separator' ) ),
$( '<em>' ).append(
rev.getParsedComment()
)
@ -217,7 +219,10 @@
*/
makePageSizeLine: function ( size ) {
return $( '<p>' ).append(
mw.message( 'revisionslider-label-page-size', mw.language.convertNumber( size ), size ).parseDom()
$( '<strong>' ).text( mw.msg( 'revisionslider-label-page-size' ) + mw.msg( 'colon-separator' ) ),
mw.language.convertNumber( size ),
mw.msg( 'word-separator' ),
mw.msg( 'revisionslider-bytes', size )
);
},
@ -247,7 +252,10 @@
.text( leadingSign + mw.language.convertNumber( relativeSize ) );
return $( '<p>' ).append(
mw.message( 'revisionslider-label-change-size', $changeNumber, relativeSize ).parseDom()
$( '<strong>' ).text( mw.msg( 'revisionslider-label-change-size' ) + mw.msg( 'colon-separator' ) ),
$changeNumber,
mw.msg( 'word-separator' ),
mw.msg( 'revisionslider-bytes', relativeSize )
);
}
} );