добавление переводов в зависимости юзеров
This commit is contained in:
parent
b09e587220
commit
1649d2cd9f
@ -87,7 +87,11 @@
|
||||
"react-router-dom": "^6.21.3",
|
||||
"swr": "^2.2.4",
|
||||
"use-debounce": "^9.0.4",
|
||||
"zustand": "^4.3.8"
|
||||
"zustand": "^4.3.8",
|
||||
"i18next": "^25.0.0",
|
||||
"i18next-browser-languagedetector": "^8.0.5",
|
||||
"i18next-http-backend": "^3.0.2",
|
||||
"react-i18next": "^15.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"bowser": "1.9.4",
|
||||
@ -97,10 +101,10 @@
|
||||
"i18next": "^25.0.0",
|
||||
"i18next-browser-languagedetector": "^8.0.5",
|
||||
"i18next-http-backend": "^3.0.2",
|
||||
"react-i18next": "^15.4.1",
|
||||
"mobile-detect": "^1.4.5",
|
||||
"mui-tel-input": "^5.1.2",
|
||||
"react-helmet-async": "^2.0.5",
|
||||
"react-i18next": "^15.4.1",
|
||||
"react-imask": "^7.6.0",
|
||||
"react-phone-number-input": "^3.4.1"
|
||||
},
|
||||
|
@ -18,7 +18,56 @@ const getLanguageFromURL = (): string => {
|
||||
return "ru"; // Жёсткий фолбэк
|
||||
};
|
||||
|
||||
// 2. Конфиг с полной отладкой
|
||||
// 2. Проверяем, работаем ли мы в виджете
|
||||
const isWidget = typeof window !== "undefined" && window.location.pathname.includes("widget");
|
||||
|
||||
// 3. Встроенные переводы для виджета
|
||||
const builtInTranslations = {
|
||||
ru: {
|
||||
Next: "Далее",
|
||||
Prev: "Назад",
|
||||
Step: "Шаг",
|
||||
of: "из",
|
||||
"Enter your answer": "Введите ваш ответ",
|
||||
"Fill out the form to receive your test results": "Заполните форму для получения результатов теста",
|
||||
Name: "Имя",
|
||||
"Phone number": "Номер телефона",
|
||||
"Get results": "Получить результаты",
|
||||
"Data sent successfully": "Данные отправлены успешно",
|
||||
"Please fill in the fields": "Пожалуйста, заполните поля",
|
||||
"Incorrect email entered": "Введен некорректный email",
|
||||
"quiz is inactive": "Квиз неактивен",
|
||||
"no questions found": "Вопросы не найдены",
|
||||
"quiz is empty": "Квиз пуст",
|
||||
"quiz already completed": "Квиз уже пройден",
|
||||
"no quiz id": "ID квиза не указан",
|
||||
"quiz data is null": "Данные квиза не предоставлены",
|
||||
"default message": "Что-то пошло не так",
|
||||
},
|
||||
en: {
|
||||
Next: "Next",
|
||||
Prev: "Previous",
|
||||
Step: "Step",
|
||||
of: "of",
|
||||
"Enter your answer": "Enter your answer",
|
||||
"Fill out the form to receive your test results": "Fill out the form to receive your test results",
|
||||
Name: "Name",
|
||||
"Phone number": "Phone number",
|
||||
"Get results": "Get results",
|
||||
"Data sent successfully": "Data sent successfully",
|
||||
"Please fill in the fields": "Please fill in the fields",
|
||||
"Incorrect email entered": "Incorrect email entered",
|
||||
"quiz is inactive": "Quiz is inactive",
|
||||
"no questions found": "No questions found",
|
||||
"quiz is empty": "Quiz is empty",
|
||||
"quiz already completed": "Quiz already completed",
|
||||
"no quiz id": "No quiz id",
|
||||
"quiz data is null": "Quiz data is null",
|
||||
"default message": "Something went wrong",
|
||||
},
|
||||
};
|
||||
|
||||
// 4. Конфиг с полной отладкой
|
||||
i18n
|
||||
.use(Backend)
|
||||
.use(initReactI18next)
|
||||
@ -31,7 +80,7 @@ i18n
|
||||
escapeValue: false,
|
||||
},
|
||||
backend: {
|
||||
loadPath: "/locales/{{lng}}.json",
|
||||
loadPath: "/locales/{{lng}}.json", // Единый путь для всех
|
||||
allowMultiLoading: false,
|
||||
},
|
||||
react: {
|
||||
@ -54,6 +103,7 @@ i18n
|
||||
stack: new Error().stack, // Выведет стек вызовов
|
||||
});
|
||||
},
|
||||
resources: isWidget ? builtInTranslations : undefined, // Встроенные переводы для виджета
|
||||
})
|
||||
.then(() => {
|
||||
//console.log("i18n инициализирован! Текущий язык:", i18n.language);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import QuizAnswerer from "@/components/QuizAnswerer";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import "./i18n/i18n"; // Инициализация i18n для виджета
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export * from "./widgets";
|
||||
|
||||
@ -19,7 +20,13 @@ const widget = {
|
||||
|
||||
const root = createRoot(element);
|
||||
|
||||
root.render(<QuizAnswerer quizId={quizId} changeFaviconAndTitle={changeFaviconAndTitle} disableGlobalCss />);
|
||||
root.render(
|
||||
<QuizAnswerer
|
||||
quizId={quizId}
|
||||
changeFaviconAndTitle={changeFaviconAndTitle}
|
||||
disableGlobalCss
|
||||
/>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user