diff --git a/src/hooks/translations/index.tsx b/src/hooks/translations/index.tsx index bd46fd6..01c564d 100644 --- a/src/hooks/translations/index.tsx +++ b/src/hooks/translations/index.tsx @@ -4,6 +4,7 @@ import { selectors } from "@/store"; import { useCallback, useEffect, useMemo } from "react"; import { useTranslation } from "react-i18next"; import { useSelector } from "react-redux"; +import { useSearchParams } from "react-router-dom"; type TranslationOptions = { [key: string]: unknown; @@ -12,12 +13,15 @@ type TranslationOptions = { export const useTranslations = ( placement: ELocalesPlacement = ELocalesPlacement.V0 ) => { + const [searchParams] = useSearchParams(); const { t, i18n } = useTranslation(); const gender = useSelector(selectors.selectQuestionnaire)?.gender || "default"; const { flags } = useMetricABFlags(); const esFlag = flags?.esFlag?.[0]; + const translateVersion = searchParams.get("tv"); + useEffect(() => { const _esFlag = localStorage.getItem("esFlag"); if (!_esFlag?.length && esFlag) { @@ -64,6 +68,14 @@ export const useTranslations = ( ); } + // Hint translate + if (translateVersion === "h") { + _key = prefixPlacementKey( + prefixGenderKey(key), + ELocalesPlacement.PalmistryV01 + ); + } + const translation = t(_key, options); if (translation === key) { @@ -75,7 +87,7 @@ export const useTranslations = ( return translation; }, - [placement, prefixGenderKey, prefixPlacementKey, t] + [placement, prefixGenderKey, prefixPlacementKey, t, translateVersion] ); return useMemo(() => ({ translate, i18n }), [i18n, translate]);