renamed language directories to ICU standard, upgrade script, no longer promoting english at top of list in languages tab, en now en_GB, encompasses Canadian and English English

v1.18.x
Julian Lam 11 years ago
parent d8eec5dd2e
commit 0376e3d574

@ -1,4 +0,0 @@
{
"name": "English",
"code": "en"
}

@ -0,0 +1,4 @@
{
"name": "English (United Kingdom/Canada)",
"code": "en_GB"
}

@ -1,4 +1,4 @@
{ {
"name": "Português Brasileiro", "name": "Português Brasileiro",
"code": "pt_br" "code": "pt_BR"
} }

@ -1,4 +1,4 @@
{ {
"name": "简体中文", "name": "简体中文",
"code": "zh_cn" "code": "zh_CN"
} }

@ -1,4 +1,4 @@
{ {
"name": "簡體中文", "name": "簡體中文",
"code": "zh_tw" "code": "zh_TW"
} }

@ -31,7 +31,7 @@
translator.prepareDOM = function() { translator.prepareDOM = function() {
// Load the appropriate timeago locale file // Load the appropriate timeago locale file
if (config.defaultLang !== 'en') { if (config.defaultLang !== 'en_GB') {
// Correct NodeBB language codes to timeago codes, if necessary // Correct NodeBB language codes to timeago codes, if necessary
var languageCode; var languageCode;
switch(config.defaultLang) { switch(config.defaultLang) {
@ -39,15 +39,15 @@
languageCode = 'cz'; languageCode = 'cz';
break; break;
case 'zh_tw': case 'zh_TW':
languageCode = 'zh-TW'; languageCode = 'zh-TW';
break; break;
case 'zh_cn': case 'zh_CN':
languageCode = 'zh-CN'; languageCode = 'zh-CN';
break; break;
case 'pt_br': case 'pt_BR':
languageCode = 'pt-br'; languageCode = 'pt-br';
break; break;
@ -203,7 +203,7 @@
fs = require('fs'), fs = require('fs'),
winston = require('winston'); winston = require('winston');
utils.walk(path.join(__dirname, '../language', (Meta.config.defaultLang || 'en')), function (err, data) { utils.walk(path.join(__dirname, '../language', (Meta.config.defaultLang || 'en_GB')), function (err, data) {
var loaded = data.length; var loaded = data.length;
for (var d in data) { for (var d in data) {

@ -32,15 +32,9 @@ Languages.list = function(callback) {
} }
}); });
}, function(err) { }, function(err) {
// Float "en" to the top, otherwise sort alphabetically // Sort alphabetically
languages = languages.sort(function(a, b) { languages = languages.sort(function(a, b) {
if (a.code === 'en') { return a.code > b.code ? 1 : -1;
return -1;
} else if (b.code === 'en') {
return 1;
} else {
return a.code > b.code;
}
}); });
callback(err, languages); callback(err, languages);

@ -47,7 +47,7 @@ var path = require('path'),
config.topicsPerPage = meta.config.topicsPerPage || 20; config.topicsPerPage = meta.config.topicsPerPage || 20;
config.postsPerPage = meta.config.postsPerPage || 20; config.postsPerPage = meta.config.postsPerPage || 20;
config.maximumFileSize = meta.config.maximumFileSize; config.maximumFileSize = meta.config.maximumFileSize;
config.defaultLang = meta.config.defaultLang || 'en'; config.defaultLang = meta.config.defaultLang || 'en_GB';
res.json(200, config); res.json(200, config);
}); });

@ -19,7 +19,7 @@ var db = require('./database'),
Upgrade.check = function(callback) { Upgrade.check = function(callback) {
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
var latestSchema = new Date(2014, 0, 27, 12, 35).getTime(); var latestSchema = new Date(2014, 0, 30, 15, 0).getTime();
db.get('schemaDate', function(err, value) { db.get('schemaDate', function(err, value) {
if (parseInt(value, 10) >= latestSchema) { if (parseInt(value, 10) >= latestSchema) {
@ -404,6 +404,31 @@ Upgrade.upgrade = function(callback) {
winston.info('[2014/1/25] Activating SSO plugins, if set up -- skipped'); winston.info('[2014/1/25] Activating SSO plugins, if set up -- skipped');
next(); next();
} }
},
function(next) {
thisSchemaDate = new Date(2014, 0, 30, 15, 0).getTime();
if (schemaDate < thisSchemaDate) {
updatesMade = true;
if (Meta.config.defaultLang === 'en') {
Meta.configs.set('defaultLang', 'en_GB', next);
} else if (Meta.config.defaultLang === 'pt_br') {
Meta.configs.set('defaultLang', 'pt_BR', next);
} else if (Meta.config.defaultLang === 'zh_cn') {
Meta.configs.set('defaultLang', 'zh_CN', next);
} else if (Meta.config.defaultLang === 'zh_tw') {
Meta.configs.set('defaultLang', 'zh_TW', next);
} else {
winston.info('[2014/1/30] Fixing language settings -- skipped');
return next();
}
winston.info('[2014/1/30] Fixing language settings');
next();
} else {
winston.info('[2014/1/30] Fixing language settings -- skipped');
next();
}
} }
// Add new schema updates here // Add new schema updates here
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!! // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!!

Loading…
Cancel
Save