Skip to content

Commit

Permalink
fix: translations and next.js config
Browse files Browse the repository at this point in the history
  • Loading branch information
Qlix826 committed Jan 22, 2025
1 parent 1b45366 commit 69eba23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
20 changes: 0 additions & 20 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,9 @@ const nextConfig = {
AUTH0_ISSUER_BASE_URL: process.env.AUTH0_ISSUER_BASE_URL,
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
},
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
],
},
];
},
poweredByHeader: false,
images: {
domains: ['localhost'],
unoptimized: true,
remotePatterns: [
{
protocol: 'https',
hostname: '**',
},
],
},
output: 'export',
basePath: '/verifio',
Expand Down
23 changes: 22 additions & 1 deletion src/hooks/use-translations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useState, useCallback } from 'react';
'use client';

import { useState, useCallback, useEffect } from 'react';
import { en } from '@/translations/en';
import { fr } from '@/translations/fr';

Expand All @@ -7,6 +9,17 @@ type Translations = typeof en;

export function useTranslations() {
const [currentLanguage, setCurrentLanguage] = useState<Language>('fr');
const [isLoaded, setIsLoaded] = useState(false);

useEffect(() => {
// Charger la langue sauvegardée au démarrage
const savedLanguage = localStorage.getItem('language') as Language;
if (savedLanguage) {
setCurrentLanguage(savedLanguage);
}
setIsLoaded(true);
}, []);

const translations = currentLanguage === 'fr' ? fr : en;

const t = useCallback((path: string) => {
Expand All @@ -18,6 +31,14 @@ export function useTranslations() {
localStorage.setItem('language', language);
}, []);

if (!isLoaded) {
return {
t: (path: string) => path,
currentLanguage: 'fr' as Language,
changeLanguage: () => {},
};
}

return {
t,
currentLanguage,
Expand Down

0 comments on commit 69eba23

Please sign in to comment.