diff --git a/.eslintrc.js b/.eslintrc.js index 8474cd86d7..fdf0bb351e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,6 +15,9 @@ module.exports = { "flowtype", "babel" ], + globals: { + LANGUAGES_FILE: "readonly", + }, env: { es6: true, }, diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index a353e38a06..df192d70b2 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -23,5 +23,5 @@ ln -s "$REACT_SDK_DIR/node_modules/matrix-js-sdk" node_modules/matrix-js-sdk rm -r node_modules/matrix-react-sdk ln -s "$REACT_SDK_DIR" node_modules/matrix-react-sdk -npm run build +RIOT_LANGUAGES_FILE="../riot-web/webapp/i18n/languages.json" npm run build popd diff --git a/src/languageHandler.js b/src/languageHandler.js index 8735150d20..7c1a47fed9 100644 --- a/src/languageHandler.js +++ b/src/languageHandler.js @@ -338,8 +338,10 @@ export function getCurrentLanguage() { function getLangsJson() { return new Promise((resolve, reject) => { + // LANGUAGES_FILE is a webpack compile-time define, see webpack config + const url = (typeof LANGUAGES_FILE === "string") ? require(LANGUAGES_FILE) : (i18nFolder + 'languages.json'); request( - { method: "GET", url: i18nFolder + 'languages.json' }, + { method: "GET", url }, (err, response, body) => { if (err || response.status < 200 || response.status >= 300) { reject({err: err, response: response});