refactor: 💡 Use env variables to set locize (#1299)
Instead of relying in dynamic configuration, use dedicated env variables to set locize api key / configuration Closes: #1271
This commit is contained in:
parent
ded2e61913
commit
756f70cc54
@ -72,12 +72,17 @@ module.exports = (env, argv, { SRC_DIR, DIST_DIR }) => {
|
|||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
|
/* Application */
|
||||||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
||||||
'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
|
'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
|
||||||
'process.env.APP_CONFIG': JSON.stringify(process.env.APP_CONFIG || ''),
|
'process.env.APP_CONFIG': JSON.stringify(process.env.APP_CONFIG || ''),
|
||||||
'process.env.PUBLIC_URL': JSON.stringify(process.env.PUBLIC_URL || '/'),
|
'process.env.PUBLIC_URL': JSON.stringify(process.env.PUBLIC_URL || '/'),
|
||||||
'process.env.VERSION_NUMBER': JSON.stringify(PACKAGE.version || ''),
|
'process.env.VERSION_NUMBER': JSON.stringify(PACKAGE.version || ''),
|
||||||
'process.env.BUILD_NUM': JSON.stringify(BUILD_NUM),
|
'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
|
// Fix: https://github.com/webpack-contrib/css-loader/issues/447#issuecomment-285598881
|
||||||
|
|||||||
@ -29,19 +29,20 @@ function addLocales(newLocales) {
|
|||||||
customDebug(resourceBundle, 'info');
|
customDebug(resourceBundle, 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: Developers can add the API key to use the in-context editor.
|
/*
|
||||||
// DO NOT commit the API key
|
* Note: Developers can add the API key to use the
|
||||||
const config = (window.config && window.config.i18n) || {};
|
* in-context editor using environment variables.
|
||||||
|
* (DO NOT commit the API key)
|
||||||
|
*/
|
||||||
const locizeOptions = {
|
const locizeOptions = {
|
||||||
projectId: config.LOCIZE_PROJECTID,
|
projectId: process.env.LOCIZE_PROJECTID,
|
||||||
apiKey: config.LOCIZE_API_KEY,
|
apiKey: process.env.LOCIZE_API_KEY,
|
||||||
referenceLng: 'en-US',
|
referenceLng: 'en-US',
|
||||||
fallbacklng: 'en-US',
|
fallbacklng: 'en-US',
|
||||||
};
|
};
|
||||||
|
|
||||||
const envUseLocize = !!config.USE_LOCIZE;
|
const envUseLocize = !!process.env.USE_LOCIZE;
|
||||||
const envApiKeyAvailable = !!config.LOCIZE_API_KEY;
|
const envApiKeyAvailable = !!process.env.LOCIZE_API_KEY;
|
||||||
const DEFAULT_LANGUAGE = 'en-US';
|
const DEFAULT_LANGUAGE = 'en-US';
|
||||||
|
|
||||||
function initI18n(
|
function initI18n(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user