From 0376e3d57455b92f75f625aadede2df782165c6d Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 30 Jan 2014 15:38:07 -0500 Subject: [PATCH] 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 --- public/language/en/language.json | 4 --- public/language/{en => en_GB}/category.json | 0 public/language/{en => en_GB}/footer.json | 0 public/language/{en => en_GB}/global.json | 0 public/language/en_GB/language.json | 4 +++ public/language/{en => en_GB}/login.json | 0 public/language/{en => en_GB}/modules.json | 0 .../language/{en => en_GB}/notifications.json | 0 public/language/{en => en_GB}/pages.json | 0 public/language/{en => en_GB}/recent.json | 0 public/language/{en => en_GB}/register.json | 0 .../{en => en_GB}/reset_password.json | 0 public/language/{en => en_GB}/topic.json | 0 public/language/{en => en_GB}/unread.json | 0 public/language/{en => en_GB}/user.json | 0 public/language/{en => en_GB}/users.json | 0 .../language/{pt_br => pt_BR}/category.json | 0 public/language/{pt_br => pt_BR}/footer.json | 0 public/language/{pt_br => pt_BR}/global.json | 0 .../language/{pt_br => pt_BR}/language.json | 2 +- public/language/{pt_br => pt_BR}/login.json | 0 public/language/{pt_br => pt_BR}/modules.json | 0 .../{pt_br => pt_BR}/notifications.json | 0 public/language/{pt_br => pt_BR}/pages.json | 0 public/language/{pt_br => pt_BR}/recent.json | 0 .../language/{pt_br => pt_BR}/register.json | 0 .../{pt_br => pt_BR}/reset_password.json | 0 public/language/{pt_br => pt_BR}/topic.json | 0 public/language/{pt_br => pt_BR}/unread.json | 0 public/language/{pt_br => pt_BR}/user.json | 0 public/language/{pt_br => pt_BR}/users.json | 0 .../language/{zh_cn => zh_CN}/category.json | 0 public/language/{zh_cn => zh_CN}/footer.json | 0 public/language/{zh_cn => zh_CN}/global.json | 0 .../language/{zh_cn => zh_CN}/language.json | 2 +- public/language/{zh_cn => zh_CN}/login.json | 0 public/language/{zh_cn => zh_CN}/modules.json | 0 .../{zh_cn => zh_CN}/notifications.json | 0 public/language/{zh_cn => zh_CN}/pages.json | 0 public/language/{zh_cn => zh_CN}/recent.json | 0 .../language/{zh_cn => zh_CN}/register.json | 0 .../{zh_cn => zh_CN}/reset_password.json | 0 public/language/{zh_cn => zh_CN}/topic.json | 0 public/language/{zh_cn => zh_CN}/unread.json | 0 public/language/{zh_cn => zh_CN}/user.json | 0 public/language/{zh_cn => zh_CN}/users.json | 0 .../language/{zh_tw => zh_TW}/category.json | 0 public/language/{zh_tw => zh_TW}/footer.json | 0 public/language/{zh_tw => zh_TW}/global.json | 0 .../language/{zh_tw => zh_TW}/language.json | 2 +- public/language/{zh_tw => zh_TW}/login.json | 0 public/language/{zh_tw => zh_TW}/modules.json | 0 .../{zh_tw => zh_TW}/notifications.json | 0 public/language/{zh_tw => zh_TW}/pages.json | 0 public/language/{zh_tw => zh_TW}/recent.json | 0 .../language/{zh_tw => zh_TW}/register.json | 0 .../{zh_tw => zh_TW}/reset_password.json | 0 public/language/{zh_tw => zh_TW}/topic.json | 0 public/language/{zh_tw => zh_TW}/unread.json | 0 public/language/{zh_tw => zh_TW}/user.json | 0 public/language/{zh_tw => zh_TW}/users.json | 0 public/src/translator.js | 10 +++---- src/languages.js | 10 ++----- src/routes/api.js | 2 +- src/upgrade.js | 27 ++++++++++++++++++- 65 files changed, 41 insertions(+), 22 deletions(-) delete mode 100644 public/language/en/language.json rename public/language/{en => en_GB}/category.json (100%) rename public/language/{en => en_GB}/footer.json (100%) rename public/language/{en => en_GB}/global.json (100%) create mode 100644 public/language/en_GB/language.json rename public/language/{en => en_GB}/login.json (100%) rename public/language/{en => en_GB}/modules.json (100%) rename public/language/{en => en_GB}/notifications.json (100%) rename public/language/{en => en_GB}/pages.json (100%) rename public/language/{en => en_GB}/recent.json (100%) rename public/language/{en => en_GB}/register.json (100%) rename public/language/{en => en_GB}/reset_password.json (100%) rename public/language/{en => en_GB}/topic.json (100%) rename public/language/{en => en_GB}/unread.json (100%) rename public/language/{en => en_GB}/user.json (100%) rename public/language/{en => en_GB}/users.json (100%) rename public/language/{pt_br => pt_BR}/category.json (100%) rename public/language/{pt_br => pt_BR}/footer.json (100%) rename public/language/{pt_br => pt_BR}/global.json (100%) rename public/language/{pt_br => pt_BR}/language.json (69%) rename public/language/{pt_br => pt_BR}/login.json (100%) rename public/language/{pt_br => pt_BR}/modules.json (100%) rename public/language/{pt_br => pt_BR}/notifications.json (100%) rename public/language/{pt_br => pt_BR}/pages.json (100%) rename public/language/{pt_br => pt_BR}/recent.json (100%) rename public/language/{pt_br => pt_BR}/register.json (100%) rename public/language/{pt_br => pt_BR}/reset_password.json (100%) rename public/language/{pt_br => pt_BR}/topic.json (100%) rename public/language/{pt_br => pt_BR}/unread.json (100%) rename public/language/{pt_br => pt_BR}/user.json (100%) rename public/language/{pt_br => pt_BR}/users.json (100%) rename public/language/{zh_cn => zh_CN}/category.json (100%) rename public/language/{zh_cn => zh_CN}/footer.json (100%) rename public/language/{zh_cn => zh_CN}/global.json (100%) rename public/language/{zh_cn => zh_CN}/language.json (60%) rename public/language/{zh_cn => zh_CN}/login.json (100%) rename public/language/{zh_cn => zh_CN}/modules.json (100%) rename public/language/{zh_cn => zh_CN}/notifications.json (100%) rename public/language/{zh_cn => zh_CN}/pages.json (100%) rename public/language/{zh_cn => zh_CN}/recent.json (100%) rename public/language/{zh_cn => zh_CN}/register.json (100%) rename public/language/{zh_cn => zh_CN}/reset_password.json (100%) rename public/language/{zh_cn => zh_CN}/topic.json (100%) rename public/language/{zh_cn => zh_CN}/unread.json (100%) rename public/language/{zh_cn => zh_CN}/user.json (100%) rename public/language/{zh_cn => zh_CN}/users.json (100%) rename public/language/{zh_tw => zh_TW}/category.json (100%) rename public/language/{zh_tw => zh_TW}/footer.json (100%) rename public/language/{zh_tw => zh_TW}/global.json (100%) rename public/language/{zh_tw => zh_TW}/language.json (60%) rename public/language/{zh_tw => zh_TW}/login.json (100%) rename public/language/{zh_tw => zh_TW}/modules.json (100%) rename public/language/{zh_tw => zh_TW}/notifications.json (100%) rename public/language/{zh_tw => zh_TW}/pages.json (100%) rename public/language/{zh_tw => zh_TW}/recent.json (100%) rename public/language/{zh_tw => zh_TW}/register.json (100%) rename public/language/{zh_tw => zh_TW}/reset_password.json (100%) rename public/language/{zh_tw => zh_TW}/topic.json (100%) rename public/language/{zh_tw => zh_TW}/unread.json (100%) rename public/language/{zh_tw => zh_TW}/user.json (100%) rename public/language/{zh_tw => zh_TW}/users.json (100%) diff --git a/public/language/en/language.json b/public/language/en/language.json deleted file mode 100644 index c96e8e9f8e..0000000000 --- a/public/language/en/language.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "English", - "code": "en" -} \ No newline at end of file diff --git a/public/language/en/category.json b/public/language/en_GB/category.json similarity index 100% rename from public/language/en/category.json rename to public/language/en_GB/category.json diff --git a/public/language/en/footer.json b/public/language/en_GB/footer.json similarity index 100% rename from public/language/en/footer.json rename to public/language/en_GB/footer.json diff --git a/public/language/en/global.json b/public/language/en_GB/global.json similarity index 100% rename from public/language/en/global.json rename to public/language/en_GB/global.json diff --git a/public/language/en_GB/language.json b/public/language/en_GB/language.json new file mode 100644 index 0000000000..fafd921150 --- /dev/null +++ b/public/language/en_GB/language.json @@ -0,0 +1,4 @@ +{ + "name": "English (United Kingdom/Canada)", + "code": "en_GB" +} \ No newline at end of file diff --git a/public/language/en/login.json b/public/language/en_GB/login.json similarity index 100% rename from public/language/en/login.json rename to public/language/en_GB/login.json diff --git a/public/language/en/modules.json b/public/language/en_GB/modules.json similarity index 100% rename from public/language/en/modules.json rename to public/language/en_GB/modules.json diff --git a/public/language/en/notifications.json b/public/language/en_GB/notifications.json similarity index 100% rename from public/language/en/notifications.json rename to public/language/en_GB/notifications.json diff --git a/public/language/en/pages.json b/public/language/en_GB/pages.json similarity index 100% rename from public/language/en/pages.json rename to public/language/en_GB/pages.json diff --git a/public/language/en/recent.json b/public/language/en_GB/recent.json similarity index 100% rename from public/language/en/recent.json rename to public/language/en_GB/recent.json diff --git a/public/language/en/register.json b/public/language/en_GB/register.json similarity index 100% rename from public/language/en/register.json rename to public/language/en_GB/register.json diff --git a/public/language/en/reset_password.json b/public/language/en_GB/reset_password.json similarity index 100% rename from public/language/en/reset_password.json rename to public/language/en_GB/reset_password.json diff --git a/public/language/en/topic.json b/public/language/en_GB/topic.json similarity index 100% rename from public/language/en/topic.json rename to public/language/en_GB/topic.json diff --git a/public/language/en/unread.json b/public/language/en_GB/unread.json similarity index 100% rename from public/language/en/unread.json rename to public/language/en_GB/unread.json diff --git a/public/language/en/user.json b/public/language/en_GB/user.json similarity index 100% rename from public/language/en/user.json rename to public/language/en_GB/user.json diff --git a/public/language/en/users.json b/public/language/en_GB/users.json similarity index 100% rename from public/language/en/users.json rename to public/language/en_GB/users.json diff --git a/public/language/pt_br/category.json b/public/language/pt_BR/category.json similarity index 100% rename from public/language/pt_br/category.json rename to public/language/pt_BR/category.json diff --git a/public/language/pt_br/footer.json b/public/language/pt_BR/footer.json similarity index 100% rename from public/language/pt_br/footer.json rename to public/language/pt_BR/footer.json diff --git a/public/language/pt_br/global.json b/public/language/pt_BR/global.json similarity index 100% rename from public/language/pt_br/global.json rename to public/language/pt_BR/global.json diff --git a/public/language/pt_br/language.json b/public/language/pt_BR/language.json similarity index 69% rename from public/language/pt_br/language.json rename to public/language/pt_BR/language.json index 611dd6491d..6343c8cd3b 100644 --- a/public/language/pt_br/language.json +++ b/public/language/pt_BR/language.json @@ -1,4 +1,4 @@ { "name": "Português Brasileiro", - "code": "pt_br" + "code": "pt_BR" } \ No newline at end of file diff --git a/public/language/pt_br/login.json b/public/language/pt_BR/login.json similarity index 100% rename from public/language/pt_br/login.json rename to public/language/pt_BR/login.json diff --git a/public/language/pt_br/modules.json b/public/language/pt_BR/modules.json similarity index 100% rename from public/language/pt_br/modules.json rename to public/language/pt_BR/modules.json diff --git a/public/language/pt_br/notifications.json b/public/language/pt_BR/notifications.json similarity index 100% rename from public/language/pt_br/notifications.json rename to public/language/pt_BR/notifications.json diff --git a/public/language/pt_br/pages.json b/public/language/pt_BR/pages.json similarity index 100% rename from public/language/pt_br/pages.json rename to public/language/pt_BR/pages.json diff --git a/public/language/pt_br/recent.json b/public/language/pt_BR/recent.json similarity index 100% rename from public/language/pt_br/recent.json rename to public/language/pt_BR/recent.json diff --git a/public/language/pt_br/register.json b/public/language/pt_BR/register.json similarity index 100% rename from public/language/pt_br/register.json rename to public/language/pt_BR/register.json diff --git a/public/language/pt_br/reset_password.json b/public/language/pt_BR/reset_password.json similarity index 100% rename from public/language/pt_br/reset_password.json rename to public/language/pt_BR/reset_password.json diff --git a/public/language/pt_br/topic.json b/public/language/pt_BR/topic.json similarity index 100% rename from public/language/pt_br/topic.json rename to public/language/pt_BR/topic.json diff --git a/public/language/pt_br/unread.json b/public/language/pt_BR/unread.json similarity index 100% rename from public/language/pt_br/unread.json rename to public/language/pt_BR/unread.json diff --git a/public/language/pt_br/user.json b/public/language/pt_BR/user.json similarity index 100% rename from public/language/pt_br/user.json rename to public/language/pt_BR/user.json diff --git a/public/language/pt_br/users.json b/public/language/pt_BR/users.json similarity index 100% rename from public/language/pt_br/users.json rename to public/language/pt_BR/users.json diff --git a/public/language/zh_cn/category.json b/public/language/zh_CN/category.json similarity index 100% rename from public/language/zh_cn/category.json rename to public/language/zh_CN/category.json diff --git a/public/language/zh_cn/footer.json b/public/language/zh_CN/footer.json similarity index 100% rename from public/language/zh_cn/footer.json rename to public/language/zh_CN/footer.json diff --git a/public/language/zh_cn/global.json b/public/language/zh_CN/global.json similarity index 100% rename from public/language/zh_cn/global.json rename to public/language/zh_CN/global.json diff --git a/public/language/zh_cn/language.json b/public/language/zh_CN/language.json similarity index 60% rename from public/language/zh_cn/language.json rename to public/language/zh_CN/language.json index c9a02bc548..2c075a5072 100644 --- a/public/language/zh_cn/language.json +++ b/public/language/zh_CN/language.json @@ -1,4 +1,4 @@ { "name": "简体中文", - "code": "zh_cn" + "code": "zh_CN" } \ No newline at end of file diff --git a/public/language/zh_cn/login.json b/public/language/zh_CN/login.json similarity index 100% rename from public/language/zh_cn/login.json rename to public/language/zh_CN/login.json diff --git a/public/language/zh_cn/modules.json b/public/language/zh_CN/modules.json similarity index 100% rename from public/language/zh_cn/modules.json rename to public/language/zh_CN/modules.json diff --git a/public/language/zh_cn/notifications.json b/public/language/zh_CN/notifications.json similarity index 100% rename from public/language/zh_cn/notifications.json rename to public/language/zh_CN/notifications.json diff --git a/public/language/zh_cn/pages.json b/public/language/zh_CN/pages.json similarity index 100% rename from public/language/zh_cn/pages.json rename to public/language/zh_CN/pages.json diff --git a/public/language/zh_cn/recent.json b/public/language/zh_CN/recent.json similarity index 100% rename from public/language/zh_cn/recent.json rename to public/language/zh_CN/recent.json diff --git a/public/language/zh_cn/register.json b/public/language/zh_CN/register.json similarity index 100% rename from public/language/zh_cn/register.json rename to public/language/zh_CN/register.json diff --git a/public/language/zh_cn/reset_password.json b/public/language/zh_CN/reset_password.json similarity index 100% rename from public/language/zh_cn/reset_password.json rename to public/language/zh_CN/reset_password.json diff --git a/public/language/zh_cn/topic.json b/public/language/zh_CN/topic.json similarity index 100% rename from public/language/zh_cn/topic.json rename to public/language/zh_CN/topic.json diff --git a/public/language/zh_cn/unread.json b/public/language/zh_CN/unread.json similarity index 100% rename from public/language/zh_cn/unread.json rename to public/language/zh_CN/unread.json diff --git a/public/language/zh_cn/user.json b/public/language/zh_CN/user.json similarity index 100% rename from public/language/zh_cn/user.json rename to public/language/zh_CN/user.json diff --git a/public/language/zh_cn/users.json b/public/language/zh_CN/users.json similarity index 100% rename from public/language/zh_cn/users.json rename to public/language/zh_CN/users.json diff --git a/public/language/zh_tw/category.json b/public/language/zh_TW/category.json similarity index 100% rename from public/language/zh_tw/category.json rename to public/language/zh_TW/category.json diff --git a/public/language/zh_tw/footer.json b/public/language/zh_TW/footer.json similarity index 100% rename from public/language/zh_tw/footer.json rename to public/language/zh_TW/footer.json diff --git a/public/language/zh_tw/global.json b/public/language/zh_TW/global.json similarity index 100% rename from public/language/zh_tw/global.json rename to public/language/zh_TW/global.json diff --git a/public/language/zh_tw/language.json b/public/language/zh_TW/language.json similarity index 60% rename from public/language/zh_tw/language.json rename to public/language/zh_TW/language.json index 8264390b6a..201538c1b0 100644 --- a/public/language/zh_tw/language.json +++ b/public/language/zh_TW/language.json @@ -1,4 +1,4 @@ { "name": "簡體中文", - "code": "zh_tw" + "code": "zh_TW" } \ No newline at end of file diff --git a/public/language/zh_tw/login.json b/public/language/zh_TW/login.json similarity index 100% rename from public/language/zh_tw/login.json rename to public/language/zh_TW/login.json diff --git a/public/language/zh_tw/modules.json b/public/language/zh_TW/modules.json similarity index 100% rename from public/language/zh_tw/modules.json rename to public/language/zh_TW/modules.json diff --git a/public/language/zh_tw/notifications.json b/public/language/zh_TW/notifications.json similarity index 100% rename from public/language/zh_tw/notifications.json rename to public/language/zh_TW/notifications.json diff --git a/public/language/zh_tw/pages.json b/public/language/zh_TW/pages.json similarity index 100% rename from public/language/zh_tw/pages.json rename to public/language/zh_TW/pages.json diff --git a/public/language/zh_tw/recent.json b/public/language/zh_TW/recent.json similarity index 100% rename from public/language/zh_tw/recent.json rename to public/language/zh_TW/recent.json diff --git a/public/language/zh_tw/register.json b/public/language/zh_TW/register.json similarity index 100% rename from public/language/zh_tw/register.json rename to public/language/zh_TW/register.json diff --git a/public/language/zh_tw/reset_password.json b/public/language/zh_TW/reset_password.json similarity index 100% rename from public/language/zh_tw/reset_password.json rename to public/language/zh_TW/reset_password.json diff --git a/public/language/zh_tw/topic.json b/public/language/zh_TW/topic.json similarity index 100% rename from public/language/zh_tw/topic.json rename to public/language/zh_TW/topic.json diff --git a/public/language/zh_tw/unread.json b/public/language/zh_TW/unread.json similarity index 100% rename from public/language/zh_tw/unread.json rename to public/language/zh_TW/unread.json diff --git a/public/language/zh_tw/user.json b/public/language/zh_TW/user.json similarity index 100% rename from public/language/zh_tw/user.json rename to public/language/zh_TW/user.json diff --git a/public/language/zh_tw/users.json b/public/language/zh_TW/users.json similarity index 100% rename from public/language/zh_tw/users.json rename to public/language/zh_TW/users.json diff --git a/public/src/translator.js b/public/src/translator.js index 366a757c0c..2304f54259 100644 --- a/public/src/translator.js +++ b/public/src/translator.js @@ -31,7 +31,7 @@ translator.prepareDOM = function() { // Load the appropriate timeago locale file - if (config.defaultLang !== 'en') { + if (config.defaultLang !== 'en_GB') { // Correct NodeBB language codes to timeago codes, if necessary var languageCode; switch(config.defaultLang) { @@ -39,15 +39,15 @@ languageCode = 'cz'; break; - case 'zh_tw': + case 'zh_TW': languageCode = 'zh-TW'; break; - case 'zh_cn': + case 'zh_CN': languageCode = 'zh-CN'; break; - case 'pt_br': + case 'pt_BR': languageCode = 'pt-br'; break; @@ -203,7 +203,7 @@ fs = require('fs'), 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; for (var d in data) { diff --git a/src/languages.js b/src/languages.js index 394fca21b1..6980ce1e85 100644 --- a/src/languages.js +++ b/src/languages.js @@ -32,15 +32,9 @@ Languages.list = function(callback) { } }); }, function(err) { - // Float "en" to the top, otherwise sort alphabetically + // Sort alphabetically languages = languages.sort(function(a, b) { - if (a.code === 'en') { - return -1; - } else if (b.code === 'en') { - return 1; - } else { - return a.code > b.code; - } + return a.code > b.code ? 1 : -1; }); callback(err, languages); diff --git a/src/routes/api.js b/src/routes/api.js index 08d4107f74..e69fc97844 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -47,7 +47,7 @@ var path = require('path'), config.topicsPerPage = meta.config.topicsPerPage || 20; config.postsPerPage = meta.config.postsPerPage || 20; config.maximumFileSize = meta.config.maximumFileSize; - config.defaultLang = meta.config.defaultLang || 'en'; + config.defaultLang = meta.config.defaultLang || 'en_GB'; res.json(200, config); }); diff --git a/src/upgrade.js b/src/upgrade.js index bea2116d8b..1581ea1589 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -19,7 +19,7 @@ var db = require('./database'), Upgrade.check = function(callback) { // 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) { 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'); 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 // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 17!!!