Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 6ff3f48

Browse files
committed
build(1.0.0): update translations
1 parent fce1e71 commit 6ff3f48

11 files changed

Lines changed: 151 additions & 99 deletions

File tree

src/app/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#root {
2424
height: 100vh;
2525
width: 100%;
26-
padding: 2rem;
26+
padding: 1rem;
2727
}
2828

2929
body {

src/entities/game/ui/card/index.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useState } from 'react';
2+
import { useTranslation } from 'react-i18next';
23

34
import { Divider, Tag } from '@widgets';
45
import { deleteGameDocument, updateGameDocument } from '@shared';
@@ -23,6 +24,7 @@ const MENU_OPTIONS = [
2324
];
2425

2526
const GameCard: FC<GameProps> = ({ id, title, platform, img, status }) => {
27+
const { t } = useTranslation();
2628
const [showDeleteAlert, setShowAlert] = useState<boolean>(false);
2729

2830
const onAlertClick: MouseEventHandler<HTMLButtonElement> = (event) => {
@@ -71,22 +73,22 @@ const GameCard: FC<GameProps> = ({ id, title, platform, img, status }) => {
7173
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
7274
/>
7375
</svg>
74-
<span>Are you sure about that?</span>
76+
<span>{t('games-list.cardMenu.deleteAlertText')}</span>
7577
</div>
7678
<div className="flex-none">
7779
<button
7880
className="btn btn-sm btn-ghost"
7981
data-action="cancel"
8082
onClick={onAlertClick}
8183
>
82-
Cancel
84+
{t('games-list.cardMenu.cancelDelete')}
8385
</button>
8486
<button
8587
className="btn btn-sm btn-primary"
8688
data-action="submit"
8789
onClick={onAlertClick}
8890
>
89-
I really want to delete it
91+
{t('games-list.cardMenu.confirmDelete')}
9092
</button>
9193
</div>
9294
</div>
@@ -118,27 +120,29 @@ const GameCard: FC<GameProps> = ({ id, title, platform, img, status }) => {
118120
tabIndex={0}
119121
className="menu menu-compact dropdown-content mt-3 p-2 shadow w-52 bg-primary-content text-primary"
120122
>
121-
<Divider>Statuses</Divider>
123+
<Divider>{t('games-list.cardMenu.statuses')}</Divider>
122124
{MENU_OPTIONS.filter((option) => option.key !== status).map((option) => (
123125
<li
124126
key={option.key}
125127
data-key={option.key}
126128
onClick={onStatusChange}
127129
className="hover:bg-primary-focus hover:text-primary-content rounded-none bg-primary-content p-2"
128130
>
129-
{option.label}
131+
{t(`games-list.cardMenu.${option.key}`)}
130132
</li>
131133
))}
132-
<Divider>Actions</Divider>
134+
<Divider>{t('games-list.cardMenu.actions')}</Divider>
133135
<li>
134136
<button className="btn btn-warning" onClick={onDeleteClick}>
135-
Delete
137+
{t('games-list.cardMenu.delete')}
136138
</button>
137139
</li>
138140
</ul>
139141
</div>
140-
<h2 className="card-title">{title}</h2>
141-
<Tag platform={platform} />
142+
<div className="absolute left-4 bottom-6">
143+
<h2 className="card-title mb-2">{title}</h2>
144+
<Tag platform={platform} />
145+
</div>
142146
</div>
143147
</div>
144148
</>

src/pages/add-game/constants.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ const translateStatus = (
3737
cb: (value: string) => string
3838
) => {
3939
const withTranslation = { ...statusItem };
40-
withTranslation.label =
41-
withTranslation.value === 'in-progress'
42-
? cb('common.inProgress')
43-
: cb(`common.${withTranslation.value}`);
40+
withTranslation.label = cb(`common.${withTranslation.value}`);
4441
return withTranslation;
4542
};
4643

src/pages/add-game/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const AddGame = (): JSX.Element => {
112112
<input
113113
{...field}
114114
id="title"
115-
placeholder="Enter game title"
115+
placeholder={t('add-game.titlePlaceholder') ?? ''}
116116
autoComplete="off"
117117
value={inputValue}
118118
onChange={onInputChange}

src/shared/i18n/en.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{
2+
"themes": {
3+
"light": "light",
4+
"dark": "dark",
5+
"emerald": "emerald",
6+
"corporate": "corporate",
7+
"synthwave": "synthwave",
8+
"cyberpunk": "cyberpunk",
9+
"pastel": "pastel",
10+
"fantasy": "fantasy"
11+
},
212
"common": {
313
"backlog": "Backlog",
4-
"inProgress": "In Progress",
14+
"in-progress": "In Progress",
515
"completed": "Completed",
6-
"addGame": "Add Game"
16+
"addGame": "Add Game",
17+
"theme": "Theme"
718
},
819
"validation": {
920
"gameTitle": "Please input game title!",
@@ -43,7 +54,8 @@
4354
"title": "Game title",
4455
"platform": "Platform",
4556
"status": "Status"
46-
}
57+
},
58+
"titlePlaceholder": "Enter game title"
4759
},
4860
"games-list": {
4961
"motto": "There are no games",
@@ -72,6 +84,17 @@
7284
"hours_few": "{{count}} hours",
7385
"hours_many": "{{count}} hours"
7486
}
87+
},
88+
"cardMenu": {
89+
"statuses": "Statuses",
90+
"toBacklog": "To Backlog",
91+
"in-progress": "Start",
92+
"completed": "Complete",
93+
"actions": "Actions",
94+
"delete": "Delete",
95+
"deleteAlertText": "Are you sure about that?",
96+
"cancelDelete": "Cancel",
97+
"confirmDelete": "Delete"
7598
}
7699
},
77100
"auth": {

src/shared/i18n/ru.json

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
{
2+
"themes": {
3+
"light": "Светлая",
4+
"dark": "Темная",
5+
"emerald": "Изумруд",
6+
"corporate": "Корпо",
7+
"synthwave": "Синтвейв",
8+
"cyberpunk": "Киберпанк",
9+
"pastel": "Пастель",
10+
"fantasy": "Фентези"
11+
},
212
"common": {
313
"backlog": "Бэклог",
4-
"inProgress": "В процессе",
14+
"in-progress": "В процессе",
515
"completed": "Пройдено",
6-
"addGame": "Добавить игру"
16+
"addGame": "Добавить игру",
17+
"theme": "Тема"
718
},
819
"validation": {
920
"gameTitle": "Пожалуйста, введите название игры",
@@ -43,7 +54,8 @@
4354
"title": "Название игры",
4455
"platform": "Платформа",
4556
"status": "Статус"
46-
}
57+
},
58+
"titlePlaceholder": "Введите название игры"
4759
},
4860
"games-list": {
4961
"motto": "Игр не найдено",
@@ -72,6 +84,17 @@
7284
"hours_few": "{{count}} ч",
7385
"hours_many": "{{count}} ч"
7486
}
87+
},
88+
"cardMenu": {
89+
"statuses": "Статусы",
90+
"backlog": "В бэклог",
91+
"in-progress": "Начать",
92+
"completed": "Пройдено",
93+
"actions": "Действия",
94+
"delete": "Удалить",
95+
"deleteAlertText": "Вы уверены?",
96+
"cancelDelete": "Отмена",
97+
"confirmDelete": "Удалить"
7598
}
7699
},
77100
"auth": {

src/widgets/header/index.tsx

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useEffect } from 'react';
2-
import { Link } from 'react-router-dom';
32
import { useTranslation } from 'react-i18next';
43
import { useSignOut } from 'react-firebase-hooks/auth';
54
import { useStore } from '@nanostores/react';
65

