diff --git a/client/i18n/config.js b/client/i18n/config.js index d2e0123117..ede88b4af0 100644 --- a/client/i18n/config.js +++ b/client/i18n/config.js @@ -1,7 +1,7 @@ import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; -const { environment, clientLocale } = require('../config/env'); +const { clientLocale } = require('../config/env'); const { i18nextCodes } = require('./allLangs'); const i18nextCode = i18nextCodes[clientLocale]; @@ -20,7 +20,8 @@ i18n.use(initReactI18next).init({ ns: ['translations', 'trending', 'intro'], defaultNS: 'translations', returnObjects: true, - debug: environment === 'development', + // Uncomment the next line for debug logging + // debug: true, interpolation: { escapeValue: false }, diff --git a/config/env.js b/config/env.js index 0f70cbe608..81887a5247 100644 --- a/config/env.js +++ b/config/env.js @@ -30,11 +30,13 @@ const { const locations = { homeLocation, + chineseHome: !chineseHome ? 'https://chinese.freecodecamp.org' : chineseHome, apiLocation, forumLocation, newsLocation, - radioLocation, - chineseHome + radioLocation: !radioLocation + ? 'https://coderadio.freecodecamp.org' + : radioLocation }; module.exports = Object.assign(locations, { diff --git a/tools/scripts/build/ensure-env.js b/tools/scripts/build/ensure-env.js index 8b1d7dc4ba..2f5fc87eb2 100644 --- a/tools/scripts/build/ensure-env.js +++ b/tools/scripts/build/ensure-env.js @@ -11,26 +11,32 @@ const { FREECODECAMP_NODE_ENV } = process.env; function checkClientLocale() { if (!availableLangs.client.includes(process.env.CLIENT_LOCALE)) { - throw Error( - `CLIENT_LOCALE, ${process.env.CLIENT_LOCALE}, is not an available language in client/i18n/allLangs.js` - ); + throw Error(` + + CLIENT_LOCALE, ${process.env.CLIENT_LOCALE}, is not an available language in client/i18n/allLangs.js + + `); } } function checkCurriculumLocale() { if (!availableLangs.curriculum.includes(process.env.CURRICULUM_LOCALE)) { - throw Error( - `CURRICULUM_LOCALE, ${process.env.CURRICULUM_LOCALE}, is not an available language in client/i18n/allLangs.js` - ); + throw Error(` + + CURRICULUM_LOCALE, ${process.env.CURRICULUM_LOCALE}, is not an available language in client/i18n/allLangs.js + + `); } } if (FREECODECAMP_NODE_ENV !== 'development') { const locationKeys = [ 'homeLocation', + 'chineseHome', 'apiLocation', 'forumLocation', - 'newsLocation' + 'newsLocation', + 'radioLocation' ]; const deploymentKeys = [ 'clientLocale', @@ -48,28 +54,49 @@ if (FREECODECAMP_NODE_ENV !== 'development') { searchKeys, donationKeys ); - const variables = Object.keys(env); + const receivedvariables = Object.keys(env); expectedVariables.sort(); - variables.sort(); - if (expectedVariables.length !== variables.length) { - throw Error(`Env. variable validation failed. Expected - ${expectedVariables} - but recieved - ${variables} + receivedvariables.sort(); + if (expectedVariables.length !== receivedvariables.length) { + throw Error(` + + Env. variable validation failed. Make sure these keys are used and configured. + + Mismatch: + ${expectedVariables + .filter(expected => !receivedvariables.includes(expected)) + .concat( + receivedvariables.filter( + received => !expectedVariables.includes(received) + ) + )} + `); } for (const key of expectedVariables) { if (typeof env[key] === 'undefined' || env[key] === null) { - throw Error(`Env. variable ${key} is missing, build cannot continue`); + throw Error(` + + Env. variable ${key} is missing, build cannot continue + + `); } } if (env['environment'] !== 'production') - throw Error("Production environment should be 'production' "); + throw Error(` + + Production environment should be 'production' + + `); if (env['showUpcomingChanges']) - throw Error("SHOW_UPCOMING_CHANGES should never be 'true' in production"); + throw Error(` + + SHOW_UPCOMING_CHANGES should never be 'true' in production + + `); checkClientLocale(); checkCurriculumLocale();