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

Use webpack alias to resolve the languages file #2730

Merged
merged 4 commits into from
Mar 1, 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
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

RIOT_LANGUAGES_FILE="../riot-web/webapp/i18n/languages.json" npm run build
npm run build
popd
9 changes: 7 additions & 2 deletions src/languageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,13 @@ 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');
let url;
try {
// $webapp is a webpack resolve alias pointing to the output directory, see webpack config
url = require('$webapp/i18n/languages.json');
} catch (e) {
url = i18nFolder + 'languages.json';
}
request(
{ method: "GET", url },
(err, response, body) => {
Expand Down