Skip to content

Commit

Permalink
fix: translate page JavaScript doesn't load (hedyorg#1155)
Browse files Browse the repository at this point in the history
The JavaScript app bundle depends on `client_messages.js` having
been loaded beforehand in the same page, but this script had not
yet been added to the HTML template.

Add an error message to indicate what went wrong, and fix the error.
  • Loading branch information
rix0rrr authored Nov 3, 2021
1 parent c02c1e9 commit 297c242
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion static/js/appbundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions static/js/appbundle.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions static/js/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ interface UserForm {
old_password?: string;
}

if (!(window as any).AuthMessages) {
throw new Error('On a page where you load this JavaScript, you must also load the "client_messages.js" script');
}

export const auth = {
texts: AuthMessages,
profile: undefined as (Profile | undefined),
Expand Down
1 change: 1 addition & 0 deletions templates/translate-fromto.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ <h2>{{file.caption}}</h2>
</div>

<script src="{{static('/vendor/jquery.min.js')}}" type="text/javascript" crossorigin="anonymous"></script>
<script src="/client_messages.js?lang={{ lang }}" type="text/javascript" crossorigin="anonymous"></script>
<script src="{{static('/js/appbundle.js')}}" type="text/javascript" crossorigin="anonymous"></script>
</body>
</html>

0 comments on commit 297c242

Please sign in to comment.