Skip to content

Commit

Permalink
Merge pull request #27 from Niharika29/addI18n
Browse files Browse the repository at this point in the history
Add i18n
  • Loading branch information
kaldari committed Sep 28, 2016
2 parents ecda678 + 80c58ae commit 22d401b
Show file tree
Hide file tree
Showing 15 changed files with 403 additions and 224 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ This is a web interface for [Plagiabot's Copyright RC feed](https://en.wikipedia

This application makes of use [Wikimedia-slimapp](https://github.com/wikimedia/wikimedia-slimapp) library and uses Twig as its templating library.

##### To add a new translation message:
1. Add it to en.json
2. Call it in Twig as <code>{{ '<message-key>'|message }}</code>. If the message contains any html, you need to add the <code>|raw</code> param after 'message'.
3. To use a translation message in JS, add it as a JS var in templates/base.html. Then simply access it in JS.
4. To call it in PHP:
<code>$this->i18nContext->message( '<message-key>' )</code>



3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"oyejorge/less.php": "~1.5",
"mediawiki/oauthclient": "~0.1",
"wikimedia/slimapp": "dev-master",
"addwiki/mediawiki-api-base": "~2.1"
"addwiki/mediawiki-api-base": "~2.1",
"wikimedia/simplei18n": "~1.0"
},
"autoload": {
"psr-4": {
Expand Down
71 changes: 71 additions & 0 deletions public_html/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"@metadata": {
"authors": [
"Niharika Kohli",
"MusikAnimal",
"Ryan Kaldari"
]
},
"name": "CopyPatrol",
"documentation": "Documentation",
"feedback": "Feedback",
"leaderboard": "Leaderboard",
"login": "Login",
"logout": "Logout",
"header-loggedin": "You are logged in as: $1",
"form-all": "All cases",
"form-open": "Open cases",
"form-reviewed": "Reviewed cases",
"form-mine": "My reviews",
"form-drafts": "Drafts only",
"wikiprojects": "WikiProjects",
"form-wikiprojects-placeholder": "Type WikiProject names...",
"submit": "Submit",
"page": "Page",
"diff": "Diff",
"editor": "Editor",
"review": "Review",
"review-fixed": "Page fixed",
"review-fixed-tooltip": "The edit was a copyright violation and has been reverted",
"review-false": "No action needed",
"review-false-tooltip": "The edit is a false positive, nothing needs to be done",
"review-by": "Reviewed by:",
"history": "History",
"talk": "Talk",
"contribs": "Contributions",
"record-editcount": "Edit count:",
"compare": "Compare",
"record-ithenticate": "iThenticate report",
"record-url-text": "$1 of edit ($2 words)",
"record-noeditor": "No editor found",
"record-noeditor-tooltip": "The revision may have been deleted or the data is not yet available in Labs database.",
"record-ores": "ORES score: $1",
"article": "Article",
"compare-article-loading": "Loading article revision...",
"compare-source-loading": "Loading possible copyvio source...",
"footer-loadmore": "Load More",
"footer-nomore": "No more records!",
"footer-broughtby": "Brought to you by $1",
"footer-commtech": "Community Tech",
"footer-poweredby": "Powered by $1 and $2",
"source": "Source",
"phabricator": "Phabricator",
"footer-imageattr": "Image attribution",
"lboard-title": "Leaderboard",
"lboard-week": "Cases closed in the last 7 days",
"lboard-month": "Cases closed in the last 30 days",
"lboard-alltime": "All time cases closed",
"lboard-back": "Back to CopyPatrol",
"close": "Close",
"imageattr-title": "Image attribution",
"imageattr-logo": "CopyPatrol logo",
"public-domain": "public domain",
"open-font-license": "Open Font License",
"imageattr-paragraph1": "$1 available to the $2 courtesy of $3 and the $4",
"imageattr-paragraph2": "$1 released under the $2 courtesy of $3",
"alert-testing": "This is a staging environment. Please do not use this tool to record your reviews. For the actual CopyPatrol tool, please use $1.",
"js-unauthorized": "You need to be logged in to be able to review.",
"js-dberror": "There was an error in connecting to database.",
"js-undo-own-only": "You can only undo your own reviews.",
"js-unknown-error": "An unknown error occurred when loading results. Please try again."
}
71 changes: 71 additions & 0 deletions public_html/i18n/qqq.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"@metadata": {
"authors": [
"Niharika Kohli",
"MusikAnimal",
"Ryan Kaldari"
]
},
"name": "{{Optional}}\nTitle of the application/tool",
"documentation": "Link to documentation in header\n{{Identical|Documentation}}",
"feedback": "Link to feedback in header\n{{Identical|Feedback}}",
"leaderboard": "Link to a list of the top reviewers in header",
"login": "Button label\n{{Identical|login}}",
"logout": "Button label\n{{Identical|Logout}}",
"header-loggedin": "Message to tell user who they are logged in as.\n Parameter: $1 - Wiki username.",
"form-all": "Form radio button label - show all possible records",
"form-open": "Form radio button label - show unreviewed records",
"form-reviewed": "Form radio button label - show reviewed records",
"form-mine": "Form radio button label - show records reviewed by logged in user",
"form-drafts": "Form checkbox label - show records in draft namespace",
"wikiprojects": "Title for an input box to select WikiProjects to search for - show ",
"form-wikiprojects-placeholder": "Placeholder for an input box to select WikiProjects to search",
"submit": "Form button label\n{{Identical|Submit}}",
"page": "Table column header\n{{Identical|Page}}",
"diff": "Table column header\n{{Identical|Diff}}",
"editor": "Table column header\n{{Identical|Editor}}",
"review": "Table column header",
"review-fixed": "Button label to mark a record as fixed",
"review-fixed-tooltip": "Button tooltip to show help text",
"review-false": "Button label to mark a record as not fixed",
"review-false-tooltip": "Button tooltip to show help text",
"review-by": "Label to indicate which user reviewed a record",
"history": "Link to the history page for a given page title\n{{Identical|History}}",
"talk": "Link to the talk page for a given page title\n{{Identical|Talk}}",
"contribs": "Link to the contributions history for a given page title\n{{Identical|Contributions}}",
"record-editcount": "Label to indicate number of edits a user has made",
"compare": "Button label to open a panel for text comparison between two pages",
"record-ithenticate": "Button label for a button to go to the original plagiarism report generated by Turnitin",
"record-url-text": "Label text to show amount of plagiarism.\n Parameters: $1 - Percentage of edit that was plagiarized.\n $2 - Number of words plagiarized.",
"record-noeditor": "Column text shown to user when no editor was found in database for an edit",
"record-noeditor-tooltip": "Tooltip for a text label, shown to editor to explain why no editor could be found",
"record-ores": "Ores score for a record. \n Parameters: $1 - Decimal number indicating percentage score.",
"article": "Label shown for a text box, showing an article text. \n{{Identical|Article}}",
"compare-article-loading": "Temporary text shown to user while article text loads",
"compare-source-loading": "Temporary text shown to user while copyvio text source loads",
"footer-loadmore": "Label for a button to load more records.",
"footer-nomore": "Label to indicate no more records in database.",
"footer-broughtby": "Footer text to indicate author. \n Parameters: $1 - String. Name of the team (community tech).",
"footer-commtech": "Footer text - name of team.",
"footer-poweredby": "Footer text to highlight sources used for development. \n Parameters: $1 - String('Eranbot', which maintains the database) and $2 - String('Turnitin', the service used for plagiarism detection)",
"source": "Footer link to source code for application",
"phabricator": "Footer link to phabricator workboard for application",
"footer-imageattr": "Footer link to open a pop up box to show attributions for images used in app",
"lboard-title": "Page title for leaderboard page",
"lboard-week": "Column title for number of records closed last week by each person (top 10 only)",
"lboard-month": "Column title for number of records closed last month by each person (top 10 only)",
"lboard-alltime": "Column title for the total number of records closed by each person (top 10 only)",
"lboard-back": "Button text to go back to CopyPatrol from leaderboard page",
"close": "Button text to close pop up box. \n{{Identical|Close}}",
"imageattr-title": "Title for popup box to show image attributions",
"imageattr-logo": "Title of logo, links to file.",
"public-domain": "Text as part of the attributions box",
"open-font-license": "Text as part of the attributions box",
"imageattr-paragraph1": "Text as part of the attributions box. \n Parameters: $1, $2, $3, $4 - Strings: Links to the app logo and usernames & project names which helped create it. Username is gender neutral.",
"imageattr-paragraph2": "Text as part of the attributions box. \n Parameters: $1, $2, $3 - Strings: Link to the font, it's creator and associated license.",
"alert-testing": "Text shown as part of an alert on the test app instance, alerting users to use the actual instance instead",
"js-unauthorized": "Alert text shown to user when they try to review records without being logged in",
"js-dberror": "Alert shown to user when a database connection could not be made",
"js-undo-own-only": "Alert shown to user when they try to undo other people's reviews",
"js-unknown-error": "Alert shown to user when results could not be loaded, possibly due to connection issues, asking them to try again"
}
26 changes: 13 additions & 13 deletions public_html/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
$reviewerNode.find( '.reviewer-timestamp' ).text( ret.timestamp );
$reviewerNode.fadeIn( 'slow' );
} else if ( ret.error === 'Unauthorized' ) {
window.alert( 'You need to be logged in to be able to review.' );
window.alert( jsUnauthorized );
// go back to initial state
setReviewState( id, 'open' );
} else {
window.alert( 'There was an error in connecting to database.' );
window.alert( jsDbError );
setReviewState( id, 'open' );
}

