added english language

This commit is contained in:
SlimusMinus
2026-07-09 00:09:45 +03:00
parent 3b503623f6
commit fffcdaa526
33 changed files with 454 additions and 687 deletions

View File

@@ -7,8 +7,10 @@ import { getPostForChat } from "../stores/chatPostStore";
import { API_URL } from "../config/authConstants";
import { useDeleteChat } from "../hooks/useDeleteChat";
import TrashIcon from "../components/icons/TrashIcon";
import { useTranslation } from 'react-i18next';
export default function ChatListPage() {
const { t } = useTranslation();
const navigate = useNavigate();
const { chats, loading, fetchChats } = useChats();
const { isAuthenticated } = useAuthContext();
@@ -28,10 +30,10 @@ export default function ChatListPage() {
}, [chats, updateFromChats]);
const handleDeleteChat = useCallback(async (chatId) => {
if (!window.confirm("Вы уверены, что хотите удалить этот чат?")) return;
if (!window.confirm(t('chat.confirmDeleteChat'))) return;
const ok = await deleteChat(chatId);
if (ok) fetchChats();
}, [deleteChat, fetchChats]);
}, [t, deleteChat, fetchChats]);
if (!isAuthenticated) {
return (
@@ -41,10 +43,10 @@ export default function ChatListPage() {
<button className="chat-back-btn" onClick={() => navigate("/feed")}>
←
</button>
<div className="chat-header-title">Чаты</div>
<div className="chat-header-title">{t('chat.chats')}</div>
<div />
</div>
<div className="chat-empty-full">Войдите, чтобы видеть чаты</div>
<div className="chat-empty-full">{t('chat.loginToSee')}</div>
</div>
</div>
);
@@ -57,22 +59,22 @@ export default function ChatListPage() {
<button className="chat-back-btn" onClick={() => navigate("/feed")}>
←
</button>
<div className="chat-header-title">Чаты</div>
<div className="chat-header-title">{t('chat.chats')}</div>
<div />
</div>
<div className="chat-list">
{loading && (
<div className="chat-empty-full">Загрузка...</div>
<div className="chat-empty-full">{t('chat.loading')}</div>
)}
{!loading && chats.length === 0 && (
<div className="chat-empty-full">У вас пока нет чатов</div>
<div className="chat-empty-full">{t('chat.noChats')}</div>
)}
{!loading && chats.map((chat) => {
const post = getPostForChat(chat.id);
const title = post?.title || chat.otherUser?.name || "Пользователь";
const title = post?.title || chat.otherUser?.name || t('chat.user');
const imgSrc = post?.images?.[0] ? `${API_URL}${post.images[0]}` : null;
const emoji = post?.emoji;
const unreadCount = unreadMap[chat.id] ?? chat.unreadCount ?? chat.unreadMessages ?? 0;
@@ -92,7 +94,7 @@ export default function ChatListPage() {
<div className="chat-list-info">
<div className="chat-list-name">{title}</div>
<div className="chat-list-preview">
{chat.lastMessage?.content || "Нет сообщений"}
{chat.lastMessage?.content || t('chat.noMessages')}
</div>
</div>
{unreadCount > 0 && (
@@ -100,7 +102,7 @@ export default function ChatListPage() {
)}
<button
className="chat-list-delete-btn"
title="Удалить чат"
title={t('chat.deleteChat')}
onClick={(e) => {
e.stopPropagation();
handleDeleteChat(chat.id);