Internationalization for JS

This commit is contained in:
David Baumgold
2013-05-16 09:55:55 -04:00
parent 9cbfee9894
commit a0a71c0df2
4 changed files with 19 additions and 10 deletions

View File

@@ -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) {

View File

@@ -1,7 +1,11 @@
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();

View File

@@ -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": {

View File

@@ -1,5 +1,5 @@
<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>