From 7f38c1a3c9cce8499307d5f751712a3e0cf3adab Mon Sep 17 00:00:00 2001 From: asadiqbal Date: Thu, 7 Jan 2016 18:08:15 +0500 Subject: [PATCH] WL-270 used gettext in javascript files --- cms/static/js/models/chapter.js | 8 ++++---- cms/static/js/models/textbook.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cms/static/js/models/chapter.js b/cms/static/js/models/chapter.js index 34723aa19c..8b97c1ff73 100644 --- a/cms/static/js/models/chapter.js +++ b/cms/static/js/models/chapter.js @@ -1,4 +1,4 @@ -define(["backbone", "backbone.associations"], function(Backbone) { +define(["backbone", "gettext", "backbone.associations"], function(Backbone, gettext) { var Chapter = Backbone.AssociatedModel.extend({ defaults: function() { return { @@ -32,17 +32,17 @@ define(["backbone", "backbone.associations"], function(Backbone) { validate: function(attrs, options) { if(!attrs.name && !attrs.asset_path) { return { - message: "Chapter name and asset_path are both required", + message: gettext("Chapter name and asset_path are both required"), attributes: {name: true, asset_path: true} }; } else if(!attrs.name) { return { - message: "Chapter name is required", + message: gettext("Chapter name is required"), attributes: {name: true} }; } else if (!attrs.asset_path) { return { - message: "asset_path is required", + message: gettext("asset_path is required"), attributes: {asset_path: true} }; } diff --git a/cms/static/js/models/textbook.js b/cms/static/js/models/textbook.js index 9412c809d7..b59948f191 100644 --- a/cms/static/js/models/textbook.js +++ b/cms/static/js/models/textbook.js @@ -1,6 +1,6 @@ -define(["backbone", "underscore", "js/models/chapter", "js/collections/chapter", +define(["backbone", "underscore", "gettext", "js/models/chapter", "js/collections/chapter", "backbone.associations", "coffee/src/main"], - function(Backbone, _, ChapterModel, ChapterCollection) { + function(Backbone, _, gettext, ChapterModel, ChapterCollection) { var Textbook = Backbone.AssociatedModel.extend({ defaults: function() { @@ -60,13 +60,13 @@ define(["backbone", "underscore", "js/models/chapter", "js/collections/chapter", validate: function(attrs, options) { if (!attrs.name) { return { - message: "Textbook name is required", + message: gettext("Textbook name is required"), attributes: {name: true} }; } if (attrs.chapters.length === 0) { return { - message: "Please add at least one chapter", + message: gettext("Please add at least one chapter"), attributes: {chapters: true} }; } else { @@ -79,7 +79,7 @@ define(["backbone", "underscore", "js/models/chapter", "js/collections/chapter", }); if(!_.isEmpty(invalidChapters)) { return { - message: "All chapters must have a name and asset", + message: gettext("All chapters must have a name and asset"), attributes: {chapters: invalidChapters} }; }