Skip to content

Commit

Permalink
Removing prototypal i18n code
Browse files Browse the repository at this point in the history
refs #16, #17, #18, #19, #20, #21, TryGhost#3801

- This code was a prototype system built when Ghost was still a prototype.
  It was never fully implemented and hasn't actually worked for ages.
- Now that the admin is in Ember, it's likely we'll need a very different
  system.
  • Loading branch information
ErisDS committed Aug 16, 2014
1 parent 7f4231c commit b91dee3
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 144 deletions.
27 changes: 0 additions & 27 deletions core/server/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var downsize = require('downsize'),
hbs = require('express-hbs'),
moment = require('moment'),
polyglot = require('node-polyglot').instance,
_ = require('lodash'),
when = require('when'),

Expand Down Expand Up @@ -569,32 +568,6 @@ coreHelpers.meta_description = function (options) {
});
};

/**
* Localised string helpers
*
* @param {String} key
* @param {String} default translation
* @param {Object} options
* @return {String} A correctly internationalised string
*/
coreHelpers.e = function (key, defaultString, options) {
var output;
return when.all([
api.settings.read('defaultLang'),
api.settings.read('forceI18n')
]).then(function (values) {
if (values[0].settings[0] === 'en_US' &&
_.isEmpty(options.hash) &&
values[1].settings[0] !== 'true') {
output = defaultString;
} else {
output = polyglot.t(key, options.hash);
}

return output;
});
};

coreHelpers.foreach = function (context, options) {
var fn = options.fn,
inverse = options.inverse,
Expand Down
25 changes: 0 additions & 25 deletions core/shared/lang/en_US.json

This file was deleted.

54 changes: 0 additions & 54 deletions core/shared/lang/i18n.js

This file was deleted.

37 changes: 0 additions & 37 deletions core/test/unit/server_helpers_index_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1368,43 +1368,6 @@ describe('Core Helpers', function () {
});
});

describe('e helper', function () {

it('is loaded', function () {
should.exist(handlebars.helpers.e);
});

it('should return the correct default string', function (done) {
apiStub.restore();
apiStub = sandbox.stub(api.settings, 'read', function () {
return when({ settings: ['en_US'] });
});

helpers.e('testKey', 'default', { hash: {} }).then(function (result) {
result.should.equal('default');
done();
}).catch(done);
});

it('should return the correct string', function (done) {
apiStub.restore();
apiStub = sandbox.stub(api.settings, 'read', function () {
return when({ settings: ['fr'] });
});

var polyglot = new Polyglot();

polyglot.extend({ testKey: 'test value' });

helpers.__set__('polyglot', polyglot);

helpers.e('testKey', 'default', { hash: {} }).then(function (result) {
result.should.equal('test value');
done();
}).catch(done);
});
});

describe('foreach helper', function () {

// passed into the foreach helper. takes the input string along with the metadata about
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"lodash": "2.4.1",
"moment": "2.4.0",
"morgan": "1.0.0",
"node-polyglot": "0.3.0",
"node-uuid": "1.4.1",
"nodemailer": "0.5.13",
"oauth2orize": "1.0.1",
Expand Down

0 comments on commit b91dee3

Please sign in to comment.