Expand All @@ -99,10 +99,10 @@
$reviewerNode.fadeOut( 'slow' );
setReviewState( id, 'open' );
} else if ( ret.error === 'db-error' ) {
window.alert( 'There was an error in connecting to database.' );
window.alert( jsDbError );
setReviewState( id, oldStatus ); // revert back to old state
} else {
window.alert( 'You can only undo your own reviews.' );
window.alert( jsUndoOwnOnly );
setReviewState( id, oldStatus );
}

Expand Down Expand Up @@ -145,11 +145,11 @@
if ( $newRecords.find( '.js-record' ).length ) {
$( '.record-container' ).append( $newRecords.html() );
} else {
$( '.js-load-more' ).replaceWith( '<p>No more records!</p>' );
$( '.js-load-more' ).replaceWith( '<p>' + jsNoMore + '</p>' );
}
} ).fail( function () {
alert( 'An unknown error occurred when loading results. Please try again.' );
$( '#btn-load-more' ).text( 'Load More' ).removeClass( 'btn-loading' );
alert( jsUnknownError );
$( '#btn-load-more' ).text( jsLoadMore ).removeClass( 'btn-loading' );
} );
}

Expand Down Expand Up @@ -201,7 +201,7 @@
}
} else {
// use API-provided error message, otherwise a blanket unknown error message as it could be unrelated to the API
var errorMessage = ret.error && ret.error.info ? ret.error.info : 'An unknown error occurred.';
var errorMessage = ret.error && ret.error.info ? ret.error.info : jsUnknownError;
$( compareDiv ).find( '.compare-pane-body' ).html( '<span class="text-danger">' + errorMessage + '</span>' );
}
} );
Expand All @@ -222,7 +222,7 @@
url: 'https://en.wikipedia.org/w/api.php',
dataType: 'jsonp',
delay: 200,
data: function( search ) {
data: function ( search ) {
return {
action: 'opensearch',
namespace: '4',
Expand All @@ -232,22 +232,22 @@
}
},
// format API data in the way Select2 wants it
processResults: function( data ) {
processResults: function ( data ) {
var results = data[1];
return {
results: results.map( function( elem ) {
results: results.map( function ( elem ) {
var title = elem.replace( /^Wikipedia:WikiProject /, '' );
// don't show WikiProject subpages
return !/\//g.test( title ) ? {
id: title.replace( / /g, '_' ),
text: title
} : {};
})
} )
};
},
cache: true
},
placeholder: 'Type WikiProject names...',
placeholder: formWikiprojectsPlaceholder,
maximumSelectionLength: 10,
minimumInputLength: 1
};
Expand Down

0 comments on commit 22d401b

Please sign in to comment.