From 7ad08e79c99a4be0850e2213ab87a552020e2eb3 Mon Sep 17 00:00:00 2001 From: Sudhanshu Gautam Date: Fri, 13 Sep 2019 02:39:28 +0530 Subject: [PATCH] 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 --- .eslintrc.yml | 1 + src/config.js | 11 +++++++++++ src/i18n.js | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/config.js diff --git a/.eslintrc.yml b/.eslintrc.yml index 536404d..8f8e190 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,5 +1,6 @@ env: browser: true + node: true es6: true jest: true extends: diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..3a497d8 --- /dev/null +++ b/src/config.js @@ -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, +}; diff --git a/src/i18n.js b/src/i18n.js index 4a3454f..393dd03 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -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 },