Skip to content

Commit

Permalink
Merge pull request #27 from ShareBookCode/locales
Browse files Browse the repository at this point in the history
added json files and corrected text in files
  • Loading branch information
NookieGrey authored Feb 19, 2025
2 parents ddacafa + 16fc089 commit 9c141ad
Show file tree
Hide file tree
Showing 30 changed files with 328 additions and 98 deletions.
4 changes: 2 additions & 2 deletions i18n.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ export function createI18nInstance() {
.use(LanguageDetector)
.init({
fallbackLng: "en",
ns: ["common", "auth", "chat"],
ns: ["common", "auth", "chat", "home", "header", "search", "profile", "createBook"],
defaultNS: "common",
pluralSeparator: '_',
backend: {
loadPath: __dirname + "/locales/{{lng}}/{{ns}}.json",
},
Expand All @@ -27,6 +28,5 @@ export function createI18nInstance() {
caches: ["cookie"],
},
});

return instance;
}
7 changes: 6 additions & 1 deletion locales/en/chat.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"title": "Chats"
"title": "Chats",
"chat": {
"body": "Who do you want to contact?",
"delete": "Delete chat",
"book": "Book "
}
}
4 changes: 3 additions & 1 deletion locales/en/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"notFound": "404 page not found"
}
25 changes: 25 additions & 0 deletions locales/en/createBook.json
Original file line number Diff line number Diff line change
@@ -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"
}
13 changes: 13 additions & 0 deletions locales/en/header.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"nav": {
"titles": {
"main": "Home",
"favourites": "Favourites",
"chats": "Chats",
"createBook": "Create a book"
}
},
"search": {
"placeholder": "Search for fantasy, detective, novels"
}
}
17 changes: 17 additions & 0 deletions locales/en/home.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
13 changes: 13 additions & 0 deletions locales/en/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"otherButtons": {
"write": "Send a message"
},
"ownButtons": {
"newAd": "Create a book"
},
"score": {
"scoreGiven_one": "Given {{count}} book",
"scoreGiven_other": "Given {{count}} books",
"scoreExchange": "Exchanged {{exchangedCount}}"
}
}
24 changes: 24 additions & 0 deletions locales/en/search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"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"
},
"booksFound": {
"book_one": "{{count}} book finded",
"book_other": "{{count}} books finded"
}
}
7 changes: 6 additions & 1 deletion locales/ru/chat.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"title": "Чаты"
"title": "Чаты",
"chat": {
"body": "Кому писать?",
"delete": "Удалить чат",
"book": "Книга "
}
}
4 changes: 3 additions & 1 deletion locales/ru/common.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"notFound": "404 страница не найдена"
}
25 changes: 25 additions & 0 deletions locales/ru/createBook.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"title": {
"label": "Название",
"message": "Пожалуйста, введите название книги",
"placeholder": "Введите название книги"
},
"author": {
"label": "Автор",
"message": "Пожалуйста, введите имя автора",
"placeholder": "Введите имя автора"
},
"genre": {
"label": "Жанр",
"placeholder": "Введите жанр книги (необязательно)"
},
"publishingHouse": {
"label": "Издательство",
"placeholder": "Введите издательство (необязательно)"
},
"year": {
"label": "Год издания",
"placeholder": "Введите год издания (необязательно)"
},
"save": "Сохранить"
}
13 changes: 13 additions & 0 deletions locales/ru/header.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"nav": {
"titles": {
"main": "Главная",
"favourites": "Избранное",
"chats": "Чаты",
"createBook": "Новое объявление"
}
},
"search": {
"placeholder": "Ищите фентези, детективы, романы"
}
}
17 changes: 17 additions & 0 deletions locales/ru/home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"filters": {
"type": {
"exchange": "Обменивают",
"giveAway": "Отдают",
"allOptions": "Все варианты"
},
"genre": {
"all": "Все",
"detectives": "Детективы",
"novels": "Романы",
"scientific": "Научные",
"horrors": "Ужасы",
"textbook": "Учебник"
}
}
}
14 changes: 14 additions & 0 deletions locales/ru/profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"otherButtons": {
"write": "Написать"
},
"ownButtons": {
"newAd": "Новое объявление"
},
"score": {
"scoreGiven_one": "Отдана {{count}} книга",
"scoreGiven_few": "Отдано {{count}} книги",
"scoreGiven_many": "Отдано {{count}} книг",
"scoreExchange": "Обменяно {{exchangedCount}}"
}
}
25 changes: 25 additions & 0 deletions locales/ru/search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"fullFilter": {
"languages": {
"ru": "Русский",
"en": "English",
"fr": "Français"
},
"titles": {
"author": "Автор",
"genres": "Жанры",
"year": "Год издания",
"publishingHouse": "Издательство",
"language": "Язык",
"filter": "Фильтр",
"reset": "Сбросить",
"apply": "Применить"
},
"placeholder": "Поиск"
},
"booksFound": {
"book_one": "{{count}} книга найдена",
"book_few": "{{count}} книги найдено",
"book_many": "{{count}} книг найдено"
}
}
7 changes: 3 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions src/components/Header/Nav/Nav.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<nav>
<ul className={styles.navBar}>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Header/SearchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { Form, Input } from "antd";
import { SvgSearch } from "../svg/SvgSearch.tsx";
import { useState } from "react";
import { useNavigate } from "react-router";
import { useTranslation } from "react-i18next";

export function SearchInput() {
const [focusSearch, setFocusSearch] = useState(false);
const navigate = useNavigate();
const { t } = useTranslation("header");

return (
<Form
Expand All @@ -20,7 +22,7 @@ export function SearchInput() {
<Form.Item name="title">
<div className={styles.miniContainerSearch}>
<Input
placeholder="Ищите фентези, детективы, романы"
placeholder={t("search.placeholder")}
onFocus={() => setFocusSearch(true)}
onBlur={() => setFocusSearch(false)}
className={styles.search}
Expand Down
12 changes: 11 additions & 1 deletion src/entry-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ i18next
.use(LanguageDetector)
.init(
{
ns: ["common", "auth", "chat"],
ns: [
"common",
"auth",
"chat",
"home",
"header",
"search",
"profile",
"createBook",
],
defaultNS: "common",
fallbackLng: window.initialLanguage,
react: {
Expand All @@ -22,6 +31,7 @@ i18next
detection: {
caches: ["cookie"],
},
pluralSeparator: "_",
},
() => {
const preloadedState = window.__PRELOADED_STATE__ || {};
Expand Down
5 changes: 4 additions & 1 deletion src/pages/chat/body/ChatBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import styles from "./chatBody.module.scss";
import { useAppSelector } from "../../../store.ts";
import { useGetCorrespondenceQuery } from "../../../services/api/sharebookApi.ts";
import { ChatMessage } from "../chatMessage";
import { useTranslation } from "react-i18next";

export function ChatBody() {
const activeChatId = useAppSelector((state) => state.chat.activeId);

const { t } = useTranslation("chat");

const response = useGetCorrespondenceQuery({
firstUserId: "6",
secondUserId: "4",
zone: 4,
});

if (!activeChatId) return <div className={styles.centered}>Кому писать?</div>;
if (!activeChatId) return <div className={styles.centered}>{t("chat.body")}</div>;

return (
<div className={styles.scroll}>
Expand Down
Loading

0 comments on commit 9c141ad

Please sign in to comment.