Skip to content

Commit

Permalink
loading backend only if s3 bucket given, using debug mode only if in …
Browse files Browse the repository at this point in the history
…development
ChrKahl committed Feb 17, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a524645 commit 51b1b3c
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zauberware/react-i18n",
"version": "0.1.1",
"version": "0.1.2",
"description": "",
"main": "lib/",
"prettier": "@zauberware/eslint-config/.prettierrc.json",
8 changes: 5 additions & 3 deletions web/i18n.js
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ const PROJECT_ID = process.env.REACT_APP_LOKALISE_PROJECT_ID;
const DEFAULT_LOCALE = process.env.REACT_APP_DEFAULT_LOCALE;
const S3_BUCKET = process.env.REACT_APP_S3_BUCKET;
const LOCALES = process.env.REACT_APP_LOCALES;
const IS_DEVELOPMENT = process.env.REACT_APP_ENV;

i18n.use(Backend)
// connect with React
@@ -28,7 +29,9 @@ i18n.use(Backend)
backends: [xhrbackend, xhrbackend],
backendOptions: [
{
loadPath: `https://s3.eu-central-1.amazonaws.com/${S3_BUCKET}/${PROJECT_ID}${ENV}{{lng}}/{{ns}}.json`,
loadPath: S3_BUCKET
? `https://s3.eu-central-1.amazonaws.com/${S3_BUCKET}/${PROJECT_ID}${ENV}{{lng}}/{{ns}}.json`
: undefined,
allowMultiLoading: false,
parse: function (data) {
return JSON.parse(data);
@@ -39,7 +42,6 @@ i18n.use(Backend)
credentials: 'same-origin',
cache: 'default',
},

// can be used to reload resources in a specific interval (useful in server environments)
reloadInterval: false,
},
@@ -52,7 +54,7 @@ i18n.use(Backend)
},
],
},
debug: true,
debug: IS_DEVELOPMENT,
lng: DEFAULT_LOCALE,
fallbackLng: DEFAULT_LOCALE,
whitelist: LOCALES,

0 comments on commit 51b1b3c

Please sign in to comment.