From d496593f40894a49e015960f333c1a7429483485 Mon Sep 17 00:00:00 2001 From: Stuart Colville Date: Thu, 26 May 2016 18:50:13 +0100 Subject: [PATCH] Add hsb and dsb to the config and test for orphaned locales --- config/default.js | 4 ++-- tests/server/TestLocalesConfig.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/server/TestLocalesConfig.js diff --git a/config/default.js b/config/default.js index 693f43e373b..e826d8620f1 100644 --- a/config/default.js +++ b/config/default.js @@ -121,8 +121,8 @@ module.exports = { // Supported languages. langs: [ - 'af', 'ar', 'bg', 'bn-BD', 'ca', 'cs', 'da', 'de', 'dbl', 'dbr', 'el', - 'en-GB', 'en-US', 'es', 'eu', 'fa', 'fi', 'fr', 'ga-IE', 'he', 'hu', 'id', + 'af', 'ar', 'bg', 'bn-BD', 'ca', 'cs', 'da', 'de', 'dbl', 'dbr', 'dsb', 'el', + 'en-GB', 'en-US', 'es', 'eu', 'fa', 'fi', 'fr', 'ga-IE', 'he', 'hsb', 'hu', 'id', 'it', 'ja', 'ko', 'mk', 'mn', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sk', 'sl', 'sq', 'sv-SE', 'uk', 'vi', 'zh-CN', 'zh-TW', ], diff --git a/tests/server/TestLocalesConfig.js b/tests/server/TestLocalesConfig.js new file mode 100644 index 00000000000..1614a533db9 --- /dev/null +++ b/tests/server/TestLocalesConfig.js @@ -0,0 +1,28 @@ +import fs from 'fs'; +import { assert } from 'chai'; +import path from 'path'; +import config from 'config'; +import { langToLocale, localeToLang } from 'core/i18n/utils'; +import glob from 'glob'; + +const langs = config.get('langs'); +const basePath = config.get('basePath'); + +describe('Locale Config', () => { + for (const lang of langs) { + // eslint-disable no-loop-func + it(`should have a corresponding ${lang} dir in locale`, () => + fs.lstatSync(path.join(basePath, 'locale', langToLocale(lang)))); + } + + for (const localeDir of glob.sync('locale/*')) { + const locale = path.basename(localeDir); + const lang = localeToLang(locale); + if (locale === 'templates') { + continue; + } + // eslint-disable no-loop-func + it(`should have a corresponding ${lang} entry the locale dir in the config`, () => + assert.include(langs, lang, `Should be a "${lang}" entry in config.langs`)); + } +});