Commit a0a71c0d by David Baumgold

Internationalization for JS

parent 9cbfee98
......@@ -4,7 +4,7 @@ CMS.Models.Section = Backbone.Model.extend({
},
validate: function(attrs, options) {
if (!attrs.name) {
return "You must specify a name";
return gettext("You must specify a name");
}
},
url: "/save_item",
......@@ -25,7 +25,7 @@ CMS.Models.Section = Backbone.Model.extend({
if(!this.msg) {
this.msg = new CMS.Models.SystemFeedback({
type: "saving",
title: "Saving…"
title: gettext("Saving…")
});
}
if(!this.msgView) {
......
CMS.Views.SectionShow = Backbone.View.extend({
template: _.template('<span data-tooltip="Edit this section\'s name" class="section-name-span"><%= name %></span>'),
template: _.template('<span data-tooltip="<%= tooltip %>" class="section-name-span"><%= name %></span>'),
render: function() {
this.$el.html(this.template(this.model.attributes));
var attrs = {
tooltip: gettext("Edit this section's name")
};
attrs = $.extend(attrs, this.model.attributes);
this.$el.html(this.template(attrs));
this.delegateEvents();
return this;
},
......@@ -20,7 +24,12 @@ CMS.Views.SectionShow = Backbone.View.extend({
CMS.Views.SectionEdit = Backbone.View.extend({
render: function() {
this.$el.html(this.template(this.model.attributes));
var attrs = {
save: gettext("Save"),
cancel: gettext("Cancel")
};
attrs = $.extend(attrs, this.model.attributes);
this.$el.html(this.template(attrs));
this.delegateEvents();
return this;
},
......@@ -61,11 +70,11 @@ CMS.Views.SectionEdit = Backbone.View.extend({
showInvalidMessage: function(model, error, options) {
var that = this;
var msg = new CMS.Models.ErrorMessage({
title: "Validation Error",
title: gettext("Validation Error"),
message: error,
actions: {
primary: {
text: "Dismiss",
text: gettext("Dismiss"),
click: function(view) {
view.hide();
that.$("input[type=text]").focus();
......
......@@ -69,7 +69,7 @@
<script type="text/javascript">
$(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
var msg = new CMS.Models.ErrorMessage({
"title": "Server Error",
"title": gettext("Server Error"),
"message": jqXHR.responseText,
"actions": {
"primary": {
......
<form class="section-name-edit">
<input type="text" value="<%= name %>" autocomplete="off"/>
<input type="submit" class="save-button" value="Save" />
<input type="button" class="cancel-button" value="Cancel" />
<input type="submit" class="save-button" value="<%= save %>" />
<input type="button" class="cancel-button" value="<%= cancel %>" />
</form>
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