Sfoglia il codice sorgente

feat: Enhance Home component to support language messaging

- Added language messaging functionality to the iframe in the Home component.
- This update ensures that the iframe receives the current language setting, improving localization support.
CalciumIon 1 anno fa
parent
commit
fe6f3d7978
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  1. 2 1
      web/src/pages/Home/index.js

+ 2 - 1
web/src/pages/Home/index.js

@@ -7,7 +7,7 @@ import { StyleContext } from '../../context/Style/index.js';
 import { useTranslation } from 'react-i18next';
 
 const Home = () => {
-  const { t } = useTranslation();
+  const { t, i18n } = useTranslation();
   const [statusState] = useContext(StatusContext);
   const [homePageContentLoaded, setHomePageContentLoaded] = useState(false);
   const [homePageContent, setHomePageContent] = useState('');
@@ -49,6 +49,7 @@ const Home = () => {
                 // console.log('Sending theme-mode to iframe:', theme); 
                 iframe.onload = () => {
                     iframe.contentWindow.postMessage({ themeMode: theme }, '*');
+                    iframe.contentWindow.postMessage({ lang: i18n.language }, '*');
                 };
             }
         }