Merge pull request #1167 from ZogStriP/i18n-helper

I18n helper
This commit is contained in:
Robin Ward 2013-07-09 06:43:48 -07:00
commit f4c3416f1b
86 changed files with 348 additions and 354 deletions

View File

@ -14,7 +14,7 @@ Discourse.AdminCustomizeController = Ember.ArrayController.extend({
@method newCustomization
**/
newCustomization: function() {
var item = Discourse.SiteCustomization.create({name: Em.String.i18n("admin.customize.new_style")});
var item = Discourse.SiteCustomization.create({name: I18n.t("admin.customize.new_style")});
this.pushObject(item);
this.set('selectedItem', item);
},
@ -45,7 +45,7 @@ Discourse.AdminCustomizeController = Ember.ArrayController.extend({
**/
destroy: function() {
var _this = this;
return bootbox.confirm(Em.String.i18n("admin.customize.delete_confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) {
return bootbox.confirm(I18n.t("admin.customize.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
var selected;
if (result) {
selected = _this.get('selectedItem');

View File

@ -19,7 +19,7 @@ Discourse.AdminFlagsController = Ember.ArrayController.extend({
item.disagreeFlags().then((function() {
adminFlagsController.removeObject(item);
}), function() {
bootbox.alert(Em.String.i18n("admin.flags.error"));
bootbox.alert(I18n.t("admin.flags.error"));
});
},
@ -28,7 +28,7 @@ Discourse.AdminFlagsController = Ember.ArrayController.extend({
item.agreeFlags().then((function() {
adminFlagsController.removeObject(item);
}), function() {
bootbox.alert(Em.String.i18n("admin.flags.error"));
bootbox.alert(I18n.t("admin.flags.error"));
});
},
@ -37,7 +37,7 @@ Discourse.AdminFlagsController = Ember.ArrayController.extend({
item.deferFlags().then((function() {
adminFlagsController.removeObject(item);
}), function() {
bootbox.alert(Em.String.i18n("admin.flags.error"));
bootbox.alert(I18n.t("admin.flags.error"));
});
},
@ -52,7 +52,7 @@ Discourse.AdminFlagsController = Ember.ArrayController.extend({
item.deletePost().then((function() {
adminFlagsController.removeObject(item);
}), function() {
bootbox.alert(Em.String.i18n("admin.flags.error"));
bootbox.alert(I18n.t("admin.flags.error"));
});
},

View File

@ -18,7 +18,7 @@ Discourse.AdminUserController = Discourse.ObjectController.extend({
data: {title: this.get('title')},
type: 'PUT'
}).then(null, function(e){
bootbox.alert(Em.String.i18n("generic_error_with_reason", {error: "http: " + e.status + " - " + e.body}));
bootbox.alert(I18n.t("generic_error_with_reason", {error: "http: " + e.status + " - " + e.body}));
});
this.toggleTitleEdit();

View File

@ -49,7 +49,7 @@ Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Pres
@property title
**/
title: function() {
return Em.String.i18n('admin.users.titles.' + this.get('query'));
return I18n.t('admin.users.titles.' + this.get('query'));
}.property('query'),
/**

View File

@ -14,7 +14,7 @@ Discourse.AdminApi = Discourse.Model.extend({
},
regenerateKey: function(){
alert(Em.String.i18n('not_implemented'));
alert(I18n.t('not_implemented'));
}
});

View File

@ -89,7 +89,7 @@ Discourse.AdminUser = Discourse.User.extend({
window.location.reload();
}, function(e) {
// failure
var error = Em.String.i18n('admin.user.trust_level_change_failed', { error: "http: " + e.status + " - " + e.body });
var error = I18n.t('admin.user.trust_level_change_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
});
},
@ -113,7 +113,7 @@ Discourse.AdminUser = Discourse.User.extend({
}).property('banned_till', 'banned_at'),
ban: function() {
var duration = parseInt(window.prompt(Em.String.i18n('admin.user.ban_duration')), 10);
var duration = parseInt(window.prompt(I18n.t('admin.user.ban_duration')), 10);
if (duration > 0) {
Discourse.ajax("/admin/users/" + this.id + "/ban", {
type: 'PUT',
@ -123,7 +123,7 @@ Discourse.AdminUser = Discourse.User.extend({
window.location.reload();
}, function(e) {
// failure
var error = Em.String.i18n('admin.user.ban_failed', { error: "http: " + e.status + " - " + e.body });
var error = I18n.t('admin.user.ban_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
});
}
@ -137,7 +137,7 @@ Discourse.AdminUser = Discourse.User.extend({
window.location.reload();
}, function(e) {
// failed
var error = Em.String.i18n('admin.user.unban_failed', { error: "http: " + e.status + " - " + e.body });
var error = I18n.t('admin.user.unban_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
});
},
@ -152,9 +152,9 @@ Discourse.AdminUser = Discourse.User.extend({
}, function(e) {
// failed
if (e.status === 404) {
bootbox.alert(Em.String.i18n('admin.impersonate.not_found'));
bootbox.alert(I18n.t('admin.impersonate.not_found'));
} else {
bootbox.alert(Em.String.i18n('admin.impersonate.invalid'));
bootbox.alert(I18n.t('admin.impersonate.invalid'));
}
});
},
@ -165,7 +165,7 @@ Discourse.AdminUser = Discourse.User.extend({
window.location.reload();
}, function(e) {
// failed
var error = Em.String.i18n('admin.user.activate_failed', { error: "http: " + e.status + " - " + e.body });
var error = I18n.t('admin.user.activate_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
});
},
@ -176,7 +176,7 @@ Discourse.AdminUser = Discourse.User.extend({
window.location.reload();
}, function(e) {
// failed
var error = Em.String.i18n('admin.user.deactivate_failed', { error: "http: " + e.status + " - " + e.body });
var error = I18n.t('admin.user.deactivate_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
});
},
@ -187,7 +187,7 @@ Discourse.AdminUser = Discourse.User.extend({
window.location.reload();
}, function(e) {
// failed
var error = Em.String.i18n('admin.user.unblock_failed', { error: "http: " + e.status + " - " + e.body });
var error = I18n.t('admin.user.unblock_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
});
},
@ -198,7 +198,7 @@ Discourse.AdminUser = Discourse.User.extend({
window.location.reload();
}, function(e) {
// failed
var error = Em.String.i18n('admin.user.block_failed', { error: "http: " + e.status + " - " + e.body });
var error = I18n.t('admin.user.block_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
});
},
@ -206,10 +206,10 @@ Discourse.AdminUser = Discourse.User.extend({
sendActivationEmail: function() {
Discourse.ajax('/users/' + this.get('username') + '/send_activation_email', {type: 'POST'}).then(function() {
// succeeded
bootbox.alert( Em.String.i18n('admin.user.activation_email_sent') );
bootbox.alert( I18n.t('admin.user.activation_email_sent') );
}, function(e) {
// failed
var error = Em.String.i18n('admin.user.send_activation_email_failed', { error: "http: " + e.status + " - " + e.body });
var error = I18n.t('admin.user.send_activation_email_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
});
},
@ -220,7 +220,7 @@ Discourse.AdminUser = Discourse.User.extend({
deleteButtonTitle: function() {
if (this.get('deleteForbidden')) {
return Em.String.i18n('admin.user.delete_forbidden');
return I18n.t('admin.user.delete_forbidden');
} else {
return null;
}
@ -228,22 +228,22 @@ Discourse.AdminUser = Discourse.User.extend({
destroy: function() {
var user = this;
bootbox.confirm(Em.String.i18n("admin.user.delete_confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) {
bootbox.confirm(I18n.t("admin.user.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
if(result) {
Discourse.ajax("/admin/users/" + user.get('id') + '.json', { type: 'DELETE' }).then(function(data) {
if (data.deleted) {
bootbox.alert(Em.String.i18n("admin.user.deleted"), function() {
bootbox.alert(I18n.t("admin.user.deleted"), function() {
document.location = "/admin/users/list/active";
});
} else {
bootbox.alert(Em.String.i18n("admin.user.delete_failed"));
bootbox.alert(I18n.t("admin.user.delete_failed"));
if (data.user) {
user.mergeAttributes(data.user);
}
}
}, function(jqXHR, status, error) {
Discourse.AdminUser.find( user.get('username') ).then(function(u){ user.mergeAttributes(u); });
bootbox.alert(Em.String.i18n("admin.user.delete_failed"));
bootbox.alert(I18n.t("admin.user.delete_failed"));
});
}
});
@ -270,7 +270,7 @@ Discourse.AdminUser.reopenClass({
return user.set('selected', false);
});
bootbox.alert(Em.String.i18n("admin.user.approve_bulk_success"));
bootbox.alert(I18n.t("admin.user.approve_bulk_success"));
return Discourse.ajax("/admin/users/approve-bulk", {
type: 'PUT',

View File

@ -12,7 +12,7 @@ Discourse.FlaggedPost = Discourse.Post.extend({
return _(this.post_actions)
.groupBy(function(a){ return a.post_action_type_id; })
.map(function(v,k){
return Em.String.i18n('admin.flags.summary.action_type_' + k, {count: v.length});
return I18n.t('admin.flags.summary.action_type_' + k, {count: v.length});
})
.join(',');
}.property(),
@ -23,7 +23,7 @@ Discourse.FlaggedPost = Discourse.Post.extend({
r = [];
_.each(this.post_actions, function(action) {
var user = _this.userLookup[action.user_id];
var flagType = Em.String.i18n('admin.flags.summary.action_type_' + action.post_action_type_id, {count: 1});
var flagType = I18n.t('admin.flags.summary.action_type_' + action.post_action_type_id, {count: 1});
r.push({user: user, flagType: flagType, flaggedAt: action.created_at});
});
return r;

View File

@ -55,7 +55,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
save: function() {
this.set('savingStatus', Em.String.i18n('saving'));
this.set('savingStatus', I18n.t('saving'));
this.set('saving',true);
var data = {
name: this.name,
@ -74,7 +74,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
siteCustomization.set('id', result.id);
siteCustomization.set('key', result.key);
}
siteCustomization.set('savingStatus', Em.String.i18n('saved'));
siteCustomization.set('savingStatus', I18n.t('saved'));
siteCustomization.set('saving',false);
siteCustomization.startTrackingChanges();
});

View File

@ -137,7 +137,7 @@ Discourse = Ember.Application.createWithMixins({
$('#main').on('click.discourse', '[data-not-implemented=true]', function(e) {
e.preventDefault();
alert(Em.String.i18n('not_implemented'));
alert(I18n.t('not_implemented'));
return false;
});

View File

@ -88,7 +88,7 @@ Discourse.Formatter = (function(){
var formatted;
var t = function(key,opts){
return Ember.String.i18n("dates." + format + "." + key, opts);
return I18n.t("dates." + format + "." + key, opts);
};
switch(true){
@ -133,7 +133,7 @@ Discourse.Formatter = (function(){
distanceInMinutes = Math.round(distance / 60.0);
var t = function(key, opts){
return Ember.String.i18n("dates.medium" + (leaveAgo?"_with_ago":"") + "." + key, opts);
return I18n.t("dates.medium" + (leaveAgo?"_with_ago":"") + "." + key, opts);
};
switch(true){
@ -173,7 +173,7 @@ Discourse.Formatter = (function(){
oneMinuteAgo = 60;
if (distance < oneMinuteAgo) {
displayDate = Em.String.i18n("now");
displayDate = I18n.t("now");
} else if (distance > fiveDaysAgo) {
if ((new Date()).getFullYear() !== date.getFullYear()) {
displayDate = shortDate(date);

View File

@ -45,42 +45,42 @@ Discourse.Markdown = {
var editorOptions = {
strings: {
bold: I18n.t("js.composer.bold_title") + " <strong> Ctrl+B",
boldexample: I18n.t("js.composer.bold_text"),
bold: I18n.t("composer.bold_title") + " <strong> Ctrl+B",
boldexample: I18n.t("composer.bold_text"),
italic: I18n.t("js.composer.italic_title") + " <em> Ctrl+I",
italicexample: I18n.t("js.composer.italic_text"),
italic: I18n.t("composer.italic_title") + " <em> Ctrl+I",
italicexample: I18n.t("composer.italic_text"),
link: I18n.t("js.composer.link_title") + " <a> Ctrl+L",
linkdescription: I18n.t("js.composer.link_description"),
linkdialog: "<p><b>" + I18n.t("js.composer.link_dialog_title") + "</b></p><p>http://example.com/ \"" +
I18n.t("js.composer.link_optional_text") + "\"</p>",
link: I18n.t("composer.link_title") + " <a> Ctrl+L",
linkdescription: I18n.t("composer.link_description"),
linkdialog: "<p><b>" + I18n.t("composer.link_dialog_title") + "</b></p><p>http://example.com/ \"" +
I18n.t("composer.link_optional_text") + "\"</p>",
quote: I18n.t("js.composer.quote_title") + " <blockquote> Ctrl+Q",
quoteexample: I18n.t("js.composer.quote_text"),
quote: I18n.t("composer.quote_title") + " <blockquote> Ctrl+Q",
quoteexample: I18n.t("composer.quote_text"),
code: I18n.t("js.composer.code_title") + " <pre><code> Ctrl+K",
codeexample: I18n.t("js.composer.code_text"),
code: I18n.t("composer.code_title") + " <pre><code> Ctrl+K",
codeexample: I18n.t("composer.code_text"),
image: I18n.t("js.composer.image_title") + " <img> Ctrl+G",
imagedescription: I18n.t("js.composer.image_description"),
imagedialog: "<p><b>" + I18n.t("js.composer.image_dialog_title") + "</b></p><p>http://example.com/images/diagram.jpg \"" +
I18n.t("js.composer.image_optional_text") + "\"<br><br>" + I18n.t("js.composer.image_hosting_hint") + "</p>",
image: I18n.t("composer.image_title") + " <img> Ctrl+G",
imagedescription: I18n.t("composer.image_description"),
imagedialog: "<p><b>" + I18n.t("composer.image_dialog_title") + "</b></p><p>http://example.com/images/diagram.jpg \"" +
I18n.t("composer.image_optional_text") + "\"<br><br>" + I18n.t("composer.image_hosting_hint") + "</p>",
olist: I18n.t("js.composer.olist_title") + " <ol> Ctrl+O",
ulist: I18n.t("js.composer.ulist_title") + " <ul> Ctrl+U",
litem: I18n.t("js.composer.list_item"),
olist: I18n.t("composer.olist_title") + " <ol> Ctrl+O",
ulist: I18n.t("composer.ulist_title") + " <ul> Ctrl+U",
litem: I18n.t("composer.list_item"),
heading: I18n.t("js.composer.heading_title") + " <h1>/<h2> Ctrl+H",
headingexample: I18n.t("js.composer.heading_text"),
heading: I18n.t("composer.heading_title") + " <h1>/<h2> Ctrl+H",
headingexample: I18n.t("composer.heading_text"),
hr: I18n.t("js.composer.hr_title") + " <hr> Ctrl+R",
hr: I18n.t("composer.hr_title") + " <hr> Ctrl+R",
undo: I18n.t("js.composer.undo_title") + " - Ctrl+Z",
redo: I18n.t("js.composer.redo_title") + " - Ctrl+Y",
redomac: I18n.t("js.composer.redo_title") + " - Ctrl+Shift+Z",
undo: I18n.t("composer.undo_title") + " - Ctrl+Z",
redo: I18n.t("composer.redo_title") + " - Ctrl+Y",
redomac: I18n.t("composer.redo_title") + " - Ctrl+Shift+Z",
help: I18n.t("js.composer.help")
help: I18n.t("composer.help")
}
};

View File

@ -168,13 +168,13 @@ Discourse.Utilities = {
if (files) {
// can only upload one file at a time
if (files.length > 1) {
bootbox.alert(Em.String.i18n('post.errors.too_many_uploads'));
bootbox.alert(I18n.t('post.errors.too_many_uploads'));
return false;
} else if (files.length > 0) {
var upload = files[0];
// ensures that new users can upload image
if (Discourse.User.current('trust_level') === 0 && Discourse.SiteSettings.newuser_max_images === 0) {
bootbox.alert(Em.String.i18n('post.errors.upload_not_allowed_for_new_user'));
bootbox.alert(I18n.t('post.errors.upload_not_allowed_for_new_user'));
return false;
}
// if the image was pasted, sets its name to a default one
@ -182,14 +182,14 @@ Discourse.Utilities = {
// check that the uploaded file is authorized
if (!Discourse.Utilities.isAuthorizedUpload(upload)) {
var extensions = Discourse.SiteSettings.authorized_extensions.replace(/\|/g, ", ");
bootbox.alert(Em.String.i18n('post.errors.upload_not_authorized', { authorized_extensions: extensions }));
bootbox.alert(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: extensions }));
return false;
}
// check file size
if (upload.size && upload.size > 0) {
var fileSizeInKB = upload.size / 1024;
if (fileSizeInKB > Discourse.SiteSettings.max_upload_size_kb) {
bootbox.alert(Em.String.i18n('post.errors.upload_too_large', { max_size_kb: Discourse.SiteSettings.max_upload_size_kb }));
bootbox.alert(I18n.t('post.errors.upload_too_large', { max_size_kb: Discourse.SiteSettings.max_upload_size_kb }));
return false;
}
// everything is fine

View File

@ -55,17 +55,17 @@ Discourse.ComposerController = Discourse.Controller.extend({
topic = this.get('topic');
if (!topic || topic.get('id') !== composer.get('topic.id'))
{
message = Em.String.i18n("composer.posting_not_on_topic", {title: this.get('model.topic.title')});
message = I18n.t("composer.posting_not_on_topic", {title: this.get('model.topic.title')});
buttons = [{
"label": Em.String.i18n("composer.cancel"),
"label": I18n.t("composer.cancel"),
"class": "cancel",
"link": true
}];
if(topic) {
buttons.push({
"label": Em.String.i18n("composer.reply_here") + "<br/><div class='topic-title'>" + topic.get('title') + "</div>",
"label": I18n.t("composer.reply_here") + "<br/><div class='topic-title'>" + topic.get('title') + "</div>",
"class": "btn btn-reply-here",
"callback": function(){
composer.set('topic', topic);
@ -76,7 +76,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
}
buttons.push({
"label": Em.String.i18n("composer.reply_original") + "<br/><div class='topic-title'>" + this.get('model.topic.title') + "</div>",
"label": I18n.t("composer.reply_original") + "<br/><div class='topic-title'>" + this.get('model.topic.title') + "</div>",
"class": "btn-primary btn-reply-on-original",
"callback": function(){
_this.save(true);
@ -301,7 +301,7 @@ Discourse.ComposerController = Discourse.Controller.extend({
return Ember.Deferred.promise(function (promise) {
if (composerController.get('model.hasMetaData') || composerController.get('model.replyDirty')) {
bootbox.confirm(Em.String.i18n("post.abandon"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) {
bootbox.confirm(I18n.t("post.abandon"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
if (result) {
composerController.destroyDraft();
composerController.get('model').clearState();

View File

@ -42,14 +42,14 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
if (this.get('accountName').length < 3) {
return Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.name.too_short')
reason: I18n.t('user.name.too_short')
});
}
// Looks good!
return Discourse.InputValidation.create({
ok: true,
reason: Em.String.i18n('user.name.ok')
reason: I18n.t('user.name.ok')
});
}.property('accountName'),
@ -67,7 +67,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
if ((this.get('authOptions.email') === email) && this.get('authOptions.email_valid')) {
return Discourse.InputValidation.create({
ok: true,
reason: Em.String.i18n('user.email.authenticated', {
reason: I18n.t('user.email.authenticated', {
provider: this.get('authOptions.auth_provider')
})
});
@ -76,13 +76,13 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
if (Discourse.Utilities.emailValid(email)) {
return Discourse.InputValidation.create({
ok: true,
reason: Em.String.i18n('user.email.ok')
reason: I18n.t('user.email.ok')
});
}
return Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.email.invalid')
reason: I18n.t('user.email.invalid')
});
}.property('accountEmail'),
@ -92,7 +92,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
if (this.shouldCheckUsernameMatch()) {
return this.set('uniqueUsernameValidation', Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.username.enter_email')
reason: I18n.t('user.username.enter_email')
}));
} else {
return this.set('uniqueUsernameValidation', Discourse.InputValidation.create({ failed: true }));
@ -100,7 +100,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
} else if (this.shouldCheckUsernameMatch()) {
this.set('uniqueUsernameValidation', Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.username.checking')
reason: I18n.t('user.username.checking')
}));
return this.checkUsernameAvailability();
}
@ -121,7 +121,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
if (this.get('accountUsername').length < 3) {
return Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.username.too_short')
reason: I18n.t('user.username.too_short')
});
}
@ -129,7 +129,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
if (this.get('accountUsername').length > 15) {
return Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.username.too_long')
reason: I18n.t('user.username.too_long')
});
}
@ -137,7 +137,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
// Let's check it out asynchronously
return Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.username.checking')
reason: I18n.t('user.username.checking')
});
}.property('accountUsername'),
@ -155,12 +155,12 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
_this.set('globalNicknameExists', true);
return _this.set('uniqueUsernameValidation', Discourse.InputValidation.create({
ok: true,
reason: Em.String.i18n('user.username.global_match')
reason: I18n.t('user.username.global_match')
}));
} else {
return _this.set('uniqueUsernameValidation', Discourse.InputValidation.create({
ok: true,
reason: Em.String.i18n('user.username.available')
reason: I18n.t('user.username.available')
}));
}
} else {
@ -169,12 +169,12 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
_this.set('globalNicknameExists', true);
return _this.set('uniqueUsernameValidation', Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.username.global_mismatch', result)
reason: I18n.t('user.username.global_mismatch', result)
}));
} else {
return _this.set('uniqueUsernameValidation', Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.username.not_available', result)
reason: I18n.t('user.username.not_available', result)
}));
}
} else if (result.errors) {
@ -186,7 +186,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
_this.set('globalNicknameExists', true);
return _this.set('uniqueUsernameValidation', Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.username.enter_email')
reason: I18n.t('user.username.enter_email')
}));
}
}
@ -228,14 +228,14 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
if (password.length < 6) {
return Discourse.InputValidation.create({
failed: true,
reason: Em.String.i18n('user.password.too_short')
reason: I18n.t('user.password.too_short')
});
}
// Looks good!
return Discourse.InputValidation.create({
ok: true,
reason: Em.String.i18n('user.password.ok')
reason: I18n.t('user.password.ok')
});
}.property('accountPassword'),
@ -261,7 +261,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
createAccountController.flash(result.message);
createAccountController.set('complete', true);
} else {
createAccountController.flash(result.message || Em.String.i18n('create_account.failed'), 'error');
createAccountController.flash(result.message || I18n.t('create_account.failed'), 'error');
createAccountController.set('formSubmitted', false);
}
if (result.active) {
@ -269,7 +269,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF
}
}, function() {
createAccountController.set('formSubmitted', false);
return createAccountController.flash(Em.String.i18n('create_account.failed'), 'error');
return createAccountController.flash(I18n.t('create_account.failed'), 'error');
});
}

View File

@ -22,9 +22,9 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
}.observes('description'),
title: function() {
if (this.get('id')) return Em.String.i18n("category.edit_long");
if (this.get('isUncategorized')) return Em.String.i18n("category.edit_uncategorized");
return Em.String.i18n("category.create");
if (this.get('id')) return I18n.t("category.edit_long");
if (this.get('isUncategorized')) return I18n.t("category.edit_uncategorized");
return I18n.t("category.create");
}.property('id'),
titleChanged: function() {
@ -82,17 +82,17 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
categoryName: function() {
var name = this.get('name') || "";
return name.trim().length > 0 ? name : Em.String.i18n("preview");
return name.trim().length > 0 ? name : I18n.t("preview");
}.property('name'),
buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n("saving");
if (this.get('isUncategorized')) return Em.String.i18n("save");
return (this.get('id') ? Em.String.i18n("category.save") : Em.String.i18n("category.create"));
if (this.get('saving')) return I18n.t("saving");
if (this.get('isUncategorized')) return I18n.t("save");
return (this.get('id') ? I18n.t("category.save") : I18n.t("category.create"));
}.property('saving', 'id'),
deleteButtonTitle: function() {
return Em.String.i18n('category.delete');
return I18n.t('category.delete');
}.property(),
showCategoryTopic: function() {
@ -129,7 +129,7 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
Discourse.URL.redirectTo("/categories");
}, function(errors) {
// errors
if(errors.length === 0) errors.push(Em.String.i18n("category.save_error"));
if(errors.length === 0) errors.push(I18n.t("category.save_error"));
categoryController.displayErrors(errors);
categoryController.set('saving', false);
});
@ -140,7 +140,7 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
Discourse.URL.redirectTo("/category/" + Discourse.Category.slugFor(result.category));
}, function(errors) {
// errors
if(errors.length === 0) errors.push(Em.String.i18n("category.creation_error"));
if(errors.length === 0) errors.push(I18n.t("category.creation_error"));
categoryController.displayErrors(errors);
categoryController.set('saving', false);
});
@ -152,7 +152,7 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
this.set('deleting', true);
$('#discourse-modal').modal('hide');
bootbox.confirm(Em.String.i18n("category.delete_confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) {
bootbox.confirm(I18n.t("category.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
if (result) {
categoryController.get('model').destroy().then(function(){
// success
@ -161,7 +161,7 @@ Discourse.EditCategoryController = Discourse.ObjectController.extend(Discourse.M
}, function(jqXHR){
// error
$('#discourse-modal').modal('show');
categoryController.displayErrors([Em.String.i18n("category.delete_error")]);
categoryController.displayErrors([I18n.t("category.delete_error")]);
categoryController.set('deleting', false);
});
} else {

View File

@ -38,7 +38,7 @@ Discourse.EditTopicAutoCloseController = Discourse.ObjectController.extend(Disco
}).then(function(){
editTopicAutoCloseController.set('details.auto_close_at', moment().add('days', days).format());
}, function (error) {
bootbox.alert(Em.String.i18n('generic_error'));
bootbox.alert(I18n.t('generic_error'));
});
}

View File

@ -12,7 +12,7 @@ Discourse.FlagActionTypeController = Discourse.ObjectController.extend({
message: Em.computed.alias('controllers.flag.message'),
customPlaceholder: function(){
return Em.String.i18n("flagging.custom_placeholder_" + this.get('name_key'));
return I18n.t("flagging.custom_placeholder_" + this.get('name_key'));
}.property('name_key'),
formattedName: function(){
@ -34,11 +34,11 @@ Discourse.FlagActionTypeController = Discourse.ObjectController.extend({
var len = this.get('message.length') || 0;
var minLen = Discourse.SiteSettings.min_private_message_post_length;
if (len === 0) {
return Em.String.i18n("flagging.custom_message.at_least", { n: minLen });
return I18n.t("flagging.custom_message.at_least", { n: minLen });
} else if (len < minLen) {
return Em.String.i18n("flagging.custom_message.more", { n: minLen - len });
return I18n.t("flagging.custom_message.more", { n: minLen - len });
} else {
return Em.String.i18n("flagging.custom_message.left", {
return I18n.t("flagging.custom_message.left", {
n: Discourse.PostActionType.MAX_MESSAGE_LENGTH - len
});
}

View File

@ -36,9 +36,9 @@ Discourse.FlagController = Discourse.ObjectController.extend(Discourse.ModalFunc
submitText: function(){
if (this.get('selected.is_custom_flag')) {
return Em.String.i18n("flagging.notify_action");
return I18n.t("flagging.notify_action");
} else {
return Em.String.i18n("flagging.action");
return I18n.t("flagging.action");
}
}.property('selected.is_custom_flag'),

View File

@ -22,7 +22,7 @@ Discourse.ForgotPasswordController = Discourse.Controller.extend(Discourse.Modal
});
// don't tell people what happened, this keeps it more secure (ensure same on server)
this.flash(Em.String.i18n('forgot_password.complete'));
this.flash(I18n.t('forgot_password.complete'));
return false;
}

View File

@ -72,7 +72,7 @@ Discourse.HistoryController = Discourse.ObjectController.extend(Discourse.ModalF
leaveAgo: true,
wrapInSpan: false});
item.description = "v" + item.number + " - " + age + " - " + Em.String.i18n("changed_by", { author: item.display_username });
item.description = "v" + item.number + " - " + age + " - " + I18n.t("changed_by", { author: item.display_username });
});
historyController.setProperties({

View File

@ -17,12 +17,12 @@ Discourse.InviteController = Discourse.ObjectController.extend(Discourse.ModalFu
}.property('email', 'saving'),
buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n('topic.inviting');
return Em.String.i18n('topic.invite_reply.action');
if (this.get('saving')) return I18n.t('topic.inviting');
return I18n.t('topic.invite_reply.action');
}.property('saving'),
successMessage: function() {
return Em.String.i18n('topic.invite_reply.success', { email: this.get('email') });
return I18n.t('topic.invite_reply.success', { email: this.get('email') });
}.property('email'),
createInvite: function() {

View File

@ -22,8 +22,8 @@ Discourse.InvitePrivateController = Discourse.ObjectController.extend(Discourse.
}.property('emailOrUsername', 'saving'),
buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n('topic.inviting');
return Em.String.i18n('topic.invite_private.action');
if (this.get('saving')) return I18n.t('topic.inviting');
return I18n.t('topic.invite_private.action');
}.property('saving'),
invite: function() {

View File

@ -92,12 +92,12 @@ Discourse.ListController = Discourse.Controller.extend({
// Put in the appropriate page title based on our view
updateTitle: function() {
if (this.get('filterMode') === 'categories') {
return Discourse.set('title', Em.String.i18n('categories_list'));
return Discourse.set('title', I18n.t('categories_list'));
} else {
if (this.present('category')) {
return Discourse.set('title', this.get('category.name').capitalize() + " " + Em.String.i18n('topic.list'));
return Discourse.set('title', this.get('category.name').capitalize() + " " + I18n.t('topic.list'));
} else {
return Discourse.set('title', Em.String.i18n('topic.list'));
return Discourse.set('title', I18n.t('topic.list'));
}
}
}.observes('filterMode', 'category'),

View File

@ -65,15 +65,15 @@ Discourse.ListTopicsController = Discourse.ObjectController.extend({
if (!this.get('allLoaded')) return;
var category = this.get('category');
if( category ) {
return Em.String.i18n('topics.bottom.category', {category: category.get('name')});
return I18n.t('topics.bottom.category', {category: category.get('name')});
} else {
var split = this.get('filter').split('/');
if (this.get('topics.length') === 0) {
return Em.String.i18n("topics.none." + split[0], {
return I18n.t("topics.none." + split[0], {
category: split[1]
});
} else {
return Em.String.i18n("topics.bottom." + split[0], {
return I18n.t("topics.bottom." + split[0], {
category: split[1]
});
}

View File

@ -31,7 +31,7 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
}.property(),
loginButtonText: function() {
return this.get('loggingIn') ? Em.String.i18n('login.logging_in') : Em.String.i18n('login.title');
return this.get('loggingIn') ? I18n.t('login.logging_in') : I18n.t('login.title');
}.property('loggingIn'),
loginDisabled: function() {
@ -69,7 +69,7 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
}, function(result) {
// Failed to login
loginController.flash(Em.String.i18n('login.error'), 'error');
loginController.flash(I18n.t('login.error'), 'error');
loginController.set('loggingIn', false);
});
@ -78,7 +78,7 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
authMessage: (function() {
if (this.blank('authenticate')) return "";
return Em.String.i18n("login." + (this.get('authenticate')) + ".message");
return I18n.t("login." + (this.get('authenticate')) + ".message");
}).property('authenticate'),
twitterLogin: function() {
@ -128,12 +128,12 @@ Discourse.LoginController = Discourse.Controller.extend(Discourse.ModalFunctiona
authenticationComplete: function(options) {
if (options.awaiting_approval) {
this.flash(Em.String.i18n('login.awaiting_approval'), 'success');
this.flash(I18n.t('login.awaiting_approval'), 'success');
this.set('authenticate', null);
return;
}
if (options.awaiting_activation) {
this.flash(Em.String.i18n('login.awaiting_confirmation'), 'success');
this.flash(I18n.t('login.awaiting_confirmation'), 'success');
this.set('authenticate', null);
return;
}

View File

@ -20,8 +20,8 @@ Discourse.MergeTopicController = Discourse.ObjectController.extend(Discourse.Sel
}.property('selectedTopicId', 'saving'),
buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n('saving');
return Em.String.i18n('topic.merge_topic.title');
if (this.get('saving')) return I18n.t('saving');
return I18n.t('topic.merge_topic.title');
}.property('saving'),
movePostsToExistingTopic: function() {
@ -46,7 +46,7 @@ Discourse.MergeTopicController = Discourse.ObjectController.extend(Discourse.Sel
Em.run.next(function() { Discourse.URL.routeTo(result.url); });
}, function() {
// Error moving posts
mergeTopicController.flash(Em.String.i18n('topic.merge_topic.error'));
mergeTopicController.flash(I18n.t('topic.merge_topic.error'));
mergeTopicController.set('saving', false);
});
return false;

View File

@ -20,35 +20,35 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({
digestFrequencies: (function() {
var freqs;
freqs = Em.A();
freqs.addObject({ name: Em.String.i18n('user.email_digests.daily'), value: 1 });
freqs.addObject({ name: Em.String.i18n('user.email_digests.weekly'), value: 7 });
freqs.addObject({ name: Em.String.i18n('user.email_digests.bi_weekly'), value: 14 });
freqs.addObject({ name: I18n.t('user.email_digests.daily'), value: 1 });
freqs.addObject({ name: I18n.t('user.email_digests.weekly'), value: 7 });
freqs.addObject({ name: I18n.t('user.email_digests.bi_weekly'), value: 14 });
return freqs;
}).property(),
autoTrackDurations: (function() {
var freqs;
freqs = Em.A();
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.never'), value: -1 });
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.always'), value: 0 });
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.after_n_seconds', { count: 30 }), value: 30000 });
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.after_n_minutes', { count: 1 }), value: 60000 });
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.after_n_minutes', { count: 2 }), value: 120000 });
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.after_n_minutes', { count: 3 }), value: 180000 });
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.after_n_minutes', { count: 4 }), value: 240000 });
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.after_n_minutes', { count: 5 }), value: 300000 });
freqs.addObject({ name: Em.String.i18n('user.auto_track_options.after_n_minutes', { count: 10 }), value: 600000 });
freqs.addObject({ name: I18n.t('user.auto_track_options.never'), value: -1 });
freqs.addObject({ name: I18n.t('user.auto_track_options.always'), value: 0 });
freqs.addObject({ name: I18n.t('user.auto_track_options.after_n_seconds', { count: 30 }), value: 30000 });
freqs.addObject({ name: I18n.t('user.auto_track_options.after_n_minutes', { count: 1 }), value: 60000 });
freqs.addObject({ name: I18n.t('user.auto_track_options.after_n_minutes', { count: 2 }), value: 120000 });
freqs.addObject({ name: I18n.t('user.auto_track_options.after_n_minutes', { count: 3 }), value: 180000 });
freqs.addObject({ name: I18n.t('user.auto_track_options.after_n_minutes', { count: 4 }), value: 240000 });
freqs.addObject({ name: I18n.t('user.auto_track_options.after_n_minutes', { count: 5 }), value: 300000 });
freqs.addObject({ name: I18n.t('user.auto_track_options.after_n_minutes', { count: 10 }), value: 600000 });
return freqs;
}).property(),
considerNewTopicOptions: (function() {
var opts;
opts = Em.A();
opts.addObject({ name: Em.String.i18n('user.new_topic_duration.not_viewed'), value: -1 });
opts.addObject({ name: Em.String.i18n('user.new_topic_duration.after_n_days', { count: 1 }), value: 60 * 24 });
opts.addObject({ name: Em.String.i18n('user.new_topic_duration.after_n_days', { count: 2 }), value: 60 * 48 });
opts.addObject({ name: Em.String.i18n('user.new_topic_duration.after_n_weeks', { count: 1 }), value: 7 * 60 * 24 });
opts.addObject({ name: Em.String.i18n('user.new_topic_duration.last_here'), value: -2 });
opts.addObject({ name: I18n.t('user.new_topic_duration.not_viewed'), value: -1 });
opts.addObject({ name: I18n.t('user.new_topic_duration.after_n_days', { count: 1 }), value: 60 * 24 });
opts.addObject({ name: I18n.t('user.new_topic_duration.after_n_days', { count: 2 }), value: 60 * 48 });
opts.addObject({ name: I18n.t('user.new_topic_duration.after_n_weeks', { count: 1 }), value: 7 * 60 * 24 });
opts.addObject({ name: I18n.t('user.new_topic_duration.last_here'), value: -2 });
return opts;
}).property(),
@ -72,30 +72,30 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({
}, function() {
// model failed to save
preferencesController.set('saving', false);
alert(Em.String.i18n('generic_error'));
alert(I18n.t('generic_error'));
});
},
saveButtonText: (function() {
if (this.get('saving')) return Em.String.i18n('saving');
return Em.String.i18n('save');
if (this.get('saving')) return I18n.t('saving');
return I18n.t('save');
}).property('saving'),
changePassword: function() {
var preferencesController = this;
if (!this.get('passwordProgress')) {
this.set('passwordProgress', Em.String.i18n("user.change_password.in_progress"));
this.set('passwordProgress', I18n.t("user.change_password.in_progress"));
return this.get('content').changePassword().then(function() {
// password changed
preferencesController.setProperties({
changePasswordProgress: false,
passwordProgress: Em.String.i18n("user.change_password.success")
passwordProgress: I18n.t("user.change_password.success")
});
}, function() {
// password failed to change
preferencesController.setProperties({
changePasswordProgress: false,
passwordProgress: Em.String.i18n("user.change_password.error")
passwordProgress: I18n.t("user.change_password.error")
});
});
}

View File

@ -29,8 +29,8 @@ Discourse.PreferencesEmailController = Discourse.ObjectController.extend({
}).observes('content.email'),
saveButtonText: (function() {
if (this.get('saving')) return Em.String.i18n("saving");
return Em.String.i18n("user.change_email.action");
if (this.get('saving')) return I18n.t("saving");
return I18n.t("user.change_email.action");
}).property('saving'),
changeEmail: function() {

View File

@ -28,7 +28,7 @@ Discourse.PreferencesUsernameController = Discourse.ObjectController.extend({
checkTaken: function() {
if( this.get('newUsername') && this.get('newUsername').length < 3 ) {
this.set('errorMessage', Em.String.i18n('user.name.too_short'));
this.set('errorMessage', I18n.t('user.name.too_short'));
} else {
var preferencesUsernameController = this;
this.set('taken', false);
@ -46,13 +46,13 @@ Discourse.PreferencesUsernameController = Discourse.ObjectController.extend({
}.observes('newUsername'),
saveButtonText: function() {
if (this.get('saving')) return Em.String.i18n("saving");
return Em.String.i18n("user.change_username.action");
if (this.get('saving')) return I18n.t("saving");
return I18n.t("user.change_username.action");
}.property('saving'),
changeUsername: function() {
var preferencesUsernameController = this;
return bootbox.confirm(Em.String.i18n("user.change_username.confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) {
return bootbox.confirm(I18n.t("user.change_username.confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
if (result) {
preferencesUsernameController.set('saving', true);
preferencesUsernameController.get('content').changeUsername(preferencesUsernameController.get('newUsername')).then(function() {

View File

@ -20,8 +20,8 @@ Discourse.SplitTopicController = Discourse.ObjectController.extend(Discourse.Sel
}.property('saving', 'topicName'),
buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n('saving');
return Em.String.i18n('topic.split_topic.action');
if (this.get('saving')) return I18n.t('saving');
return I18n.t('topic.split_topic.action');
}.property('saving'),
movePostsToNewTopic: function() {
@ -40,7 +40,7 @@ Discourse.SplitTopicController = Discourse.ObjectController.extend(Discourse.Sel
Em.run.next(function() { Discourse.URL.routeTo(result.url); });
}, function() {
// Error moving posts
splitTopicController.flash(Em.String.i18n('topic.split_topic.error'));
splitTopicController.flash(I18n.t('topic.split_topic.error'));
splitTopicController.set('saving', false);
});
return false;

View File

@ -161,7 +161,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
if (error && error.responseText) {
bootbox.alert($.parseJSON(error.responseText).errors[0]);
} else {
bootbox.alert(Em.String.i18n('generic_error'));
bootbox.alert(I18n.t('generic_error'));
}
});
@ -172,7 +172,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
deleteSelected: function() {
var topicController = this;
bootbox.confirm(Em.String.i18n("post.delete.confirm", { count: this.get('selectedPostsCount')}), function(result) {
bootbox.confirm(I18n.t("post.delete.confirm", { count: this.get('selectedPostsCount')}), function(result) {
if (result) {
// If all posts are selected, it's the same thing as deleting the topic
@ -210,7 +210,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
promise.then(function() {
Discourse.Post.loadQuote(post.get('id')).then(function(q) {
composerController.appendText("" + (Em.String.i18n("post.continue_discussion", {
composerController.appendText("" + (I18n.t("post.continue_discussion", {
postLink: postLink
})) + "\n\n" + q);
});
@ -251,7 +251,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
var topicController = this;
this.unsubscribe();
this.get('content').destroy().then(function() {
topicController.set('message', Em.String.i18n('topic.deleted'));
topicController.set('message', I18n.t('topic.deleted'));
topicController.set('loaded', false);
});
},
@ -356,7 +356,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
toggleBookmark: function(post) {
if (!Discourse.User.current()) {
alert(Em.String.i18n("bookmarks.not_bookmarked"));
alert(I18n.t("bookmarks.not_bookmarked"));
return;
}
post.toggleProperty('bookmarked');
@ -382,7 +382,7 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
if (Discourse.User.current('staff')) {
post.set('deleted_at', new Date());
} else {
post.set('cooked', Discourse.Markdown.cook(Em.String.i18n("post.deleted_by_author")));
post.set('cooked', Discourse.Markdown.cook(I18n.t("post.deleted_by_author")));
post.set('can_delete', false);
post.set('version', post.get('version') + 1);
}

View File

@ -66,7 +66,7 @@ Ember.Handlebars.registerBoundHelper('boundCategoryLink', function(category) {
Handlebars.registerHelper('titledLinkTo', function(name, object) {
var options = [].slice.call(arguments, -1)[0];
if (options.hash.titleKey) {
options.hash.title = Em.String.i18n(options.hash.titleKey);
options.hash.title = I18n.t(options.hash.titleKey);
}
if (arguments.length === 3) {
return Ember.Handlebars.helpers.linkTo.call(this, name, object, options);
@ -254,7 +254,7 @@ Handlebars.registerHelper('number', function(property, options) {
}
title = orig;
if (options.hash.numberKey) {
title = Em.String.i18n(options.hash.numberKey, {
title = I18n.t(options.hash.numberKey, {
number: orig
});
}
@ -308,6 +308,6 @@ Handlebars.registerHelper('faqLink', function(property, options) {
return new Handlebars.SafeString(
"<a href='" +
(Discourse.SiteSettings.faq_url.length > 0 ? Discourse.SiteSettings.faq_url : Discourse.getURL('/faq')) +
"'>" + Em.String.i18n('faq') + "</a>"
"'>" + I18n.t('faq') + "</a>"
);
});

View File

@ -1,3 +1,16 @@
/**
We always prefix with "js." to select exactly what we want passed
through to the front end.
**/
var oldI18nlookup = I18n.lookup;
I18n.lookup = function() {
// jshint doesn't like when we change the arguments directly...
var args = arguments;
if (args.length > 0) { args[0] = "js." + args[0]; }
return oldI18nlookup.apply(this, args);
};
/**
Look up a translation for an i18n key in our dictionary.
@ -12,22 +25,9 @@ Ember.Handlebars.registerHelper('i18n', function(property, options) {
_.each(params, function(value, key) {
params[key] = Em.Handlebars.get(_this, value, options);
});
return Ember.String.i18n(property, params);
return I18n.t(property, params);
});
/* We always prefix with .js to select exactly what we want passed through to the front end.
*/
/**
Look up a translation for an i18n key in our dictionary.
@method i18n
@for Ember.String
**/
Ember.String.i18n = function(scope, options) {
return I18n.translate("js." + scope, options);
};
/**
Set up an i18n binding that will update as a count changes, complete with pluralization.
@ -39,9 +39,7 @@ Ember.Handlebars.registerHelper('countI18n', function(key, options) {
tagName: 'span',
render: function(buffer) {
buffer.push(Ember.String.i18n(key, {
count: this.get('count')
}));
buffer.push(I18n.t(key, { count: this.get('count') }));
},
countChanged: function() {
@ -54,8 +52,6 @@ Ember.Handlebars.registerHelper('countI18n', function(key, options) {
if (Ember.EXTEND_PROTOTYPES) {
String.prototype.i18n = function(options) {
return Ember.String.i18n(String(this), options);
return I18n.t(String(this), options);
};
}

View File

@ -13,12 +13,12 @@ Discourse.ActionSummary = Discourse.Model.extend({
var action = this.get('actionType.name_key');
if (this.get('acted')) {
if (this.get('count') <= 1) {
return Em.String.i18n('post.actions.by_you.' + action);
return I18n.t('post.actions.by_you.' + action);
} else {
return Em.String.i18n('post.actions.by_you_and_others.' + action, { count: this.get('count') - 1 });
return I18n.t('post.actions.by_you_and_others.' + action, { count: this.get('count') - 1 });
}
} else {
return Em.String.i18n('post.actions.by_others.' + action, { count: this.get('count') });
return I18n.t('post.actions.by_others.' + action, { count: this.get('count') });
}
}.property('count', 'acted', 'actionType'),

View File

@ -60,7 +60,7 @@ Discourse.Composer = Discourse.Model.extend({
if (topic) {
var postNumber = this.get('post.post_number');
postLink = "<a href='" + (topic.get('url')) + "/" + postNumber + "'>" +
Em.String.i18n("post.post_number", { number: postNumber }) + "</a>";
I18n.t("post.post_number", { number: postNumber }) + "</a>";
topicLink = "<a href='" + (topic.get('url')) + "'> " + (Handlebars.Utils.escapeExpression(topic.get('title'))) + "</a>";
}
@ -68,7 +68,7 @@ Discourse.Composer = Discourse.Model.extend({
post = this.get('post');
if (post) {
postDescription = Em.String.i18n('post.' + this.get('action'), {
postDescription = I18n.t('post.' + this.get('action'), {
link: postLink,
replyAvatar: Discourse.Utilities.tinyAvatar(post.get('username')),
username: this.get('post.username')
@ -76,24 +76,24 @@ Discourse.Composer = Discourse.Model.extend({
var replyUsername = post.get('reply_to_user.username');
if (replyUsername && this.get('action') === EDIT) {
postDescription += " " + Em.String.i18n("post.in_reply_to") + " " +
postDescription += " " + I18n.t("post.in_reply_to") + " " +
Discourse.Utilities.tinyAvatar(replyUsername) + " " + replyUsername;
}
}
switch (this.get('action')) {
case PRIVATE_MESSAGE: return Em.String.i18n('topic.private_message');
case CREATE_TOPIC: return Em.String.i18n('topic.create_long');
case PRIVATE_MESSAGE: return I18n.t('topic.private_message');
case CREATE_TOPIC: return I18n.t('topic.create_long');
case REPLY:
case EDIT:
if (postDescription) return postDescription;
if (topic) return Em.String.i18n('post.reply_topic', { link: topicLink });
if (topic) return I18n.t('post.reply_topic', { link: topicLink });
}
}.property('action', 'post', 'topic', 'topic.title'),
toggleText: function() {
return this.get('showPreview') ? Em.String.i18n('composer.hide_preview') : Em.String.i18n('composer.show_preview');
return this.get('showPreview') ? I18n.t('composer.hide_preview') : I18n.t('composer.show_preview');
}.property('showPreview'),
hidePreview: Em.computed.not('showPreview'),
@ -139,10 +139,10 @@ Discourse.Composer = Discourse.Model.extend({
// The text for the save button
saveText: function() {
switch (this.get('action')) {
case EDIT: return Em.String.i18n('composer.save_edit');
case REPLY: return Em.String.i18n('composer.reply');
case CREATE_TOPIC: return Em.String.i18n('composer.create_topic');
case PRIVATE_MESSAGE: return Em.String.i18n('composer.create_pm');
case EDIT: return I18n.t('composer.save_edit');
case REPLY: return I18n.t('composer.reply');
case CREATE_TOPIC: return I18n.t('composer.create_topic');
case PRIVATE_MESSAGE: return I18n.t('composer.create_pm');
}
}.property('action'),
@ -235,13 +235,13 @@ Discourse.Composer = Discourse.Model.extend({
var titleDiff = this.get('missingTitleCharacters');
if (titleDiff > 0) {
this.flashDraftStatusForNewUser();
return this.set('draftStatus', Em.String.i18n('composer.min_length.need_more_for_title', { n: titleDiff }));
return this.set('draftStatus', I18n.t('composer.min_length.need_more_for_title', { n: titleDiff }));
}
// 'reply' is focused
} else if ($reply.is(':focus')) {
var replyDiff = this.get('missingReplyCharacters');
if (replyDiff > 0) {
return this.set('draftStatus', Em.String.i18n('composer.min_length.need_more_for_reply', { n: replyDiff }));
return this.set('draftStatus', I18n.t('composer.min_length.need_more_for_reply', { n: replyDiff }));
}
}
@ -415,7 +415,7 @@ Discourse.Composer = Discourse.Model.extend({
if (response && response.errors) {
promise.reject(response.errors[0]);
} else {
promise.reject(Em.String.i18n('generic_error'));
promise.reject(I18n.t('generic_error'));
}
post.set('cooked', oldCooked);
composer.set('composeState', OPEN);
@ -525,16 +525,16 @@ Discourse.Composer = Discourse.Model.extend({
usernames: this.get('targetUsernames')
};
this.set('draftStatus', Em.String.i18n('composer.saving_draft_tip'));
this.set('draftStatus', I18n.t('composer.saving_draft_tip'));
var composer = this;
// try to save the draft
return Discourse.Draft.save(this.get('draftKey'), this.get('draftSequence'), data)
.then(function() {
composer.set('draftStatus', Em.String.i18n('composer.saved_draft_tip'));
composer.set('draftStatus', I18n.t('composer.saved_draft_tip'));
}, function() {
composer.set('draftStatus', Em.String.i18n('composer.drafts_offline'));
composer.set('draftStatus', I18n.t('composer.drafts_offline'));
});
},

View File

@ -20,7 +20,7 @@ Discourse.Notification = Discourse.Model.extend({
rendered: function() {
var notificationName = Discourse.Site.instance().get('notificationLookup')[this.notification_type];
return Em.String.i18n("notifications." + notificationName, {
return I18n.t("notifications." + notificationName, {
username: this.data.display_username,
link: "<a href='" + (this.get('url')) + "'>" + this.data.topic_title + "</a>"
});

View File

@ -62,14 +62,14 @@ Discourse.Post = Discourse.Model.extend({
// Custom tooltips for the bookmark icons
bookmarkTooltip: function() {
if (this.get('bookmarked')) return Em.String.i18n('bookmarks.created');
if (this.get('bookmarked')) return I18n.t('bookmarks.created');
if (!this.get('read')) return "";
var topic = this.get('topic');
if (topic && topic.get('last_read_post_number') === this.get('post_number')) {
return Em.String.i18n('bookmarks.last_read');
return I18n.t('bookmarks.last_read');
}
return Em.String.i18n('bookmarks.not_bookmarked');
return I18n.t('bookmarks.not_bookmarked');
}.property('read', 'topic.last_read_post_number', 'bookmarked'),
bookmarkedChanged: function() {
@ -83,7 +83,7 @@ Discourse.Post = Discourse.Model.extend({
if (error && error.responseText) {
bootbox.alert($.parseJSON(error.responseText).errors[0]);
} else {
bootbox.alert(Em.String.i18n('generic_error'));
bootbox.alert(I18n.t('generic_error'));
}
});

View File

@ -118,14 +118,14 @@ Discourse.PostStream = Em.Object.extend({
var streamFilters = this.get('streamFilters');
if (streamFilters.filter && streamFilters.filter === "best_of") {
return Em.String.i18n("topic.filters.best_of", {
n_best_posts: Em.String.i18n("topic.filters.n_best_posts", { count: this.get('filteredPostsCount') }),
of_n_posts: Em.String.i18n("topic.filters.of_n_posts", { count: this.get('topic.posts_count') })
return I18n.t("topic.filters.best_of", {
n_best_posts: I18n.t("topic.filters.n_best_posts", { count: this.get('filteredPostsCount') }),
of_n_posts: I18n.t("topic.filters.of_n_posts", { count: this.get('topic.posts_count') })
});
} else if (streamFilters.username_filters) {
return Em.String.i18n("topic.filters.user", {
n_posts: Em.String.i18n("topic.filters.n_posts", { count: this.get('filteredPostsCount') }),
by_n_users: Em.String.i18n("topic.filters.by_n_users", { count: streamFilters.username_filters.length })
return I18n.t("topic.filters.user", {
n_posts: I18n.t("topic.filters.n_posts", { count: this.get('filteredPostsCount') }),
by_n_users: I18n.t("topic.filters.by_n_users", { count: streamFilters.username_filters.length })
});
}
return "";
@ -614,21 +614,21 @@ Discourse.PostStream = Em.Object.extend({
// If the result was 404 the post is not found
if (status === 404) {
topic.set('errorTitle', Em.String.i18n('topic.not_found.title'));
topic.set('message', Em.String.i18n('topic.not_found.description'));
topic.set('errorTitle', I18n.t('topic.not_found.title'));
topic.set('message', I18n.t('topic.not_found.description'));
return;
}
// If the result is 403 it means invalid access
if (status === 403) {
topic.set('errorTitle', Em.String.i18n('topic.invalid_access.title'));
topic.set('message', Em.String.i18n('topic.invalid_access.description'));
topic.set('errorTitle', I18n.t('topic.invalid_access.title'));
topic.set('message', I18n.t('topic.invalid_access.description'));
return;
}
// Otherwise supply a generic error message
topic.set('errorTitle', Em.String.i18n('topic.server_error.title'));
topic.set('message', Em.String.i18n('topic.server_error.description'));
topic.set('errorTitle', I18n.t('topic.server_error.title'));
topic.set('message', I18n.t('topic.server_error.description'));
}
});

View File

@ -14,7 +14,7 @@ Discourse.ShareLink = Discourse.Model.extend({
}.property('target', 'link', 'topicTitle'),
title: function() {
return Em.String.i18n("share." + this.get('target'));
return I18n.t("share." + this.get('target'));
}.property('target'),
iconClass: function() {

View File

@ -147,7 +147,7 @@ Discourse.Topic = Discourse.Model.extend({
}).property('starred'),
favoriteTooltip: (function() {
return Em.String.i18n(this.get('favoriteTooltipKey'));
return I18n.t(this.get('favoriteTooltipKey'));
}).property('favoriteTooltipKey'),
toggleStar: function() {
@ -163,7 +163,7 @@ Discourse.Topic = Discourse.Model.extend({
if (error && error.responseText) {
bootbox.alert($.parseJSON(error.responseText).errors);
} else {
bootbox.alert(Em.String.i18n('generic_error'));
bootbox.alert(I18n.t('generic_error'));
}
});
},

View File

@ -40,7 +40,7 @@ Discourse.TopicDetails = Discourse.Model.extend({
if (typeof this.get('notifications_reason_id') === 'number') {
locale_string += "_" + this.get('notifications_reason_id');
}
return Em.String.i18n(locale_string, { username: Discourse.User.current('username_lower') });
return I18n.t(locale_string, { username: Discourse.User.current('username_lower') });
}.property('notification_level', 'notifications_reason_id'),

View File

@ -49,11 +49,11 @@ Discourse.User = Discourse.Model.extend({
statusIcon: function() {
var desc;
if(this.get('admin')) {
desc = Em.String.i18n('user.admin', {user: this.get("name")});
desc = I18n.t('user.admin', {user: this.get("name")});
return '<i class="icon icon-trophy" title="' + desc + '" alt="' + desc + '"></i>';
}
if(this.get('moderator')){
desc = Em.String.i18n('user.moderator', {user: this.get("name")});
desc = I18n.t('user.moderator', {user: this.get("name")});
return '<i class="icon icon-magic" title="' + desc + '" alt="' + desc + '"></i>';
}
return null;

View File

@ -20,51 +20,51 @@ Discourse.UserAction = Discourse.Model.extend({
if (this.get('isPM')) {
icon = '<i class="icon icon-envelope-alt" title="{{i18n user.stream.private_message}}"></i>';
if (sameUser) {
sentence = Em.String.i18n('user_action.sent_by_you', { userUrl: this.get('userUrl') });
sentence = I18n.t('user_action.sent_by_you', { userUrl: this.get('userUrl') });
} else {
sentence = Em.String.i18n('user_action.sent_by_user', { user: this.get('name'), userUrl: this.get('userUrl') });
sentence = I18n.t('user_action.sent_by_user', { user: this.get('name'), userUrl: this.get('userUrl') });
}
} else {
if (sameUser) {
sentence = Em.String.i18n('user_action.posted_by_you', { userUrl: this.get('userUrl') });
sentence = I18n.t('user_action.posted_by_you', { userUrl: this.get('userUrl') });
} else {
sentence = Em.String.i18n('user_action.posted_by_user', { user: this.get('name'), userUrl: this.get('userUrl') });
sentence = I18n.t('user_action.posted_by_user', { user: this.get('name'), userUrl: this.get('userUrl') });
}
}
} else if (action === ua.NEW_TOPIC) {
if (sameUser) {
sentence = Em.String.i18n('user_action.you_posted_topic', { userUrl: this.get('userUrl'), topicUrl: this.get('replyUrl') });
sentence = I18n.t('user_action.you_posted_topic', { userUrl: this.get('userUrl'), topicUrl: this.get('replyUrl') });
} else {
sentence = Em.String.i18n('user_action.user_posted_topic', { user: this.get('name'), userUrl: this.get('userUrl'), topicUrl: this.get('replyUrl') });
sentence = I18n.t('user_action.user_posted_topic', { user: this.get('name'), userUrl: this.get('userUrl'), topicUrl: this.get('replyUrl') });
}
} else if (action === ua.POST || action === ua.RESPONSE) {
if (this.get('reply_to_post_number')) {
if (sameUser) {
sentence = Em.String.i18n('user_action.you_replied_to_post', { post_number: '#' + this.get('reply_to_post_number'),
sentence = I18n.t('user_action.you_replied_to_post', { post_number: '#' + this.get('reply_to_post_number'),
userUrl: this.get('userUrl'), postUrl: this.get('postUrl') });
} else {
sentence = Em.String.i18n('user_action.user_replied_to_post', { user: this.get('name'),
sentence = I18n.t('user_action.user_replied_to_post', { user: this.get('name'),
post_number: '#' + this.get('reply_to_post_number'), userUrl: this.get('userUrl'), postUrl: this.get('postUrl') });
}
} else {
if (sameUser) {
sentence = Em.String.i18n('user_action.you_replied_to_topic', { userUrl: this.get('userUrl'),
sentence = I18n.t('user_action.you_replied_to_topic', { userUrl: this.get('userUrl'),
topicUrl: this.get('replyUrl') });
} else {
sentence = Em.String.i18n('user_action.user_replied_to_topic', { user: this.get('name'),
sentence = I18n.t('user_action.user_replied_to_topic', { user: this.get('name'),
userUrl: this.get('userUrl'), topicUrl: this.get('replyUrl') });
}
}
} else if (action === ua.MENTION) {
if (sameUser) {
sentence = Em.String.i18n('user_action.you_mentioned_user', { user: this.get('target_name'),
sentence = I18n.t('user_action.you_mentioned_user', { user: this.get('target_name'),
user1Url: this.get('userUrl'), user2Url: this.get('targetUserUrl') });
} else {
if (this.get('target_username') === Discourse.User.current('username')) {
sentence = Em.String.i18n('user_action.user_mentioned_you', { user: this.get('name'),
sentence = I18n.t('user_action.user_mentioned_you', { user: this.get('name'),
user1Url: this.get('userUrl'), user2Url: this.get('targetUserUrl') });
} else {
sentence = Em.String.i18n('user_action.user_mentioned_user', { user: this.get('name'),
sentence = I18n.t('user_action.user_mentioned_user', { user: this.get('name'),
another_user: this.get('target_name'), user1Url: this.get('userUrl'), user2Url: this.get('targetUserUrl') });
}
}

View File

@ -15,7 +15,7 @@ Discourse.UserActionStat = Discourse.Model.extend({
}.property('action_type'),
description: function() {
return Em.String.i18n('user_action_groups.' + this.get('action_type'));
return I18n.t('user_action_groups.' + this.get('action_type'));
}.property('description'),
isResponse: function() {

View File

@ -49,23 +49,23 @@ Discourse.ActionsHistoryView = Discourse.View.extend({
if(postUrl) {
key = key + "_with_url";
}
buffer.push(" " + Em.String.i18n(key, { icons: iconsHtml, postUrl: postUrl}) + ".");
buffer.push(" " + I18n.t(key, { icons: iconsHtml, postUrl: postUrl}) + ".");
} else {
buffer.push("<a href='#' data-who-acted='" + (c.get('id')) + "'>" + (c.get('description')) + "</a>.");
}
if (c.get('can_act') && !c.get('actionType.is_custom_flag')) {
actionString = Em.String.i18n("post.actions.it_too." + c.get('actionType.name_key'));
actionString = I18n.t("post.actions.it_too." + c.get('actionType.name_key'));
buffer.push(" <a href='#' data-act='" + (c.get('id')) + "'>" + actionString + "</a>.");
}
if (c.get('can_undo')) {
actionString = Em.String.i18n("post.actions.undo." + c.get('actionType.name_key') );
actionString = I18n.t("post.actions.undo." + c.get('actionType.name_key') );
buffer.push(" <a href='#' data-undo='" + (c.get('id')) + "'>" + actionString + "</a>.");
}
if (c.get('can_clear_flags')) {
buffer.push(" <a href='#' data-clear-flags='" + (c.get('id')) + "'>" + (Em.String.i18n("post.actions.clear_flags", { count: c.count })) + "</a>.");
buffer.push(" <a href='#' data-clear-flags='" + (c.get('id')) + "'>" + (I18n.t("post.actions.clear_flags", { count: c.count })) + "</a>.");
}
buffer.push("</div>");

View File

@ -10,7 +10,7 @@ Discourse.AutoCloseFormView = Ember.View.extend({
templateName: 'auto_close_form',
label: function() {
return Em.String.i18n( this.get('labelKey') || 'composer.auto_close_label' );
return I18n.t( this.get('labelKey') || 'composer.auto_close_label' );
}.property('labelKey'),
autoCloseChanged: function() {

View File

@ -12,11 +12,11 @@ Discourse.ButtonView = Discourse.View.extend({
attributeBindings: ['data-not-implemented', 'title', 'data-toggle', 'data-share-url'],
title: function() {
return Em.String.i18n(this.get('helpKey') || this.get('textKey'));
return I18n.t(this.get('helpKey') || this.get('textKey'));
}.property('helpKey'),
text: function() {
return Em.String.i18n(this.get('textKey'));
return I18n.t(this.get('textKey'));
}.property('textKey'),
render: function(buffer) {

View File

@ -40,8 +40,8 @@ Discourse.DropdownButtonView = Discourse.View.extend({
_.each(this.get('dropDownContent'), function(row) {
var id = row[0],
textKey = row[1],
title = Em.String.i18n(textKey + ".title"),
description = Em.String.i18n(textKey + ".description");
title = I18n.t(textKey + ".title"),
description = I18n.t(textKey + ".description");
buffer.push("<li data-id=\"" + id + "\"><a href='#'>");
buffer.push("<span class='title'>" + title + "</span>");

View File

@ -7,7 +7,7 @@
@module Discourse
**/
Discourse.NotificationsButton = Discourse.DropdownButtonView.extend({
title: Em.String.i18n('topic.notifications.title'),
title: I18n.t('topic.notifications.title'),
longDescriptionBinding: 'topic.details.notificationReasonText',
dropDownContent: [
@ -35,7 +35,7 @@ Discourse.NotificationsButton = Discourse.DropdownButtonView.extend({
case 'muted': return '<i class="icon-remove-sign"></i>&nbsp;';
}
})();
return icon + (Ember.String.i18n("topic.notifications." + key + ".title")) + "<span class='caret'></span>";
return icon + (I18n.t("topic.notifications." + key + ".title")) + "<span class='caret'></span>";
}.property('topic.details.notification_level'),
clicked: function(id) {

View File

@ -17,7 +17,7 @@ Discourse.ReplyButton = Discourse.ButtonView.extend({
var customTitle = this.get("parentView.replyButtonText" + archetypeCapitalized);
if (customTitle) { return customTitle; }
return Em.String.i18n("topic.reply.title");
return I18n.t("topic.reply.title");
}.property(),
renderIcon: function(buffer) {

View File

@ -15,7 +15,7 @@ Discourse.ComboboxView = Discourse.View.extend({
// Add none option if required
if (this.get('none')) {
buffer.push('<option value="">' + (Ember.String.i18n(this.get('none'))) + "</option>");
buffer.push('<option value="">' + (I18n.t(this.get('none'))) + "</option>");
}
var selected = this.get('value');

View File

@ -302,12 +302,12 @@ Discourse.ComposerView = Discourse.View.extend({
case 0: return;
// 413 == entity too large, returned usually from nginx
case 413:
bootbox.alert(Em.String.i18n('post.errors.upload_too_large', {max_size_kb: Discourse.SiteSettings.max_upload_size_kb}));
bootbox.alert(I18n.t('post.errors.upload_too_large', {max_size_kb: Discourse.SiteSettings.max_upload_size_kb}));
return;
// 415 == media type not authorized
case 415:
var extensions = Discourse.SiteSettings.authorized_extensions.replace(/\|/g, ", ");
bootbox.alert(Em.String.i18n('post.errors.upload_not_authorized', { authorized_extensions: extensions }));
bootbox.alert(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: extensions }));
return;
// 422 == there has been an error on the server (mostly due to FastImage)
case 422:
@ -316,7 +316,7 @@ Discourse.ComposerView = Discourse.View.extend({
}
}
// otherwise, display a generic error message
bootbox.alert(Em.String.i18n('post.errors.upload'));
bootbox.alert(I18n.t('post.errors.upload'));
});
// I hate to use Em.run.later, but I don't think there's a way of waiting for a CSS transition
@ -378,11 +378,11 @@ Discourse.ComposerView = Discourse.View.extend({
missingChars = this.get('model.missingTitleCharacters'),
reason;
if( titleLength < 1 ){
reason = Em.String.i18n('composer.error.title_missing');
reason = I18n.t('composer.error.title_missing');
} else if( missingChars > 0 ) {
reason = Em.String.i18n('composer.error.title_too_short', {min: this.get('model.minimumTitleLength')});
reason = I18n.t('composer.error.title_too_short', {min: this.get('model.minimumTitleLength')});
} else if( titleLength > Discourse.SiteSettings.max_topic_title_length ) {
reason = Em.String.i18n('composer.error.title_too_long', {max: Discourse.SiteSettings.max_topic_title_length});
reason = I18n.t('composer.error.title_too_long', {max: Discourse.SiteSettings.max_topic_title_length});
}
if( reason ) {
@ -392,7 +392,7 @@ Discourse.ComposerView = Discourse.View.extend({
categoryValidation: function() {
if( !Discourse.SiteSettings.allow_uncategorized_topics && !this.get('model.categoryName')) {
return Discourse.InputValidation.create({ failed: true, reason: Em.String.i18n('composer.error.category_missing') });
return Discourse.InputValidation.create({ failed: true, reason: I18n.t('composer.error.category_missing') });
}
}.property('model.categoryName'),
@ -401,9 +401,9 @@ Discourse.ComposerView = Discourse.View.extend({
missingChars = this.get('model.missingReplyCharacters'),
reason;
if( replyLength < 1 ){
reason = Em.String.i18n('composer.error.post_missing');
reason = I18n.t('composer.error.post_missing');
} else if( missingChars > 0 ) {
reason = Em.String.i18n('composer.error.post_length', {min: this.get('model.minimumPostLength')});
reason = I18n.t('composer.error.post_length', {min: this.get('model.minimumPostLength')});
}
if( reason ) {
@ -415,7 +415,7 @@ Discourse.ComposerView = Discourse.View.extend({
// not sure if this is the right way, keeping here for now, we could use a mixin perhaps
Discourse.NotifyingTextArea = Ember.TextArea.extend({
placeholder: function() {
return Em.String.i18n(this.get('placeholderKey'));
return I18n.t(this.get('placeholderKey'));
}.property('placeholderKey'),
didInsertElement: function() {

View File

@ -11,7 +11,7 @@ Discourse.TextField = Ember.TextField.extend({
placeholder: function() {
if( this.get('placeholderKey') ) {
return Em.String.i18n(this.get('placeholderKey'));
return I18n.t(this.get('placeholderKey'));
} else {
return '';
}

View File

@ -19,11 +19,11 @@ Discourse.ListView = Discourse.View.extend({
createTopicText: function() {
if (this.get('controller.category.name')) {
return Em.String.i18n("topic.create_in", {
return I18n.t("topic.create_in", {
categoryName: this.get('controller.category.name')
});
} else {
return Em.String.i18n("topic.create");
return I18n.t("topic.create");
}
}.property('controller.category.name')

View File

@ -8,7 +8,7 @@
**/
Discourse.ArchetypeOptionsModalView = Discourse.ModalBodyView.extend({
templateName: 'modal/archetype_options',
title: Em.String.i18n('topic.options')
title: I18n.t('topic.options')
});

View File

@ -29,7 +29,7 @@ Discourse.ColorPickerView = Discourse.ContainerView.extend({
attributeBindings: ['style', 'title'],
classNames: ['colorpicker'].concat( isUsed ? ['used-color'] : ['unused-color'] ),
style: 'background-color: #' + color + ';',
title: isUsed ? I18n.t("js.category.already_used") : null,
title: isUsed ? I18n.t("category.already_used") : null,
click: function() {
colorPickerView.set("value", color);
return false;

View File

@ -8,7 +8,7 @@
**/
Discourse.CreateAccountView = Discourse.ModalBodyView.extend({
templateName: 'modal/create_account',
title: Em.String.i18n('create_account.title'),
title: I18n.t('create_account.title'),
didInsertElement: function(e) {

View File

@ -8,5 +8,5 @@
**/
Discourse.EditTopicAutoCloseView = Discourse.ModalBodyView.extend({
templateName: 'modal/auto_close',
title: Em.String.i18n('topic.auto_close_title')
title: I18n.t('topic.auto_close_title')
});

View File

@ -8,7 +8,7 @@
**/
Discourse.FlagView = Discourse.ModalBodyView.extend({
templateName: 'modal/flag',
title: Em.String.i18n('flagging.title'),
title: I18n.t('flagging.title'),
selectedChanged: function() {
var nameKey = this.get('controller.selected.name_key');

View File

@ -8,7 +8,7 @@
**/
Discourse.ForgotPasswordView = Discourse.ModalBodyView.extend({
templateName: 'modal/forgot_password',
title: Em.String.i18n('forgot_password.title')
title: I18n.t('forgot_password.title')
});

View File

@ -8,5 +8,5 @@
**/
Discourse.HistoryView = Discourse.ModalBodyView.extend({
templateName: 'modal/history',
title: Em.String.i18n('history')
title: I18n.t('history')
});

View File

@ -9,7 +9,7 @@
Discourse.ImageSelectorView = Discourse.ModalBodyView.extend({
templateName: 'modal/image_selector',
classNames: ['image-selector'],
title: Em.String.i18n('image_selector.title'),
title: I18n.t('image_selector.title'),
upload: function() {
$('#reply-control').fileupload('add', { fileInput: $('#filename-input') });

View File

@ -8,5 +8,5 @@
**/
Discourse.InvitePrivateView = Discourse.ModalBodyView.extend({
templateName: 'modal/invite_private',
title: Em.String.i18n('topic.invite_private.title')
title: I18n.t('topic.invite_private.title')
});

View File

@ -8,7 +8,7 @@
**/
Discourse.InviteView = Discourse.ModalBodyView.extend({
templateName: 'modal/invite',
title: Em.String.i18n('topic.invite_reply.title'),
title: I18n.t('topic.invite_reply.title'),
keyUp: function(e) {

View File

@ -8,7 +8,7 @@
**/
Discourse.LoginView = Discourse.ModalBodyView.extend({
templateName: 'modal/login',
title: Em.String.i18n('login.title'),
title: I18n.t('login.title'),
mouseMove: function(e) {

View File

@ -8,7 +8,7 @@
**/
Discourse.MergeTopicView = Discourse.ModalBodyView.extend({
templateName: 'modal/merge_topic',
title: Em.String.i18n('topic.merge_topic.title')
title: I18n.t('topic.merge_topic.title')
});

View File

@ -8,5 +8,5 @@
**/
Discourse.NotActivatedView = Discourse.ModalBodyView.extend({
templateName: 'modal/not_activated',
title: Em.String.i18n('log_in')
title: I18n.t('log_in')
});

View File

@ -8,7 +8,7 @@
**/
Discourse.SplitTopicView = Discourse.ModalBodyView.extend(Discourse.SelectedPostsCount, {
templateName: 'modal/split_topic',
title: Em.String.i18n('topic.split_topic.title')
title: I18n.t('topic.split_topic.title')
});

View File

@ -20,7 +20,7 @@ Discourse.NavItemView = Discourse.View.extend({
extra = { categoryName: categoryName };
name = "category";
}
return Ember.String.i18n("filters." + name + ".help", extra);
return I18n.t("filters." + name + ".help", extra);
}.property("content.filter"),
isActive: function() {
@ -45,7 +45,7 @@ Discourse.NavItemView = Discourse.View.extend({
name = 'category';
extra.categoryName = Discourse.Formatter.toTitleCase(categoryName);
}
return I18n.t("js.filters." + name + ".title", extra);
return I18n.t("filters." + name + ".title", extra);
}.property('count'),
render: function(buffer) {

View File

@ -48,7 +48,7 @@ Discourse.PostMenuView = Discourse.View.extend({
var reply_count = post.get('reply_count');
buffer.push("<button class='show-replies' data-action='replies'>");
buffer.push("<span class='badge-posts'>" + reply_count + "</span>");
buffer.push(Em.String.i18n("post.has_replies", { count: reply_count }));
buffer.push(I18n.t("post.has_replies", { count: reply_count }));
var icon = this.get('postView.repliesShown') ? 'icon-chevron-up' : 'icon-chevron-down';
return buffer.push("<i class='icon " + icon + "'></i></button>");
@ -62,7 +62,7 @@ Discourse.PostMenuView = Discourse.View.extend({
renderDelete: function(post, buffer) {
if (post.get('post_number') === 1 && this.get('controller.model.details.can_delete')) {
buffer.push("<button title=\"" +
(Em.String.i18n("topic.actions.delete")) +
(I18n.t("topic.actions.delete")) +
"\" data-action=\"deleteTopic\" class='delete'><i class=\"icon-trash\"></i></button>");
return;
}
@ -70,12 +70,12 @@ Discourse.PostMenuView = Discourse.View.extend({
if (post.get('deleted_at')) {
if (post.get('can_recover')) {
buffer.push("<button title=\"" +
(Em.String.i18n("post.controls.undelete")) +
(I18n.t("post.controls.undelete")) +
"\" data-action=\"recover\" class=\"delete\"><i class=\"icon-undo\"></i></button>");
}
} else if (post.get('can_delete')) {
buffer.push("<button title=\"" +
(Em.String.i18n("post.controls.delete")) +
(I18n.t("post.controls.delete")) +
"\" data-action=\"delete\" class=\"delete\"><i class=\"icon-trash\"></i></button>");
}
},
@ -96,7 +96,7 @@ Discourse.PostMenuView = Discourse.View.extend({
renderLike: function(post, buffer) {
if (!post.get('actionByName.like.can_act')) return;
buffer.push("<button title=\"" +
(Em.String.i18n("post.controls.like")) +
(I18n.t("post.controls.like")) +
"\" data-action=\"like\" class='like'><i class=\"icon-heart\"></i></button>");
},
@ -109,7 +109,7 @@ Discourse.PostMenuView = Discourse.View.extend({
renderFlag: function(post, buffer) {
if (!this.present('post.flagsAvailable')) return;
buffer.push("<button title=\"" +
(Em.String.i18n("post.controls.flag")) +
(I18n.t("post.controls.flag")) +
"\" data-action=\"flag\" class='flag'><i class=\"icon-flag\"></i></button>");
},
@ -121,7 +121,7 @@ Discourse.PostMenuView = Discourse.View.extend({
renderEdit: function(post, buffer) {
if (!post.get('can_edit')) return;
buffer.push("<button title=\"" +
(Em.String.i18n("post.controls.edit")) +
(I18n.t("post.controls.edit")) +
"\" data-action=\"edit\" class='edit'><i class=\"icon-pencil\"></i></button>");
},
@ -132,7 +132,7 @@ Discourse.PostMenuView = Discourse.View.extend({
// Share button
renderShare: function(post, buffer) {
buffer.push("<button title=\"" +
(Em.String.i18n("post.controls.share")) +
(I18n.t("post.controls.share")) +
"\" data-share-url=\"" + (post.get('shareUrl')) + "\" class='share'><i class=\"icon-link\"></i></button>");
},
@ -140,9 +140,9 @@ Discourse.PostMenuView = Discourse.View.extend({
renderReply: function(post, buffer) {
if (!this.get('controller.model.details.can_create_post')) return;
buffer.push("<button title=\"" +
(Em.String.i18n("post.controls.reply")) +
(I18n.t("post.controls.reply")) +
"\" class='create' data-action=\"reply\"><i class='icon-reply'></i>" +
(Em.String.i18n("topic.reply.title")) + "</button>");
(I18n.t("topic.reply.title")) + "</button>");
},
clickReply: function() {

View File

@ -46,7 +46,7 @@ Discourse.PostView = Discourse.View.extend({
}.property('controller.selectedPostsCount'),
selectText: function() {
return this.get('selected') ? Em.String.i18n('topic.multi_select.selected', { count: this.get('controller.selectedPostsCount') }) : Em.String.i18n('topic.multi_select.select');
return this.get('selected') ? I18n.t('topic.multi_select.selected', { count: this.get('controller.selectedPostsCount') }) : I18n.t('topic.multi_select.select');
}.property('selected', 'controller.selectedPostsCount'),
repliesHidden: function() {
@ -104,7 +104,7 @@ Discourse.PostView = Discourse.View.extend({
updateQuoteElements: function($aside, desc) {
var navLink = "";
var quoteTitle = Em.String.i18n("post.follow_quote");
var quoteTitle = I18n.t("post.follow_quote");
var postNumber = $aside.data('post');
if (postNumber) {
@ -130,7 +130,7 @@ Discourse.PostView = Discourse.View.extend({
// Only add the expand/contract control if it's not a full post
var expandContract = "";
if (!$aside.data('full')) {
expandContract = "<i class='icon-" + desc + "' title='" + Em.String.i18n("post.expand_collapse") + "'></i>";
expandContract = "<i class='icon-" + desc + "' title='" + I18n.t("post.expand_collapse") + "'></i>";
$aside.css('cursor', 'pointer');
}
$('.quote-controls', $aside).html("" + expandContract + navLink);
@ -145,7 +145,7 @@ Discourse.PostView = Discourse.View.extend({
$aside.data('original-contents',$blockQuote.html());
var originalText = $blockQuote.text().trim();
$blockQuote.html(Em.String.i18n("loading"));
$blockQuote.html(I18n.t("loading"));
var topic_id = this.get('post.topic_id');
if ($aside.data('topic')) {
topic_id = $aside.data('topic');
@ -179,7 +179,7 @@ Discourse.PostView = Discourse.View.extend({
if (link.closest('.badge-category').length === 0) {
// nor in oneboxes (except when we force it)
if (link.closest(".onebox-result").length === 0 || link.hasClass("track-link")) {
link.append("<span class='badge badge-notification clicks' title='" + Em.String.i18n("topic_summary.clicks") + "'>" + lc.clicks + "</span>");
link.append("<span class='badge badge-notification clicks' title='" + I18n.t("topic_summary.clicks") + "'>" + lc.clicks + "</span>");
}
}
}

View File

@ -27,7 +27,7 @@ Discourse.QuoteButtonView = Discourse.View.extend({
**/
render: function(buffer) {
buffer.push('<i class="icon-quote-right"></i>&nbsp;&nbsp;');
buffer.push(Em.String.i18n("post.quote_reply"));
buffer.push(I18n.t("post.quote_reply"));
},
/**

View File

@ -19,13 +19,13 @@ Discourse.SearchTextField = Discourse.TextField.extend({
if (ctx) {
switch(Em.get(ctx, 'type')) {
case 'user':
return Em.String.i18n('search.prefer.user', {username: Em.get(ctx, 'user.username')});
return I18n.t('search.prefer.user', {username: Em.get(ctx, 'user.username')});
case 'category':
return Em.String.i18n('search.prefer.category', {category: Em.get(ctx, 'category.name')});
return I18n.t('search.prefer.category', {category: Em.get(ctx, 'category.name')});
}
}
return Em.String.i18n('search.placeholder');
return I18n.t('search.placeholder');
}.property('searchContext')
});

View File

@ -12,8 +12,8 @@ Discourse.ShareView = Discourse.View.extend({
classNameBindings: ['hasLink'],
title: function() {
if (this.get('controller.type') === 'topic') return Em.String.i18n('share.topic');
return Em.String.i18n('share.post');
if (this.get('controller.type') === 'topic') return I18n.t('share.topic');
return I18n.t('share.post');
}.property('controller.type'),
hasLink: function() {

View File

@ -27,25 +27,25 @@ Discourse.TopicClosingView = Discourse.View.extend({
var timeLeftString, rerenderDelay, minutesLeft = duration.asMinutes();
if (minutesLeft > 1410) {
timeLeftString = Em.String.i18n('in_n_days', {count: Math.round(duration.asDays())});
timeLeftString = I18n.t('in_n_days', {count: Math.round(duration.asDays())});
if( minutesLeft > 2160 ) {
rerenderDelay = 12 * 60 * 60000;
} else {
rerenderDelay = 60 * 60000;
}
} else if (minutesLeft > 90) {
timeLeftString = Em.String.i18n('in_n_hours', {count: Math.round(duration.asHours())});
timeLeftString = I18n.t('in_n_hours', {count: Math.round(duration.asHours())});
rerenderDelay = 30 * 60000;
} else if (minutesLeft > 2) {
timeLeftString = Em.String.i18n('in_n_minutes', {count: Math.round(duration.asMinutes())});
timeLeftString = I18n.t('in_n_minutes', {count: Math.round(duration.asMinutes())});
rerenderDelay = 60000;
} else {
timeLeftString = Em.String.i18n('in_n_seconds', {count: Math.round(duration.asSeconds())});
timeLeftString = I18n.t('in_n_seconds', {count: Math.round(duration.asSeconds())});
rerenderDelay = 1000;
}
buffer.push('<h3><i class="icon icon-time"></i> ');
buffer.push( Em.String.i18n('topic.auto_close_notice', {timeLeft: timeLeftString}) );
buffer.push( I18n.t('topic.auto_close_notice', {timeLeft: timeLeftString}) );
buffer.push('</h3>');
// TODO Sam: concerned this can cause a heavy rerender loop

View File

@ -22,7 +22,7 @@ Discourse.TopicStatusView = Discourse.View.extend({
}.observes('topic.closed', 'topic.pinned', 'topic.visible'),
renderIcon: function(buffer, name, key) {
var title = Em.String.i18n("topic_statuses." + key + ".help");
var title = I18n.t("topic_statuses." + key + ".help");
return buffer.push("<span title='" + title + "' class='topic-status'><i class='icon icon-" + name + "'></i></span>");
},

View File

@ -146,7 +146,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
var topicView = this;
this.get('topic').resetRead().then(function() {
topicView.set('controller.message', Em.String.i18n("topic.read_position_reset"));
topicView.set('controller.message', I18n.t("topic.read_position_reset"));
topicView.set('controller.loaded', false);
});
},
@ -305,7 +305,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
browseMoreMessage: function() {
var opts = {
latestLink: "<a href=\"/\">" + (Em.String.i18n("topic.view_latest_topics")) + "</a>"
latestLink: "<a href=\"/\">" + (I18n.t("topic.view_latest_topics")) + "</a>"
};
@ -313,7 +313,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
if (category) {
opts.catLink = Discourse.Utilities.categoryLink(category);
} else {
opts.catLink = "<a href=\"" + Discourse.getURL("/categories") + "\">" + (Em.String.i18n("topic.browse_all_categories")) + "</a>";
opts.catLink = "<a href=\"" + Discourse.getURL("/categories") + "\">" + (I18n.t("topic.browse_all_categories")) + "</a>";
}
var tracking = this.get('topicTrackingState');
@ -334,9 +334,9 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
});
}
else if (category) {
return Ember.String.i18n("topic.read_more_in_category", opts);
return I18n.t("topic.read_more_in_category", opts);
} else {
return Ember.String.i18n("topic.read_more", opts);
return I18n.t("topic.read_more", opts);
}
}.property('topicTrackingState.messageCount')

View File

@ -34,7 +34,7 @@ Discourse.ActivityFilterView = Discourse.View.extend({
description = Em.get(content, 'description');
} else {
count = this.get('count');
description = Em.String.i18n("user.filters.all");
description = I18n.t("user.filters.all");
}
buffer.push("<a href='#'>" + description +

View File

@ -14,7 +14,7 @@ Discourse.UserView = Discourse.View.extend({
var username;
username = this.get('user.username');
if (username) {
return Discourse.set('title', "" + (Em.String.i18n("user.profile")) + " - " + username);
return Discourse.set('title', "" + (I18n.t("user.profile")) + " - " + username);
}
}.observes('user.loaded', 'user.username')

View File

@ -399,7 +399,6 @@ var bootbox = window.bootbox || (function(document, $) {
div.find(".modal-body").html(str);
function onCancel(source) {
console.log('onCancel');
// for now source is unused, but it will be in future
var hideModal = null;
if (typeof options.onEscape === 'function') {
@ -414,7 +413,6 @@ var bootbox = window.bootbox || (function(document, $) {
// hook into the modal's keyup trigger to check for the escape key
div.on('keyup.dismiss.modal', function(e) {
console.log('keyup.dismiss.modal');
// any truthy value passed to onEscape will dismiss the dialog
// as long as the onEscape function (if defined) doesn't prevent it
if (e.which === 27 && options.onEscape !== false) {

View File

@ -4,7 +4,7 @@ window.PagedownCustom = {
insertButtons: [
{
id: 'wmd-quote-post',
description: I18n.t("js.composer.quote_post_title"),
description: I18n.t("composer.quote_post_title"),
execute: function() {
// AWFUL but I can't figure out how to call a controller method from outside our app
return Discourse.__container__.lookup('controller:composer').importQuote();

View File

@ -20,7 +20,7 @@ test("uploading one file", function() {
this.stub(bootbox, "alert");
ok(!validUpload([1, 2]));
ok(bootbox.alert.calledWith(Em.String.i18n('post.errors.too_many_uploads')));
ok(bootbox.alert.calledWith(I18n.t('post.errors.too_many_uploads')));
});
test("new user", function() {
@ -29,7 +29,7 @@ test("new user", function() {
this.stub(bootbox, "alert");
ok(!validUpload([1]));
ok(bootbox.alert.calledWith(Em.String.i18n('post.errors.upload_not_allowed_for_new_user')));
ok(bootbox.alert.calledWith(I18n.t('post.errors.upload_not_allowed_for_new_user')));
});
test("ensures an authorized upload", function() {
@ -38,7 +38,7 @@ test("ensures an authorized upload", function() {
this.stub(bootbox, "alert");
ok(!validUpload([html]));
ok(bootbox.alert.calledWith(Em.String.i18n('post.errors.upload_not_authorized', { authorized_extensions: extensions })));
ok(bootbox.alert.calledWith(I18n.t('post.errors.upload_not_authorized', { authorized_extensions: extensions })));
});
test("prevents files that are too big from being uploaded", function() {
@ -47,7 +47,7 @@ test("prevents files that are too big from being uploaded", function() {
this.stub(bootbox, "alert");
ok(!validUpload([image]));
ok(bootbox.alert.calledWith(Em.String.i18n('post.errors.upload_too_large', { max_size_kb: 5 })));
ok(bootbox.alert.calledWith(I18n.t('post.errors.upload_too_large', { max_size_kb: 5 })));
});
var dummyBlob = function() {

View File

@ -24,11 +24,11 @@
cantVote: function() {
if (!Discourse.get('currentUser')) {
bootbox.alert(Em.String.i18n('vote.not_logged_in'));
bootbox.alert(I18n.t('vote.not_logged_in'));
return false;
}
bootbox.alert(Em.String.i18n('vote.cant'));
bootbox.alert(I18n.t('vote.cant'));
return false;
},

View File

@ -2,7 +2,7 @@
window.Discourse.TopicFooterButtonsView.reopen({
replyButtonTextPoll: function() {
return Em.String.i18n("topic.reply.poll");
return I18n.t("topic.reply.poll");
}.property()
});

View File

@ -33,8 +33,8 @@
}.property('post.voteAction.can_act'),
voteButtonText: function() {
if (!this.get('post.voteAction.can_act')) return Em.String.i18n("vote.voted");
return Em.String.i18n("vote.title");
if (!this.get('post.voteAction.can_act')) return I18n.t("vote.voted");
return I18n.t("vote.title");
}.property('post.voteAction.can_act')
})

View File

@ -21,9 +21,9 @@
text: function () {
if (this.get('complete')) {
return Em.String.i18n("task.reverse");
return I18n.t("task.reverse");
} else {
return Em.String.i18n("task.complete_action");
return I18n.t("task.complete_action");
}
}.property('complete'),