Merge branch 'hotfix/AW-334-translate-version' into 'main'
hotfix/AW-334-translate-version See merge request witapp/aura-webapp!460
This commit is contained in:
commit
eb6db3522e
@ -4,6 +4,7 @@ import { selectors } from "@/store";
|
|||||||
import { useCallback, useEffect, useMemo } from "react";
|
import { useCallback, useEffect, useMemo } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
import { useSearchParams } from "react-router-dom";
|
||||||
|
|
||||||
type TranslationOptions = {
|
type TranslationOptions = {
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
@ -12,12 +13,15 @@ type TranslationOptions = {
|
|||||||
export const useTranslations = (
|
export const useTranslations = (
|
||||||
placement: ELocalesPlacement = ELocalesPlacement.V0
|
placement: ELocalesPlacement = ELocalesPlacement.V0
|
||||||
) => {
|
) => {
|
||||||
|
const [searchParams] = useSearchParams();
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const gender =
|
const gender =
|
||||||
useSelector(selectors.selectQuestionnaire)?.gender || "default";
|
useSelector(selectors.selectQuestionnaire)?.gender || "default";
|
||||||
const { flags } = useMetricABFlags();
|
const { flags } = useMetricABFlags();
|
||||||
const esFlag = flags?.esFlag?.[0];
|
const esFlag = flags?.esFlag?.[0];
|
||||||
|
|
||||||
|
const translateVersion = searchParams.get("tv");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const _esFlag = localStorage.getItem("esFlag");
|
const _esFlag = localStorage.getItem("esFlag");
|
||||||
if (!_esFlag?.length && 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);
|
const translation = t(_key, options);
|
||||||
|
|
||||||
if (translation === key) {
|
if (translation === key) {
|
||||||
@ -75,7 +87,7 @@ export const useTranslations = (
|
|||||||
|
|
||||||
return translation;
|
return translation;
|
||||||
},
|
},
|
||||||
[placement, prefixGenderKey, prefixPlacementKey, t]
|
[placement, prefixGenderKey, prefixPlacementKey, t, translateVersion]
|
||||||
);
|
);
|
||||||
|
|
||||||
return useMemo(() => ({ translate, i18n }), [i18n, translate]);
|
return useMemo(() => ({ translate, i18n }), [i18n, translate]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user