From 684a1bc72b61e7229e75529b82d8907b7ebf8c40 Mon Sep 17 00:00:00 2001 From: Jon Eugster Date: Fri, 29 Mar 2024 12:16:36 +0100 Subject: [PATCH] fix initial translation loading on starting page --- client/src/components/landing_page.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/components/landing_page.tsx b/client/src/components/landing_page.tsx index 26ab89b..30fb2d4 100644 --- a/client/src/components/landing_page.tsx +++ b/client/src/components/landing_page.tsx @@ -39,13 +39,16 @@ function Tile({gameId, data}: {gameId: string, data: GameTile|undefined}) { navigate(gameId); } + // we use this to reload the tile 1x after the translation is loaded. + let [loadedTranslation, setLoadedTranslation] = React.useState(false) + + // Load the namespace of the game + i18next.loadNamespaces(gameId).catch(err => {}).then(() => {setLoadedTranslation(true)}) + if (typeof data === 'undefined') { return <> } - // Load the namespace of the game - i18next.loadNamespaces(gameId) - return
{t(data.title, { ns: gameId })}