Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Cache-bust languages.json with file-loader #2658

Merged
merged 5 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module.exports = {
"flowtype",
"babel"
],
globals: {
LANGUAGES_FILE: "readonly",
},
env: {
es6: true,
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/travis/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion src/languageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down