@@ -273,45 +273,49 @@ export default class LanguageProvider {
273273 // Hooks //
274274 // /////////
275275
276- init ( ) { }
276+ async initSequence ( ) {
277+ await this . getLanguages ( ) ;
278+ this . loadFonts ( ) ;
279+ this . loadLanguages ( ) ;
280+ this . loadCustomFonts ( ) ;
281+ this . reloadLanguages ( ) ;
282+ }
277283
278- i18nInit ( ) { }
284+ async setupSequence ( ) {
285+ this . getDefaultLanguage ( ) ;
286+ }
279287
280- /**
281- * Loads everything that can't be loaded on the constructor due to async/await.
282- * It Hooks on ready if the system depends on reading compendiums.
283- */
284- async setup ( ) {
288+ init ( ) {
285289 game . polyglot . omniglot = game . settings . get ( "polyglot" , "omniglot" ) ;
286290 game . polyglot . comprehendLanguages = game . settings . get ( "polyglot" , "comprehendLanguages" ) ;
287291 game . polyglot . truespeech = game . settings . get ( "polyglot" , "truespeech" ) ;
292+ }
288293
289- const setupSteps = async ( ) => {
290- await this . getLanguages ( ) ;
291- this . loadFonts ( ) ;
292- this . loadLanguages ( ) ;
293- this . loadCustomFonts ( ) ;
294- this . reloadLanguages ( ) ;
295- this . getDefaultLanguage ( ) ;
296- } ;
297- if ( this . requiresReady ) {
298- if ( game . modules . get ( "babele" ) ?. active ) {
299- Hooks . on ( "babele.ready" , async ( ) => {
300- await setupSteps ( ) ;
301- Hooks . callAll ( "polyglot.languageProvider.ready" ) ;
302- } ) ;
303- } else {
304- Hooks . on ( "ready" , async ( ) => {
305- await setupSteps ( ) ;
306- Hooks . callAll ( "polyglot.languageProvider.ready" ) ;
307- } ) ;
308- }
309- } else {
310- await setupSteps ( ) ;
294+ async i18nInit ( ) {
295+ if ( ! this . requiresReady ) {
296+ await this . initSequence ( ) ;
297+ }
298+ }
299+
300+ async setup ( ) {
301+ if ( ! this . requiresReady ) {
302+ await this . setupSequence ( ) ;
303+ } else if ( game . modules . get ( "babele" ) ?. active ) {
304+ Hooks . on ( "babele.ready" , async ( ) => {
305+ await this . initSequence ( ) ;
306+ await this . setupSequence ( ) ;
307+ Hooks . callAll ( "polyglot.languageProvider.ready" ) ;
308+ } ) ;
311309 }
312310 }
313311
314- ready ( ) { }
312+ async ready ( ) {
313+ if ( this . requiresReady && ! game . modules . get ( "babele" ) ?. active ) {
314+ await this . initSequence ( ) ;
315+ await this . setupSequence ( ) ;
316+ Hooks . callAll ( "polyglot.languageProvider.ready" ) ;
317+ }
318+ }
315319
316320 /**
317321 * Even though the base method doesn't have an await, some providers might need it to look into compendiums.
0 commit comments