Merge pull request #2730 from matrix-org/dbkr/langs_file_resolve_alias

Use webpack alias to resolve the languages file
This commit is contained in:
David Baker 2019-03-01 12:13:31 +00:00 committed by GitHub
commit 4f430db981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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) => {