Commit 55b2ea37 by Andy Armstrong

Merge pull request #9684 from edx/andya/fix-teams-i18n

Fix i18n for last activity date on team cards
parents f8bbbc87 6817e89f
...@@ -27,8 +27,9 @@ require.config({ ...@@ -27,8 +27,9 @@ require.config({
"jquery.immediateDescendents": "coffee/src/jquery.immediateDescendents", "jquery.immediateDescendents": "coffee/src/jquery.immediateDescendents",
"datepair": "js/vendor/timepicker/datepair", "datepair": "js/vendor/timepicker/datepair",
"date": "js/vendor/date", "date": "js/vendor/date",
"text": 'js/vendor/requirejs/text',
"moment": "js/vendor/moment.min", "moment": "js/vendor/moment.min",
"moment-with-locales": "js/vendor/moment-with-locales.min",
"text": 'js/vendor/requirejs/text',
"underscore": "js/vendor/underscore-min", "underscore": "js/vendor/underscore-min",
"underscore.string": "js/vendor/underscore.string.min", "underscore.string": "js/vendor/underscore.string.min",
"backbone": "js/vendor/backbone-min", "backbone": "js/vendor/backbone-min",
......
...@@ -23,6 +23,8 @@ requirejs.config({ ...@@ -23,6 +23,8 @@ requirejs.config({
"jquery.simulate": "xmodule_js/common_static/js/vendor/jquery.simulate", "jquery.simulate": "xmodule_js/common_static/js/vendor/jquery.simulate",
"datepair": "xmodule_js/common_static/js/vendor/timepicker/datepair", "datepair": "xmodule_js/common_static/js/vendor/timepicker/datepair",
"date": "xmodule_js/common_static/js/vendor/date", "date": "xmodule_js/common_static/js/vendor/date",
"moment": "xmodule_js/common_static/js/vendor/moment.min",
"moment-with-locales": "xmodule_js/common_static/js/vendor/moment-with-locales.min",
"text": "xmodule_js/common_static/js/vendor/requirejs/text", "text": "xmodule_js/common_static/js/vendor/requirejs/text",
"underscore": "xmodule_js/common_static/js/vendor/underscore-min", "underscore": "xmodule_js/common_static/js/vendor/underscore-min",
"underscore.string": "xmodule_js/common_static/js/vendor/underscore.string.min", "underscore.string": "xmodule_js/common_static/js/vendor/underscore.string.min",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -43,8 +43,8 @@ define(['jquery', ...@@ -43,8 +43,8 @@ define(['jquery',
expect(view.$el).toHaveClass('list-card'); expect(view.$el).toHaveClass('list-card');
expect(view.$el.find('.card-title').text()).toContain('Test Team'); expect(view.$el.find('.card-title').text()).toContain('Test Team');
expect(view.$el.find('.card-description').text()).toContain('A team for testing'); expect(view.$el.find('.card-description').text()).toContain('A team for testing');
expect(view.$el.find('.team-activity abbr').attr('title')).toEqual("2015-08-21T18:53:01.145Z"); expect(view.$el.find('.team-activity abbr').attr('title')).toContain('August 21st 2015');
expect(view.$el.find('.team-activity').text()).toContain('Last Activity'); expect(view.$el.find('.team-activity').text()).toContain('Last activity');
expect(view.$el.find('.card-meta').text()).toContain('0 / 100 Members'); expect(view.$el.find('.card-meta').text()).toContain('0 / 100 Members');
expect(view.$el.find('.team-location').text()).toContain('United States of America'); expect(view.$el.find('.team-location').text()).toContain('United States of America');
expect(view.$el.find('.team-language').text()).toContain('English'); expect(view.$el.find('.team-language').text()).toContain('English');
...@@ -143,7 +143,7 @@ define(['jquery', ...@@ -143,7 +143,7 @@ define(['jquery',
{username: 'user_5', image_url: 'user_5_image'}, {username: 'user_5', image_url: 'user_5_image'},
{username: 'user_6', image_url: 'user_6_image'}, {username: 'user_6', image_url: 'user_6_image'},
{username: 'user_3', image_url: 'user_3_image'}, {username: 'user_3', image_url: 'user_3_image'},
{username: 'user_4', image_url: 'user_4_image'}, {username: 'user_4', image_url: 'user_4_image'}
]); ]);
expect(view.$('.item-member-thumb').eq(-1)).toHaveText('and others…'); expect(view.$('.item-member-thumb').eq(-1)).toHaveText('and others…');
}); });
......
;(function (define) { ;(function (define) {
'use strict'; 'use strict';
define([ define([
'jquery',
'backbone', 'backbone',
'underscore', 'underscore',
'gettext', 'gettext',
'jquery.timeago', 'moment-with-locales',
'js/components/card/views/card', 'js/components/card/views/card',
'teams/js/views/team_utils', 'teams/js/views/team_utils',
'text!teams/templates/team-membership-details.underscore', 'text!teams/templates/team-membership-details.underscore',
'text!teams/templates/team-country-language.underscore', 'text!teams/templates/team-country-language.underscore',
'text!teams/templates/team-activity.underscore' 'text!teams/templates/team-activity.underscore'
], function ( ], function (
$,
Backbone, Backbone,
_, _,
gettext, gettext,
timeago, moment,
CardView, CardView,
TeamUtils, TeamUtils,
teamMembershipDetailsTemplate, teamMembershipDetailsTemplate,
...@@ -75,15 +77,18 @@ ...@@ -75,15 +77,18 @@
}, },
render: function () { render: function () {
var lastActivity = moment(this.date),
currentLanguage = $('html').attr('lang');
lastActivity.locale(currentLanguage);
this.$el.html( this.$el.html(
interpolate( interpolate(
// Translators: 'date' is a placeholder for a fuzzy, relative timestamp (see: https://github.com/rmm5t/jquery-timeago) // Translators: 'date' is a placeholder for a fuzzy, relative timestamp (see: http://momentjs.com/)
gettext("Last Activity %(date)s"), gettext("Last activity %(date)s"),
{date: this.template({date: this.date})}, {date: this.template({date: lastActivity.format('MMMM Do YYYY, h:mm:ss a')})},
true true
) )
); );
this.$('abbr').timeago(); this.$('abbr').text(lastActivity.fromNow());
} }
}); });
...@@ -103,7 +108,7 @@ ...@@ -103,7 +108,7 @@
}, },
teamModel: function () { teamModel: function () {
if (this.model.has('team')) { return this.model.get('team'); }; if (this.model.has('team')) { return this.model.get('team'); }
return this.model; return this.model;
}, },
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
'jquery.url': 'xmodule_js/common_static/js/vendor/url.min', 'jquery.url': 'xmodule_js/common_static/js/vendor/url.min',
'datepair': 'xmodule_js/common_static/js/vendor/timepicker/datepair', 'datepair': 'xmodule_js/common_static/js/vendor/timepicker/datepair',
'date': 'xmodule_js/common_static/js/vendor/date', 'date': 'xmodule_js/common_static/js/vendor/date',
'moment': 'xmodule_js/common_static/js/vendor/moment.min',
'moment-with-locales': 'xmodule_js/common_static/js/vendor/moment-with-locales.min',
'text': 'xmodule_js/common_static/js/vendor/requirejs/text', 'text': 'xmodule_js/common_static/js/vendor/requirejs/text',
'underscore': 'xmodule_js/common_static/js/vendor/underscore-min', 'underscore': 'xmodule_js/common_static/js/vendor/underscore-min',
'underscore.string': 'xmodule_js/common_static/js/vendor/underscore.string.min', 'underscore.string': 'xmodule_js/common_static/js/vendor/underscore.string.min',
......
...@@ -63,6 +63,7 @@ lib_paths: ...@@ -63,6 +63,7 @@ lib_paths:
- xmodule_js/common_static/js/test/i18n.js - xmodule_js/common_static/js/test/i18n.js
- xmodule_js/common_static/js/vendor/date.js - xmodule_js/common_static/js/vendor/date.js
- xmodule_js/common_static/js/vendor/moment.min.js - xmodule_js/common_static/js/vendor/moment.min.js
- xmodule_js/common_static/js/vendor/moment-with-locales.min.js
- xmodule_js/common_static/js/utils/edx.utils.validate.js - xmodule_js/common_static/js/utils/edx.utils.validate.js
# Paths to source JavaScript files # Paths to source JavaScript files
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
"gettext": "/i18n", "gettext": "/i18n",
"annotator_1.2.9": "js/vendor/edxnotes/annotator-full.min", "annotator_1.2.9": "js/vendor/edxnotes/annotator-full.min",
"date": "js/vendor/date", "date": "js/vendor/date",
"moment": "js/vendor/moment.min",
"moment-with-locales": "js/vendor/moment-with-locales.min",
"text": "js/vendor/requirejs/text", "text": "js/vendor/requirejs/text",
"logger": "js/src/logger", "logger": "js/src/logger",
"backbone": "js/vendor/backbone-min", "backbone": "js/vendor/backbone-min",
...@@ -52,7 +54,6 @@ ...@@ -52,7 +54,6 @@
"URI": "js/vendor/URI.min", "URI": "js/vendor/URI.min",
"string_utils": "js/src/string_utils", "string_utils": "js/src/string_utils",
"utility": "js/src/utility", "utility": "js/src/utility",
"moment": "js/vendor/moment.min",
// Files needed by OVA // Files needed by OVA
"annotator": "js/vendor/ova/annotator-full", "annotator": "js/vendor/ova/annotator-full",
...@@ -189,6 +190,9 @@ ...@@ -189,6 +190,9 @@
// End of needed by OVA // End of needed by OVA
"moment": { "moment": {
exports: "moment" exports: "moment"
},
"moment-with-locales": {
exports: "moment"
} }
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment