From 633e7421e15fda940a8438423e9c4761bfc54ed1 Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Tue, 26 Jul 2016 19:02:31 +0200 Subject: [PATCH] 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 --- extension.json | 3 +++ i18n/en.json | 11 ++++++----- i18n/qqq.json | 11 ++++++----- modules/ext.RevisionSlider.RevisionListView.js | 18 +++++++++++++----- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/extension.json b/extension.json index 315ead32..dc1d903e 100644 --- a/extension.json +++ b/extension.json @@ -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", diff --git a/i18n/en.json b/i18n/en.json index f86e3e0d..d1058e9c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -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": "Date: $1", - "revisionslider-label-page-size": "Page size: $1 {{PLURAL:$2|byte|bytes}}", - "revisionslider-label-change-size": "Change size: $1 {{PLURAL:$2|byte|bytes}}", - "revisionslider-label-comment": "Comment: ", - "revisionslider-label-username": "{{GENDER:$2|Username}}: [[$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.", diff --git a/i18n/qqq.json b/i18n/qqq.json index 24d86d57..c4c851c0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -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.", diff --git a/modules/ext.RevisionSlider.RevisionListView.js b/modules/ext.RevisionSlider.RevisionListView.js index e52ef0a4..502045ba 100644 --- a/modules/ext.RevisionSlider.RevisionListView.js +++ b/modules/ext.RevisionSlider.RevisionListView.js @@ -139,7 +139,8 @@ var $tooltip = $( '
' ) .append( $( '

' ).append( - mw.message( 'revisionslider-label-date', rev.getFormattedDate() ).parseDom() + $( '' ).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 $( '' ).append( $( '

' ).append( - mw.message( 'revisionslider-label-username', this.stripInvalidCharacters( userString ), userGender, this.getUserPage( userString ) ).parseDom() + $( '' ).text( mw.msg( 'revisionslider-label-username', userGender ) + mw.msg( 'colon-separator' ) ), + $( '' ).addClass( 'mw-userlink' ).attr( 'href', mw.util.getUrl( this.getUserPage( userString ) ) ).text( this.stripInvalidCharacters( userString ) ) ) ); }, @@ -201,7 +203,7 @@ return $( '' ).append( $( '

' ).append( - $( '' ).text( mw.message( 'revisionslider-label-comment' ).text() ), + $( '' ).text( mw.msg( 'revisionslider-label-comment' ) + mw.msg( 'colon-separator' ) ), $( '' ).append( rev.getParsedComment() ) @@ -217,7 +219,10 @@ */ makePageSizeLine: function ( size ) { return $( '

' ).append( - mw.message( 'revisionslider-label-page-size', mw.language.convertNumber( size ), size ).parseDom() + $( '' ).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 $( '

' ).append( - mw.message( 'revisionslider-label-change-size', $changeNumber, relativeSize ).parseDom() + $( '' ).text( mw.msg( 'revisionslider-label-change-size' ) + mw.msg( 'colon-separator' ) ), + $changeNumber, + mw.msg( 'word-separator' ), + mw.msg( 'revisionslider-bytes', relativeSize ) ); } } );