76
import { User } from '@entities';
87
import { DropdownWidget } from '@widgets';
9-
import { getLanguageLabel, firebaseAuth } from '@shared';
8+
import { getLanguageLabel, firebaseAuth, capitalize } from '@shared';
109
import { nanoLogout, nanoUser } from 'entities/user/slice/index';
10+
import { Navbar } from './navbar';
1111

1212
const LanguageItems = [
1313
{
@@ -31,9 +31,9 @@ const themes = [
3131
'fantasy',
3232
];
3333

34-
const createThemeOptions = (): { key: string; label: string }[] => {
34+
const createThemeOptions = (translateCb: (key: string) => string): { key: string; label: string }[] => {
3535
const themesOptions: { key: string; label: string }[] = [];
36-
themes.map((theme) => themesOptions.push({ key: theme, label: theme }));
36+
themes.map((theme) => themesOptions.push({ key: theme, label: capitalize(translateCb(`themes.${theme}`)) }));
3737
return themesOptions;
3838
};
3939

@@ -70,59 +70,15 @@ const Header = (): JSX.Element => {
7070

7171
return (
7272
<header className="flex justify-between mb-6">
73-
<nav className="navbar flex items-center">
74-
<div className="navbar-start">
75-
<div className="dropdown">
76-
<label tabIndex={0} className="btn btn-ghost">
77-
<svg
78-
xmlns="http://www.w3.org/2000/svg"
79-
className="h-5 w-5"
80-
fill="none"
81-
viewBox="0 0 24 24"
82-
stroke="currentColor"
83-
>
84-
<path
85-
strokeLinecap="round"
86-
strokeLinejoin="round"
87-
strokeWidth="2"
88-
d="M4 6h16M4 12h8m-8 6h16"
89-
/>
90-
</svg>
91-
</label>
92-
<ul
93-
tabIndex={0}
94-
className="menu menu-compact dropdown-content mt-3 p-2 shadow rounded-box w-52 bg-primary-content text-primary"
95-
>
96-
<li className="hover:bg-primary-focus hover:text-primary-content rounded-none">
97-
<Link to="/">
98-
Backlog App
99-
</Link>
100-
</li>
101-
{user.authorized ? (
102-
<li className="hover:bg-primary-focus hover:text-primary-content rounded-none">
103-
<Link to="/list">
104-
{t('home.header.navigation.games')}
105-
</Link>
106-
</li>
107-
) : (
108-
<li className="hover:bg-primary-focus hover:text-primary-content rounded-none">
109-
<Link to="/auth">
110-
{t('home.header.navigation.login')}
111-
</Link>
112-
</li>
113-
)}
114-
</ul>
115-
</div>
116-
</div>
117-
</nav>
73+
<Navbar authorized={user.authorized} />
11874
<div className="flex">
11975
{user.authorized ? <User {...user} onLogout={onLogout} /> : null}
12076
<DropdownWidget
12177
label={getLanguageLabel(i18n.language)}
12278
items={LanguageItems}
12379
onClick={onLanguageSelect}
12480
/>
125-
<DropdownWidget label="Theme" items={createThemeOptions()} onClick={onThemeChange} />
81+
<DropdownWidget label={t('common.theme')} items={createThemeOptions(t)} onClick={onThemeChange} />
12682
</div>
12783
</header>
12884
);

src/widgets/header/navbar.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { useTranslation } from 'react-i18next';
2+
import { Link } from 'react-router-dom';
3+
4+
import type { FC } from 'react';
5+
6+
const Navbar: FC<{ authorized: boolean }> = ({ authorized }) => {
7+
const { t } = useTranslation();
8+
return (
9+
<nav className="navbar flex items-center">
10+
<div className="navbar-start">
11+
<div className="dropdown">
12+
<label tabIndex={0} className="btn btn-ghost">
13+
<svg
14+
xmlns="http://www.w3.org/2000/svg"
15+
className="h-5 w-5"
16+
fill="none"
17+
viewBox="0 0 24 24"
18+
stroke="currentColor"
19+
>
20+
<path
21+
strokeLinecap="round"
22+
strokeLinejoin="round"
23+
strokeWidth="2"
24+
d="M4 6h16M4 12h8m-8 6h16"
25+
/>
26+
</svg>
27+
</label>
28+
<ul
29+
tabIndex={0}
30+
className="menu menu-compact dropdown-content mt-3 p-2 shadow rounded-box w-52 bg-primary-content text-primary"
31+
>
32+
<li className="hover:bg-primary-focus hover:text-primary-content rounded-none">
33+
<Link to="/">Backlog App</Link>
34+
</li>
35+
{authorized ? (
36+
<li className="hover:bg-primary-focus hover:text-primary-content rounded-none">
37+
<Link to="/list">{t('home.header.navigation.games')}</Link>
38+
</li>
39+
) : (
40+
<li className="hover:bg-primary-focus hover:text-primary-content rounded-none">
41+
<Link to="/auth">{t('home.header.navigation.login')}</Link>
42+
</li>
43+
)}
44+
</ul>
45+
</div>
46+
</div>
47+
</nav>
48+
);
49+
};
50+
51+
export { Navbar };

0 commit comments

Comments
 (0)