mirror of
				https://gitlab.com/Alamantus/Readlebee.git
				synced 2025-11-04 10:17:03 +01:00 
			
		
		
		
	Make request.language default to 'en'
Add i18n.pages.default using 'en' locale
This commit is contained in:
		
							parent
							
								
									3bfaf5f3df
								
							
						
					
					
						commit
						0e956f6c67
					
				
					 2 changed files with 2 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -36,6 +36,7 @@ async function plugin (fastify, opts, done) {
 | 
			
		|||
 | 
			
		||||
    // Set the default language to English after parsing locales because it has the most coverage.
 | 
			
		||||
    i18n.default = i18n.en;
 | 
			
		||||
    i18n.pages.default = i18n.pages.en;
 | 
			
		||||
  } catch (ex) {
 | 
			
		||||
    console.error('Could not get locales folder.\n', ex);
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -100,9 +100,7 @@ fastify.addHook('onRequest', async (request, reply) => {
 | 
			
		|||
      request.user = user;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  if (typeof request.cookies.lang !== 'undefined') {
 | 
			
		||||
    request.language = request.cookies.lang;
 | 
			
		||||
  }
 | 
			
		||||
  request.language = typeof request.cookies.lang !== 'undefined' ? request.cookies.lang : 'en';
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
// Store i18n files in fastify object and register locales routes
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue