feat: i18n user interface (#40306)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -1,16 +1,22 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const debug = require('debug');
|
||||
|
||||
const env = require('../../../config/env');
|
||||
|
||||
const log = debug('fcc:ensure-env');
|
||||
const { availableLangs } = require('../../../client/i18n/allLangs');
|
||||
|
||||
const clientPath = path.resolve(__dirname, '../../../client');
|
||||
const globalConfigPath = path.resolve(__dirname, '../../../config');
|
||||
|
||||
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`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (FREECODECAMP_NODE_ENV !== 'development') {
|
||||
const locationKeys = [
|
||||
'homeLocation',
|
||||
@ -19,7 +25,9 @@ if (FREECODECAMP_NODE_ENV !== 'development') {
|
||||
'newsLocation'
|
||||
];
|
||||
const deploymentKeys = [
|
||||
'locale',
|
||||
'clientLocale',
|
||||
'curriculumLocale',
|
||||
'showLocaleDropdownMenu',
|
||||
'deploymentEnv',
|
||||
'environment',
|
||||
'showUpcomingChanges'
|
||||
@ -54,8 +62,10 @@ if (FREECODECAMP_NODE_ENV !== 'development') {
|
||||
|
||||
if (env['showUpcomingChanges'])
|
||||
throw Error("SHOW_UPCOMING_CHANGES should never be 'true' in production");
|
||||
|
||||
checkClientLocale();
|
||||
} else {
|
||||
log('Skipping environment variable checks in development');
|
||||
checkClientLocale();
|
||||
}
|
||||
|
||||
fs.writeFileSync(`${clientPath}/config/env.json`, JSON.stringify(env));
|
||||
|
Reference in New Issue
Block a user