Skip to content

Commit

Permalink
fix Translation title tag
Browse files Browse the repository at this point in the history
  • Loading branch information
EstherKal committed Dec 19, 2024
1 parent 3d15c63 commit f0ebe2c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import './App.scss'
import 'leaflet/dist/leaflet.css'
import 'moment/locale/he'
import { RouterProvider } from 'react-router-dom'
import { Suspense } from 'react'
import { Suspense, useEffect } from 'react'
import moment from 'moment-timezone'
import Preloader from './shared/Preloader'
import router from './routes'
import 'moment/dist/locale/he'
import { useTranslation } from 'react-i18next'

Check failure on line 10 in src/App.tsx

View workflow job for this annotation

GitHub Actions / local-tests

`react-i18next` import should occur before import of `./shared/Preloader`

moment.tz.setDefault('Asia/Jerusalem')
moment.locale('he')
Expand All @@ -18,9 +19,20 @@ if ('serviceWorker' in navigator) {
.catch((err) => console.error('Service Worker Registration Failed', err))
}

export const RoutedApp = () => (
<Suspense fallback={<Preloader />}>
<RouterProvider router={router} />
</Suspense>
)
export const RoutedApp = () => {
const { i18n } = useTranslation(); // Access i18n for language management

Check failure on line 23 in src/App.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
const currentLanguage = i18n.language; // Get the current language

Check failure on line 24 in src/App.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`

// Effect hook to update the title based on the current language
useEffect(() => {
const title = currentLanguage === 'he' ? 'דאטאבוס' : 'Databus'; // Set title based on language

Check failure on line 28 in src/App.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
document.title = title; // Update the <title> tag in the document

Check failure on line 29 in src/App.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
}, [currentLanguage]); // Re-run when the language changes

Check failure on line 30 in src/App.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`

return (
<Suspense fallback={<Preloader />}>
<RouterProvider router={router} />
</Suspense>
);

Check failure on line 36 in src/App.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
};

Check failure on line 37 in src/App.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
export default RoutedApp

0 comments on commit f0ebe2c

Please sign in to comment.