fix
Some checks failed
Deploy / CreateImage (push) Has been cancelled
Deploy / DeployService (push) Has been cancelled

This commit is contained in:
Nastya 2025-07-01 17:26:50 +03:00
parent 2e3358eb2c
commit 8a09356208
4 changed files with 123 additions and 68 deletions

File diff suppressed because one or more lines are too long

@ -1,21 +1,39 @@
import { FC, SVGProps } from "react"; import { FC, SVGProps } from "react";
import { useLocation } from "react-router-dom";
// Fallback функция для получения языка, когда React Router недоступен
const getLanguageFromUrlFallback = (): string => {
const path = window.location.pathname;
const langMatch = path.match(/^\/(en|ru|uz)(\/|$)/i);
if (langMatch) {
return langMatch[1].toLowerCase();
}
return "ru";
};
export const NameplateLogoFQ: FC<SVGProps<SVGSVGElement>> = (props) => { export const NameplateLogoFQ: FC<SVGProps<SVGSVGElement>> = (props) => {
const location = useLocation(); let lang = "ru"; // fallback
const pathname = location.pathname;
const getLanguageFromUrl = () => { try {
const parts = pathname.split("/"); // Пытаемся использовать React Router
if (parts.length >= 2) { const { useLocation } = require("react-router-dom");
const langSegment = parts[1].toLowerCase(); const location = useLocation();
if (langSegment === "en") return "en"; const pathname = location.pathname;
if (langSegment === "uz") return "uz";
}
return "ru";
};
const lang = getLanguageFromUrl(); // Оптимизация - вызываем функцию один раз const getLanguageFromUrl = () => {
const parts = pathname.split("/");
if (parts.length >= 2) {
const langSegment = parts[1].toLowerCase();
if (langSegment === "en") return "en";
if (langSegment === "uz") return "uz";
}
return "ru";
};
lang = getLanguageFromUrl();
} catch (error) {
// Если React Router недоступен (в виджете), используем fallback
lang = getLanguageFromUrlFallback();
}
if (lang === "ru") return <RU {...props} />; if (lang === "ru") return <RU {...props} />;
if (lang === "en") return <EN {...props} />; if (lang === "en") return <EN {...props} />;

@ -1,21 +1,39 @@
import { FC, SVGProps } from "react"; import { FC, SVGProps } from "react";
import { useLocation } from "react-router-dom";
// Fallback функция для получения языка, когда React Router недоступен
const getLanguageFromUrlFallback = (): string => {
const path = window.location.pathname;
const langMatch = path.match(/^\/(en|ru|uz)(\/|$)/i);
if (langMatch) {
return langMatch[1].toLowerCase();
}
return "ru";
};
export const NameplateLogoFQDark: FC<SVGProps<SVGSVGElement>> = (props) => { export const NameplateLogoFQDark: FC<SVGProps<SVGSVGElement>> = (props) => {
const location = useLocation(); let lang = "ru"; // fallback
const pathname = location.pathname;
const getLanguageFromUrl = () => { try {
const parts = pathname.split("/"); // Пытаемся использовать React Router
if (parts.length >= 2) { const { useLocation } = require("react-router-dom");
const langSegment = parts[1].toLowerCase(); const location = useLocation();
if (langSegment === "en") return "en"; const pathname = location.pathname;
if (langSegment === "uz") return "uz";
}
return "ru";
};
const lang = getLanguageFromUrl(); // Оптимизация - вызываем функцию один раз const getLanguageFromUrl = () => {
const parts = pathname.split("/");
if (parts.length >= 2) {
const langSegment = parts[1].toLowerCase();
if (langSegment === "en") return "en";
if (langSegment === "uz") return "uz";
}
return "ru";
};
lang = getLanguageFromUrl();
} catch (error) {
// Если React Router недоступен (в виджете), используем fallback
lang = getLanguageFromUrlFallback();
}
if (lang === "ru") return <RU {...props} />; if (lang === "ru") return <RU {...props} />;
if (lang === "en") return <EN {...props} />; if (lang === "en") return <EN {...props} />;

@ -70,8 +70,7 @@ const r = {
"questions are not ready yet": "Вопросы для аудитории ещё не созданы. Пожалуйста, подождите", "questions are not ready yet": "Вопросы для аудитории ещё не созданы. Пожалуйста, подождите",
"Add your image": "Добавьте своё изображение", "Add your image": "Добавьте своё изображение",
"select emoji": "выберите смайлик", "select emoji": "выберите смайлик",
"file is too big": "Файл слишком большой", "": "", // Пустой ключ для fallback
"file type is not supported": "Тип файла не поддерживается",
}, },
en: { en: {
"quiz is inactive": "Quiz is inactive", "quiz is inactive": "Quiz is inactive",
@ -132,6 +131,7 @@ const r = {
"questions are not ready yet": "There are no questions for the audience yet. Please wait", "questions are not ready yet": "There are no questions for the audience yet. Please wait",
"Add your image": "Add your image", "Add your image": "Add your image",
"select emoji": "select emoji", "select emoji": "select emoji",
"": "", // Пустой ключ для fallback
}, },
uz: { uz: {
"quiz is inactive": "Test faol emas", "quiz is inactive": "Test faol emas",
@ -192,6 +192,7 @@ const r = {
"questions are not ready yet": "Tomoshabinlar uchun hozircha savollar yo'q. Iltimos kuting", "questions are not ready yet": "Tomoshabinlar uchun hozircha savollar yo'q. Iltimos kuting",
"Add your image": "Rasmingizni qo'shing", "Add your image": "Rasmingizni qo'shing",
"select emoji": "emoji tanlang", "select emoji": "emoji tanlang",
"": "", // Пустой ключ для fallback
}, },
}; };
@ -230,6 +231,10 @@ i18n
}) })
.then(() => { .then(() => {
console.log("i18n initialized. Current language:", i18n.language); console.log("i18n initialized. Current language:", i18n.language);
console.log("Available languages:", i18n.languages);
console.log("Available keys for ru:", Object.keys(r.ru));
console.log("Available keys for en:", Object.keys(r.en));
console.log("Available keys for uz:", Object.keys(r.uz));
}); });
// 4. Логирование событий // 4. Логирование событий