Add config system

Introduce ability to change default settings for the app.
Currently starting with disabling i18n debug on prod server

Signed-off-by: Sudhanshu Gautam <me@sudhanshug.com>
This commit is contained in:
Sudhanshu Gautam 2019-09-13 02:39:28 +05:30
parent b835f928a4
commit 7ad08e79c9
3 changed files with 14 additions and 1 deletions

11
src/config.js Normal file
View file

@ -0,0 +1,11 @@
const defaults = {};
const prod = {
i18nDebug: false,
};
const dev = {
i18nDebug: true,
};
export default {
...defaults,
settings: process.env.NODE_ENV === 'development' ? dev : prod,
};

View file

@ -3,6 +3,7 @@ import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import translationEN from './locales/en.json';
import translationDE from './locales/de.json';
import Config from './config';
const resources = {
en: {
@ -19,7 +20,7 @@ i18n
.init({
resources,
fallbackLng: 'en',
debug: true,
debug: Config.settings.i18nDebug,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},