diff --git a/locales/AR_ar.json b/locales/ar_AR.json similarity index 100% rename from locales/AR_ar.json rename to locales/ar_AR.json diff --git a/locales/DE_de.json b/locales/de_DE.json similarity index 100% rename from locales/DE_de.json rename to locales/de_DE.json diff --git a/locales/US_en.json b/locales/en_US.json similarity index 100% rename from locales/US_en.json rename to locales/en_US.json diff --git a/locales/ES_es.json b/locales/es_ES.json similarity index 100% rename from locales/ES_es.json rename to locales/es_ES.json diff --git a/locales/FR_fr.json b/locales/fr_FR.json similarity index 100% rename from locales/FR_fr.json rename to locales/fr_FR.json diff --git a/locales/IT_it.json b/locales/it_IT.json similarity index 100% rename from locales/IT_it.json rename to locales/it_IT.json diff --git a/locales/JP_ja.json b/locales/ja_JP.json similarity index 100% rename from locales/JP_ja.json rename to locales/ja_JP.json diff --git a/locales/KR_ko.json b/locales/ko_KR.json similarity index 100% rename from locales/KR_ko.json rename to locales/ko_KR.json diff --git a/locales/NO_nb.json b/locales/nb_NO.json similarity index 100% rename from locales/NO_nb.json rename to locales/nb_NO.json diff --git a/locales/NL_nl.json b/locales/nl_NL.json similarity index 100% rename from locales/NL_nl.json rename to locales/nl_NL.json diff --git a/locales/PL_pl.json b/locales/pl_PL.json similarity index 100% rename from locales/PL_pl.json rename to locales/pl_PL.json diff --git a/locales/BR_pt.json b/locales/pt_BR.json similarity index 100% rename from locales/BR_pt.json rename to locales/pt_BR.json diff --git a/locales/RO_ro.json b/locales/ro_RO.json similarity index 100% rename from locales/RO_ro.json rename to locales/ro_RO.json diff --git a/locales/RU_ru.json b/locales/ru_RU.json similarity index 100% rename from locales/RU_ru.json rename to locales/ru_RU.json diff --git a/locales/TR_tr.json b/locales/tr_TR.json similarity index 100% rename from locales/TR_tr.json rename to locales/tr_TR.json diff --git a/locales/CN_zh.json b/locales/zh_CN.json similarity index 100% rename from locales/CN_zh.json rename to locales/zh_CN.json diff --git a/src/middleware/render-data.js b/src/middleware/render-data.js index f534edb..50f1f97 100644 --- a/src/middleware/render-data.js +++ b/src/middleware/render-data.js @@ -8,7 +8,7 @@ async function renderDataMiddleware(request, response, next) { // Get user local const reqLocale = request.locale; - const locale = util.getLocale(reqLocale.region, reqLocale.language); + const locale = util.getLocale(reqLocale.language, reqLocale.region); response.locals.locale = locale; response.locals.localeString = reqLocale.toString(); @@ -40,4 +40,4 @@ async function renderDataMiddleware(request, response, next) { } } -module.exports = renderDataMiddleware; \ No newline at end of file +module.exports = renderDataMiddleware; diff --git a/src/server.js b/src/server.js index fd2cd7a..2dce61b 100644 --- a/src/server.js +++ b/src/server.js @@ -12,7 +12,7 @@ const database = require('./database'); const util = require('./util'); const logger = require('./logger'); const config = require('../config.json'); -const defaultLocale = require('../locales/US_en.json'); +const defaultLocale = require('../locales/en_US.json'); const { http: { port } } = config; const app = express(); diff --git a/src/util.js b/src/util.js index f7df0d8..90f4c6a 100644 --- a/src/util.js +++ b/src/util.js @@ -13,16 +13,16 @@ function fullUrl(request) { return `${request.protocol}://${request.hostname}${request.originalUrl}`; } -function getLocale(region, language) { - const path = `${__dirname}/../locales/${region}_${language}.json`; +function getLocale(language, region) { + const path = `${__dirname}/../locales/${language}_${region}.json`; if (fs.pathExistsSync(path)) { return require(path); } - logger.warn(`Could not find locale ${region}_${language}! Loading US_en`); + logger.warn(`Could not find locale ${language}_${region}! Loading en_US`); - return require(`${__dirname}/../locales/US_en.json`); + return require(`${__dirname}/../locales/en_US.json`); } function apiGetRequest(path, headers) {