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

Commit 4f430db

Browse files
authored
Merge pull request #2730 from matrix-org/dbkr/langs_file_resolve_alias
Use webpack alias to resolve the languages file
2 parents 52a2fe1 + 4f84311 commit 4f430db

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

scripts/travis/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ ln -s "$REACT_SDK_DIR/node_modules/matrix-js-sdk" node_modules/matrix-js-sdk
2323
rm -r node_modules/matrix-react-sdk
2424
ln -s "$REACT_SDK_DIR" node_modules/matrix-react-sdk
2525

26-
RIOT_LANGUAGES_FILE="../riot-web/webapp/i18n/languages.json" npm run build
26+
npm run build
2727
popd

src/languageHandler.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,13 @@ export function getCurrentLanguage() {
338338

339339
function getLangsJson() {
340340
return new Promise((resolve, reject) => {
341-
// LANGUAGES_FILE is a webpack compile-time define, see webpack config
342-
const url = (typeof LANGUAGES_FILE === "string") ? require(LANGUAGES_FILE) : (i18nFolder + 'languages.json');
341+
let url;
342+
try {
343+
// $webapp is a webpack resolve alias pointing to the output directory, see webpack config
344+
url = require('$webapp/i18n/languages.json');
345+
} catch (e) {
346+
url = i18nFolder + 'languages.json';
347+
}
343348
request(
344349
{ method: "GET", url },
345350
(err, response, body) => {

0 commit comments

Comments
 (0)