From 18b71f32b144652a63d5391e40f460a89cfc5cc2 Mon Sep 17 00:00:00 2001 From: Katharina Irrgang Date: Wed, 31 May 2017 17:05:49 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=20rename=20language=20to=20loca?= =?UTF-8?q?le=20and=20use=20`en`=20as=20default=20locale=20(#8490)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - this PR references indirecty to https://github.com/TryGhost/Ghost/pull/8437 - i would like to have the settings change already in place before we release the beta - the i18n feature is able to change the locale of Ghost - most i18n libraries use locale - adding/changing settings doesn't require a migration file, but it can make the database a bit messy (because you can end up with default_locale and lang) - furthermore we agreed that the default locale for Ghost should be simply `en`, not `en_US` or `en_GB` --- core/server/data/schema/default-settings.json | 4 ++-- core/server/data/schema/fixtures/fixtures.json | 1 - core/server/data/schema/schema.js | 4 ++-- core/server/i18n.js | 2 +- core/test/integration/data/importer/importers/data_spec.js | 4 +--- core/test/integration/model/model_posts_spec.js | 4 +++- core/test/unit/migration_spec.js | 4 ++-- core/test/utils/fixtures/data-generator.js | 7 +++---- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/core/server/data/schema/default-settings.json b/core/server/data/schema/default-settings.json index 9423996048..eabfd35c56 100644 --- a/core/server/data/schema/default-settings.json +++ b/core/server/data/schema/default-settings.json @@ -29,8 +29,8 @@ "icon": { "defaultValue": "" }, - "default_lang": { - "defaultValue": "en_US", + "default_locale": { + "defaultValue": "en", "validations": { "isEmpty": false } diff --git a/core/server/data/schema/fixtures/fixtures.json b/core/server/data/schema/fixtures/fixtures.json index 10d31321e1..f4946a7706 100644 --- a/core/server/data/schema/fixtures/fixtures.json +++ b/core/server/data/schema/fixtures/fixtures.json @@ -11,7 +11,6 @@ "featured": false, "page": false, "status": "published", - "language": "en_US", "meta_title": null, "meta_description": null } diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index 6616c02786..23053f507b 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -12,7 +12,7 @@ module.exports = { featured: {type: 'bool', nullable: false, defaultTo: false}, page: {type: 'bool', nullable: false, defaultTo: false}, status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'draft'}, - language: {type: 'string', maxlength: 6, nullable: false, defaultTo: 'en_US'}, + locale: {type: 'string', maxlength: 6, nullable: true}, visibility: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'public', validations: {isIn: [['public']]}}, meta_title: {type: 'string', maxlength: 2000, nullable: true}, meta_description: {type: 'string', maxlength: 2000, nullable: true}, @@ -41,7 +41,7 @@ module.exports = { twitter: {type: 'string', maxlength: 2000, nullable: true}, accessibility: {type: 'text', maxlength: 65535, nullable: true}, status: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'active'}, - language: {type: 'string', maxlength: 6, nullable: false, defaultTo: 'en_US'}, + locale: {type: 'string', maxlength: 6, nullable: true}, visibility: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'public', validations: {isIn: [['public']]}}, meta_title: {type: 'string', maxlength: 2000, nullable: true}, meta_description: {type: 'string', maxlength: 2000, nullable: true}, diff --git a/core/server/i18n.js b/core/server/i18n.js index 8017392843..ad1ebdc031 100644 --- a/core/server/i18n.js +++ b/core/server/i18n.js @@ -6,7 +6,7 @@ var supportedLocales = ['en'], chalk = require('chalk'), MessageFormat = require('intl-messageformat'), - // TODO: fetch this dynamically based on overall blog settings (`key = "default_lang"`) in the `settings` table + // TODO: fetch this dynamically based on overall blog settings (`key = "default_locale"`) in the `settings` table currentLocale = 'en', blos, I18n; diff --git a/core/test/integration/data/importer/importers/data_spec.js b/core/test/integration/data/importer/importers/data_spec.js index 92f84cd14b..dc55c78121 100644 --- a/core/test/integration/data/importer/importers/data_spec.js +++ b/core/test/integration/data/importer/importers/data_spec.js @@ -460,7 +460,7 @@ describe('Import', function () { }).then(function () { done(new Error('Allowed import of invalid post data')); }).catch(function (response) { - response.length.should.equal(3, response); + response.length.should.equal(2, response); response[0].errorType.should.equal('ValidationError'); response[0].message.should.eql('Value in [posts.title] cannot be blank.'); @@ -468,8 +468,6 @@ describe('Import', function () { response[1].errorType.should.equal('ValidationError'); response[1].message.should.eql('Value in [posts.status] cannot be blank.'); - response[2].errorType.should.equal('ValidationError'); - response[2].message.should.eql('Value in [posts.language] cannot be blank.'); done(); }).catch(done); }); diff --git a/core/test/integration/model/model_posts_spec.js b/core/test/integration/model/model_posts_spec.js index 86e540d51c..06582f5d66 100644 --- a/core/test/integration/model/model_posts_spec.js +++ b/core/test/integration/model/model_posts_spec.js @@ -959,7 +959,9 @@ describe('Post Model', function () { createdPost.get('slug').should.equal(newPostDB.slug + '-2'); (!!createdPost.get('featured')).should.equal(false); (!!createdPost.get('page')).should.equal(false); - createdPost.get('language').should.equal('en_US'); + + should.equal(createdPost.get('locale'), null); + // testing for nulls (createdPost.get('feature_image') === null).should.equal(true); (createdPost.get('meta_title') === null).should.equal(true); diff --git a/core/test/unit/migration_spec.js b/core/test/unit/migration_spec.js index a1005184bf..e69f11320b 100644 --- a/core/test/unit/migration_spec.js +++ b/core/test/unit/migration_spec.js @@ -19,8 +19,8 @@ var should = require('should'), // jshint ignore:line // both of which are required for migrations to work properly. describe('DB version integrity', function () { // Only these variables should need updating - var currentSchemaHash = 'd10bff0a4dbccbd5e5d66c9ed596301b', - currentFixturesHash = 'ec48af84f206fa377214ed4311ba6dfd'; + var currentSchemaHash = 'b613bca0f20e02360487a3c17a9ffcc1', + currentFixturesHash = 'd9a19655448a168246a4849dc4591ba9'; // If this test is failing, then it is likely a change has been made that requires a DB version bump, // and the values above will need updating as confirmation diff --git a/core/test/utils/fixtures/data-generator.js b/core/test/utils/fixtures/data-generator.js index e51d2ec107..70aa079bab 100644 --- a/core/test/utils/fixtures/data-generator.js +++ b/core/test/utils/fixtures/data-generator.js @@ -367,7 +367,6 @@ DataGenerator.forKnex = (function () { title: 'title', status: 'published', html: mobiledoc.cards && mobiledoc.cards[0][1].markdown, - language: 'en_US', featured: true, page: false, author_id: DataGenerator.Content.users[0].id, @@ -380,9 +379,9 @@ DataGenerator.forKnex = (function () { }); } - function createGenericPost(uniqueInteger, status, language, author_id) { + function createGenericPost(uniqueInteger, status, locale, author_id) { status = status || 'draft'; - language = language || 'en_US'; + locale = locale || null; author_id = author_id || DataGenerator.Content.users[0].id; return createPost({ @@ -394,7 +393,7 @@ DataGenerator.forKnex = (function () { html: "

Three days ago I released a concept page<\/a> for a lite version of WordPress that I've been thinking about for a long time, called Ghost. I think it's fair to say that I didn't quite anticipate how strong the reaction would be - and I've hardly had time to catch my breath in the last 72 hours.<\/p>\n

The response was overwhelming, and overwhelmingly positive. In the first 6 hours my site got 35,000 page views after hitting the number 1 slot on Hacker News<\/a>. As of right now, the traffic count is just over 91,000 page views<\/a> - and Ghost has been featured all over the place. Notable mentions so far include Christina Warren from Mashable, who wrote about it<\/a>. Michael Carney from PandoDaily interviewed me about it<\/a>. Someone even wrote about it in Chinese<\/a>. That's pretty cool.\\n

The feedback has been amazing, and while it's impossible to reply to all of the messages individually, I'm getting to as many of them as I can and I want to thank each and every one of you who took the time to send me a message or share the concept because you liked it. Now that the initial storm has died down a bit, I wanted to take some time to answer some of the more common questions and talk about what's next.<\/p>\n

FAQ - Continued...<\/h2>\n

The most common question, bizarrely:<\/p>\n

Oh my god, why is that whole page made of images? What's wrong with you? \/\/ I can't take you seriously \/\/ Don't you know anything about the web? \/\/ You are literally Satan re-incarnate.<\/strong><\/em><\/h5>\n

This was really the only negativity I got in response to the post, and it surprised me. I put together the concept page as... just that... a concept. It was a way for me to get the ideas out of my head and \"down on paper\" - or so to speak. I used photoshop as a tool<\/em> to write down my idea with text and images. If I used a sketchbook as a tool <\/em>to create images and handwritten notes, then uploaded scans of it, I doubt anyone would complain. The concept page was never supposed to be a finished product because I had no idea if there would be any interest in it. I had no motivation to waste hours coding a custom layout for something might only ever be read by a few people and then forgotten.<\/p>\n

Hardware manufacturers make hundreds of foam cutout prototypes of products before they build one with working buttons and screens. I'm aware of all the usability problems with a web page made of images, and equally, foam cutouts without buttons or screens aren't particularly user friendly either. They're not supposed to be.<\/p>\n

Let's move on.<\/p>\n

What? Why no comments? I need comments.<\/strong><\/em><\/h5>\n

Because comments add a layer of complexity that is beyond the core focus of this platform, which is publishing. Again, that's not to say you couldn't have any comments. This could easily be added with a dedicated plugin where you own the data or (as mentioned) there are third party providers such as Disqus, IntenseDebate, Livefyre and Facebook who all have great platforms. The point of this isn't to say \"you can't have comments\" - it's to say \"comments aren't on by default\". It's about simplicity, more than anything else.<\/p>\n

Yeah, but WordPress are already going to revise their dashboard, WordPress.com is experimenting with a potential simplified version... so why bother with this?<\/strong><\/em><\/h5>\n

\"\"<\/a><\/p>\n

Sorry, but Tumblr already did this - it's not the future of blogging, it's the past.<\/p>\n

Ghost isn't about sharing \"Fuck Yeah [Dogs<\/a>\/Sharks<\/a>\/Girls with Tattoos<\/a>]\" - it's about publishing - which means writing - rather than mashing a few buttons to make sure that everyone can see and appreciate your latest funny picture\/status, which is surely the most funny picture\/status you've ever posted.<\/p>\n

Tumblr, Pinterest and Facebook already have this locked down. It's not the future.<\/p>\n

So... are you actually going to build this thing?<\/strong><\/em><\/h5>\n

The concept page was a way for me to test demand and interest. To see if anyone actually agreed with my frustrations and, more importantly, my solutions. I plucked a random figure of \"10,000 pageviews\" out of the air before I hit the publish button. If it got less than 10,000 pageviews, I would surrender to the fact that it would only ever be an idea. I've now exceeded that goal 9 times over, so yes, I'm looking at how Ghost can now be made into a reality.<\/p>\n

How can I find out when it's done? \/\/ SHUT UP AND TAKE MY MONEY<\/strong><\/em><\/h5>\n

Ok, ok - there's a holding page up on http:\/\/TryGhost.org<\/a> - put your email address in.<\/p>\n


\n

How are you going to do this?<\/h3>\n

There's three main ways of going about this, each has merits as well as drawbacks.<\/p>\n

1.) Build it from scratch<\/strong><\/em> - Many people (particularly the Hacker News crowd) expressed the sentiment that there was little point in forking WordPress. When you're going to strip out so much, you get to a point where you might as well start from scratch anyway. Take away the crutches of being stuck with older technologies and put together something which is as sophisticated in code as it is in UI\/UX.<\/p>\n