From 9db28d0d521f8cafe6138c1ca07604146fd1db3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Mon, 4 Nov 2024 20:49:56 +0000 Subject: [PATCH] hotfix/AW-334-translate-version --- src/hooks/translations/index.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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]);