diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index f0f4453137..7ef6250a36 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -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'), @@ -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, diff --git a/core/shared/lang/en_US.json b/core/shared/lang/en_US.json deleted file mode 100644 index e21e5cbac6..0000000000 --- a/core/shared/lang/en_US.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "__SECTION__": "admin core", - "admin.navbar.blog": "Blog", - "admin.navbar.settings": "Settings", - - "__SECTION__": "icons", - "icon.tag.label": "Tag", - "icon.faq.label": "?", - "icon.faq.markdown.title": "What is Markdown?", - "icon.full_screen.label": "Full Screen", - "icon.full_screen.title": "Enter full screen mode", - "icon.settings.label": "Settings", - - "__SECTION__": "editor", - "editor.entry_title.placeholder": "Your Post Title", - "editor.entry_permalink.label": "Permalink:", - "editor.entry_permalink.example_url": "http://yoursite.com/", - "editor.entry_permalink.example_slug": "the-post-title-goes-here", - "editor.headers.markdown.label": "Markdown", - "editor.headers.preview.label": "Preview", - "editor.word_count": "%{count} words", - "editor.actions.save_draft": "Save Draft", - "editor.actions.publish": "Publish" - -} diff --git a/core/shared/lang/i18n.js b/core/shared/lang/i18n.js deleted file mode 100644 index 4f3617d6ad..0000000000 --- a/core/shared/lang/i18n.js +++ /dev/null @@ -1,54 +0,0 @@ -var fs = require('fs'), - config = require('../../server/config'), - /** - * Create new Polyglot object - * @type {Polyglot} - */ - I18n; - -I18n = function (ghost) { - - // TODO: validate - var lang = ghost.settings('defaultLang'), - path = config.paths.lang, - langFilePath = path + lang + '.json'; - - return function (req, res, next) { - - if (lang === 'en_US') { - // TODO: do stuff here to optimise for en - - // Make jslint empty block error go away - lang = 'en_US'; - } - - /** TODO: potentially use req.acceptedLanguages rather than the default - * TODO: handle loading language file for frontend on frontend request etc - * TODO: switch this mess to be promise driven */ - fs.stat(langFilePath, function (error) { - if (error) { - console.log('No language file found for language ' + lang + '. Defaulting to en_US'); - lang = 'en_US'; - } - - fs.readFile(langFilePath, function (error, data) { - if (error) { - throw error; - } - - try { - data = JSON.parse(data); - } catch (e) { - throw e; // TODO: do something better with the error here - } - - ghost.polyglot().extend(data); - - next(); - }); - }); - }; -}; - - -module.exports.load = I18n; \ No newline at end of file diff --git a/core/test/unit/server_helpers_index_spec.js b/core/test/unit/server_helpers_index_spec.js index f17481e272..30e8db23f4 100644 --- a/core/test/unit/server_helpers_index_spec.js +++ b/core/test/unit/server_helpers_index_spec.js @@ -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 diff --git a/package.json b/package.json index 8a8adee62a..6a8f42ed32 100644 --- a/package.json +++ b/package.json @@ -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",