From 6c080ecb69021fab8946053c3a8eba927ffae6e7 Mon Sep 17 00:00:00 2001 From: Katerina Kashleva <40360807+ketrinFox5@users.noreply.github.com> Date: Mon, 17 Feb 2025 15:04:12 +0000 Subject: [PATCH 1/5] added json files and corrected text in files --- i18n.server.js | 2 +- locales/en/chat.json | 8 +++ locales/en/common.json | 4 +- locales/en/createBook.json | 25 +++++++++ locales/en/header.json | 13 +++++ locales/en/home.json | 17 ++++++ locales/en/profile.json | 11 ++++ locales/en/search.json | 20 +++++++ locales/ru/chat.json | 7 ++- locales/ru/common.json | 4 +- locales/ru/createBook.json | 25 +++++++++ locales/ru/header.json | 13 +++++ locales/ru/home.json | 17 ++++++ locales/ru/profile.json | 11 ++++ locales/ru/search.json | 20 +++++++ src/components/Header/components/Nav.tsx | 15 ++--- .../Header/components/SearchInput.tsx | 4 +- src/pages/chat/body/ChatBody.tsx | 5 +- .../chat/currentUser/ChatCurrentUser.tsx | 42 +++++++++----- src/pages/createBook/CreateBook.tsx | 28 +++++----- .../Filter/components/FilterGenre.tsx | 20 ++++--- .../Filter/components/FilterType.tsx | 22 ++++++-- src/pages/profile/info/ProfileInfo.tsx | 5 +- .../otherButtons/ProfileOtherButtons.tsx | 4 +- .../profile/ownButtons/ProfileOwnButtons.tsx | 4 +- .../search/FullFilter/CheckboxFilter.tsx | 4 +- src/pages/search/FullFilter/FilterFull.tsx | 56 +++++++++---------- 27 files changed, 318 insertions(+), 88 deletions(-) create mode 100644 locales/en/chat.json create mode 100644 locales/en/createBook.json create mode 100644 locales/en/header.json create mode 100644 locales/en/home.json create mode 100644 locales/en/profile.json create mode 100644 locales/en/search.json create mode 100644 locales/ru/createBook.json create mode 100644 locales/ru/header.json create mode 100644 locales/ru/home.json create mode 100644 locales/ru/profile.json create mode 100644 locales/ru/search.json diff --git a/i18n.server.js b/i18n.server.js index 1ffdefe..51479fb 100644 --- a/i18n.server.js +++ b/i18n.server.js @@ -16,7 +16,7 @@ export function createI18nInstance() { .init({ fallbackLng: "en", preload: ["en", "ru"], - ns: ["common", "auth", "chat"], + ns: ["common", "auth", "chat", "home", "header", "search", "profile", "createBook"], defaultNS: "common", backend: { loadPath: __dirname + "/locales/{{lng}}/{{ns}}.json", diff --git a/locales/en/chat.json b/locales/en/chat.json new file mode 100644 index 0000000..5e67553 --- /dev/null +++ b/locales/en/chat.json @@ -0,0 +1,8 @@ +{ + "title": "Chats", + "chat": { + "body": "Who do you want to contact?", + "delete": "Delete chat", + "book": "Book " + } +} \ No newline at end of file diff --git a/locales/en/common.json b/locales/en/common.json index 9e26dfe..a78129b 100644 --- a/locales/en/common.json +++ b/locales/en/common.json @@ -1 +1,3 @@ -{} \ No newline at end of file +{ + "notFound": "404 page not found" +} \ No newline at end of file diff --git a/locales/en/createBook.json b/locales/en/createBook.json new file mode 100644 index 0000000..390b5b8 --- /dev/null +++ b/locales/en/createBook.json @@ -0,0 +1,25 @@ +{ + "title": { + "label": "Title", + "message": "Please enter the title of the book", + "placeholder": "Enter the book title" + }, + "author": { + "label": "Author", + "message": "Please enter the author's name", + "placeholder": "Enter the author's name" + }, + "genre": { + "label": "Genre", + "placeholder": "Enter the book genre (optional)" + }, + "publishingHouse": { + "label": "Publishing house", + "placeholder": "Enter the publisher (optional)" + }, + "year": { + "label": "Year of publication", + "placeholder": "Enter the year of publication (optional)" + }, + "save": "Save" +} \ No newline at end of file diff --git a/locales/en/header.json b/locales/en/header.json new file mode 100644 index 0000000..c09b27c --- /dev/null +++ b/locales/en/header.json @@ -0,0 +1,13 @@ +{ + "nav": { + "titles": { + "main": "Home", + "favourites": "Favourites", + "chats": "Chats", + "createBook": "Create a book" + } + }, + "search": { + "placeholder": "Search for fantasy, detective, novels" + } +} \ No newline at end of file diff --git a/locales/en/home.json b/locales/en/home.json new file mode 100644 index 0000000..bef08f6 --- /dev/null +++ b/locales/en/home.json @@ -0,0 +1,17 @@ +{ + "filters": { + "type": { + "exchange": "Exchanges", + "giveAway": "Gives Away", + "allOptions": "All options" + }, + "genre": { + "all": "All", + "detectives": "Detectives", + "novels": "Novels", + "scientific": "Scientific", + "horrors": "Horrors", + "textbook": "Textbook" + } + } +} \ No newline at end of file diff --git a/locales/en/profile.json b/locales/en/profile.json new file mode 100644 index 0000000..23f6313 --- /dev/null +++ b/locales/en/profile.json @@ -0,0 +1,11 @@ +{ + "otherButtons": { + "write": "Send a message" + }, + "ownButtons": { + "newAd": "Create a book" + }, + "info": { + "score": "{giveCount, plural, one {Given} other {Given}} {giveCount, plural, one {book} other {books}} • Exchanged {exchangedCount}" + } +} \ No newline at end of file diff --git a/locales/en/search.json b/locales/en/search.json new file mode 100644 index 0000000..2d2c095 --- /dev/null +++ b/locales/en/search.json @@ -0,0 +1,20 @@ +{ + "fullFilter": { + "languages": { + "ru": "Русский", + "en": "English", + "fr": "Français" + }, + "titles": { + "author": "Author", + "genres": "Genres", + "year": "Year of publication", + "publishingHouse": "Publishing house", + "language": "Language", + "filter": "Filter", + "reset": "Reset", + "apply": "Apply" + }, + "placeholder": "Search" + } +} \ No newline at end of file diff --git a/locales/ru/chat.json b/locales/ru/chat.json index ce4ca34..13c09a0 100644 --- a/locales/ru/chat.json +++ b/locales/ru/chat.json @@ -1,3 +1,8 @@ { - "title": "Чаты" + "title": "Чаты", + "chat": { + "body": "Кому писать?", + "delete": "Удалить чат", + "book": "Книга " + } } \ No newline at end of file diff --git a/locales/ru/common.json b/locales/ru/common.json index 9e26dfe..b478010 100644 --- a/locales/ru/common.json +++ b/locales/ru/common.json @@ -1 +1,3 @@ -{} \ No newline at end of file +{ + "notFound": "404 страница не найдена" +} \ No newline at end of file diff --git a/locales/ru/createBook.json b/locales/ru/createBook.json new file mode 100644 index 0000000..a7cb8c4 --- /dev/null +++ b/locales/ru/createBook.json @@ -0,0 +1,25 @@ +{ + "title": { + "label": "Название", + "message": "Пожалуйста, введите название книги", + "placeholder": "Введите название книги" + }, + "author": { + "label": "Автор", + "message": "Пожалуйста, введите имя автора", + "placeholder": "Введите имя автора" + }, + "genre": { + "label": "Жанр", + "placeholder": "Введите жанр книги (необязательно)" + }, + "publishingHouse": { + "label": "Издательство", + "placeholder": "Введите издательство (необязательно)" + }, + "year": { + "label": "Год издания", + "placeholder": "Введите год издания (необязательно)" + }, + "save": "Сохранить" +} \ No newline at end of file diff --git a/locales/ru/header.json b/locales/ru/header.json new file mode 100644 index 0000000..8dbef8b --- /dev/null +++ b/locales/ru/header.json @@ -0,0 +1,13 @@ +{ + "nav": { + "titles": { + "main": "Главная", + "favourites": "Избранное", + "chats": "Чаты", + "createBook": "Новое объявление" + } + }, + "search": { + "placeholder": "Ищите фентези, детективы, романы" + } +} \ No newline at end of file diff --git a/locales/ru/home.json b/locales/ru/home.json new file mode 100644 index 0000000..34aaafe --- /dev/null +++ b/locales/ru/home.json @@ -0,0 +1,17 @@ +{ + "filters": { + "type": { + "exchange": "Обменивают", + "giveAway": "Отдают", + "allOptions": "Все варианты" + }, + "genre": { + "all": "Все", + "detectives": "Детективы", + "novels": "Романы", + "scientific": "Научные", + "horrors": "Ужасы", + "textbook": "Учебник" + } + } +} \ No newline at end of file diff --git a/locales/ru/profile.json b/locales/ru/profile.json new file mode 100644 index 0000000..cfbb113 --- /dev/null +++ b/locales/ru/profile.json @@ -0,0 +1,11 @@ +{ + "otherButtons": { + "write": "Написать" + }, + "ownButtons": { + "newAd": "Новое объявление" + }, + "info": { + "score": "{giveCount, plural, one {Отдана} few {Отдано} many {Отдано}} {giveCount, plural, one {книга} few {книги} many {книг}} • Обменяно {exchangedCount}" + } +} \ No newline at end of file diff --git a/locales/ru/search.json b/locales/ru/search.json new file mode 100644 index 0000000..b0a48e5 --- /dev/null +++ b/locales/ru/search.json @@ -0,0 +1,20 @@ +{ + "fullFilter": { + "languages": { + "ru": "Русский", + "en": "English", + "fr": "Français" + }, + "titles": { + "author": "Автор", + "genres": "Жанры", + "year": "Год издания", + "publishingHouse": "Издательство", + "language": "Язык", + "filter": "Фильтр", + "reset": "Сбросить", + "apply": "Применить" + }, + "placeholder": "Поиск" + } +} \ No newline at end of file diff --git a/src/components/Header/components/Nav.tsx b/src/components/Header/components/Nav.tsx index 9364b04..43c453d 100644 --- a/src/components/Header/components/Nav.tsx +++ b/src/components/Header/components/Nav.tsx @@ -1,19 +1,20 @@ import styles from "../header.module.scss"; import { NavLink } from "react-router"; +import { useTranslation } from "react-i18next"; interface MainMenuItem { title: string; url: string; } -const mainMenuItems: MainMenuItem[] = [ - { title: "Главная", url: "/" }, - { title: "Избранное", url: "/favourites" }, - { title: "Чаты", url: "/chats" }, - { title: "Новое объявление", url: "/createBook" }, -]; - export function Nav() { + const { t } = useTranslation("header"); + const mainMenuItems: MainMenuItem[] = [ + { title: `${t("nav.titles.main")}`, url: "/" }, + { title: `${t("nav.titles.favourites")}`, url: "/favourites" }, + { title: `${t("nav.titles.chats")}`, url: "/chats" }, + { title: `${t("nav.titles.createBook")}`, url: "/createBook" }, + ]; return (