diff --git a/.webpack/webpack.base.js b/.webpack/webpack.base.js index 7d932bd26..d90236144 100644 --- a/.webpack/webpack.base.js +++ b/.webpack/webpack.base.js @@ -72,12 +72,17 @@ module.exports = (env, argv, { SRC_DIR, DIST_DIR }) => { }, plugins: [ new webpack.DefinePlugin({ + /* Application */ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), 'process.env.DEBUG': JSON.stringify(process.env.DEBUG), 'process.env.APP_CONFIG': JSON.stringify(process.env.APP_CONFIG || ''), 'process.env.PUBLIC_URL': JSON.stringify(process.env.PUBLIC_URL || '/'), 'process.env.VERSION_NUMBER': JSON.stringify(PACKAGE.version || ''), 'process.env.BUILD_NUM': JSON.stringify(BUILD_NUM), + /* i18n */ + 'process.env.USE_LOCIZE': JSON.stringify(process.env.USE_LOCIZE || ''), + 'process.env.LOCIZE_PROJECTID': JSON.stringify(process.env.LOCIZE_PROJECTID || ''), + 'process.env.LOCIZE_API_KEY': JSON.stringify(process.env.LOCIZE_API_KEY || ''), }), ], // Fix: https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-285598881 diff --git a/platform/i18n/src/index.js b/platform/i18n/src/index.js index f8b34fc9f..1ad95d090 100644 --- a/platform/i18n/src/index.js +++ b/platform/i18n/src/index.js @@ -29,19 +29,20 @@ function addLocales(newLocales) { customDebug(resourceBundle, 'info'); } -// Note: Developers can add the API key to use the in-context editor. -// DO NOT commit the API key -const config = (window.config && window.config.i18n) || {}; - +/* + * Note: Developers can add the API key to use the + * in-context editor using environment variables. + * (DO NOT commit the API key) + */ const locizeOptions = { - projectId: config.LOCIZE_PROJECTID, - apiKey: config.LOCIZE_API_KEY, + projectId: process.env.LOCIZE_PROJECTID, + apiKey: process.env.LOCIZE_API_KEY, referenceLng: 'en-US', fallbacklng: 'en-US', }; -const envUseLocize = !!config.USE_LOCIZE; -const envApiKeyAvailable = !!config.LOCIZE_API_KEY; +const envUseLocize = !!process.env.USE_LOCIZE; +const envApiKeyAvailable = !!process.env.LOCIZE_API_KEY; const DEFAULT_LANGUAGE = 'en-US'; function initI18n(