File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
import eventManager from '../utils/eventManager.js' ;
2
- import { global } from '../utils/global.js' ;
2
+ import { global , globalSet } from '../utils/global.js' ;
3
3
4
4
eventManager . on ( ':loaded' , ( ) => {
5
- if ( global ( 'translationReady' , { throws : false } ) ) {
5
+ const READY = 'translationReady' ;
6
+ if ( global ( READY , { throws : false } ) ) {
6
7
eventManager . singleton . emit ( 'translation:loaded' ) ;
7
8
} else {
8
- document . addEventListener ( 'translationReady' , ( ) => {
9
+ document . addEventListener ( READY , ( ) => {
9
10
eventManager . singleton . emit ( 'translation:loaded' ) ;
10
11
} , {
11
12
once : true ,
12
13
} ) ;
14
+ // Fallback for if translation function breaks
15
+ eventManager . on ( ':load' , ( ) => {
16
+ const translationReady = global ( READY , { throws : false } ) ;
17
+ if ( translationReady !== false ) return ;
18
+ globalSet ( READY , true ) ;
19
+ document . dispatchEvent ( global ( 'translationEvent' ) ) ;
20
+ } ) ;
13
21
}
14
22
} ) ;
You can’t perform that action at this time.
0 commit comments