Skip to content

Commit 9da6a9d

Browse files
refactor(Tablet): use i18n
1 parent 5472288 commit 9da6a9d

File tree

5 files changed

+42
-8
lines changed

5 files changed

+42
-8
lines changed

src/containers/Tablet/Tablet.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {TabletTable} from './TabletTable';
1919
import {TabletInfo} from './TabletInfo';
2020
import {TabletControls} from './TabletControls';
2121

22+
import i18n from './i18n';
23+
2224
import './Tablet.scss';
2325

2426
export const b = cn('tablet-page');
@@ -69,7 +71,7 @@ export const Tablet = () => {
6971
if (!tablet || !Object.keys(tablet).length) {
7072
return (
7173
<div className={b('placeholder')}>
72-
<EmptyState title="The tablet was not found" />
74+
<EmptyState title={i18n('emptyState')} />
7375
</div>
7476
);
7577
}
@@ -89,7 +91,7 @@ export const Tablet = () => {
8991
<div className={b('left-pane')}>
9092
<ul className={b('links')}>{externalLinks.map(renderExternalLinks)}</ul>
9193
<div className={b('row', {header: true})}>
92-
<span className={b('title')}>Tablet</span>
94+
<span className={b('title')}>{i18n('tablet.header')}</span>
9395
<EntityStatus status={Overall} name={TabletId} />
9496
<a
9597
rel="noopener noreferrer"

src/containers/Tablet/TabletControls/TabletControls.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Button} from '@gravity-ui/uikit';
44
import {ETabletState, TTabletStateInfo} from '../../../types/api/tablet';
55
import {CriticalActionDialog} from '../../../components/CriticalActionDialog';
66

7+
import i18n from '../i18n';
78
import {b} from '../Tablet';
89

910
enum EVisibleDialogType {
@@ -91,7 +92,7 @@ export const TabletControls = ({tablet}: TabletControlsProps) => {
9192
return (
9293
<CriticalActionDialog
9394
visible={isDialogVisible}
94-
text="The tablet will be restarted. Do you want to proceed?"
95+
text={i18n('dialog.kill')}
9596
onClose={hideDialog}
9697
onConfirm={_onKillClick}
9798
/>
@@ -101,7 +102,7 @@ export const TabletControls = ({tablet}: TabletControlsProps) => {
101102
return (
102103
<CriticalActionDialog
103104
visible={isDialogVisible}
104-
text="The tablet will be stopped. Do you want to proceed?"
105+
text={i18n('dialog.stop')}
105106
onClose={hideDialog}
106107
onConfirm={_onStopClick}
107108
/>
@@ -111,7 +112,7 @@ export const TabletControls = ({tablet}: TabletControlsProps) => {
111112
return (
112113
<CriticalActionDialog
113114
visible={isDialogVisible}
114-
text="The tablet will be resumed. Do you want to proceed?"
115+
text={i18n('dialog.resume')}
115116
onClose={hideDialog}
116117
onConfirm={_onResumeClick}
117118
/>
@@ -130,7 +131,7 @@ export const TabletControls = ({tablet}: TabletControlsProps) => {
130131
disabled={isDisabledKill()}
131132
className={b('control')}
132133
>
133-
Restart
134+
{i18n('controls.kill')}
134135
</Button>
135136
{hasHiveId() ? (
136137
<>
@@ -140,15 +141,15 @@ export const TabletControls = ({tablet}: TabletControlsProps) => {
140141
disabled={isDisabledStop()}
141142
className={b('control')}
142143
>
143-
Stop
144+
{i18n('controls.stop')}
144145
</Button>
145146
<Button
146147
onClick={showResumeDialog}
147148
view="action"
148149
disabled={isDisabledResume()}
149150
className={b('control')}
150151
>
151-
Resume
152+
{i18n('controls.resume')}
152153
</Button>
153154
</>
154155
) : null}

src/containers/Tablet/i18n/en.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tablet.header": "Tablet",
3+
"controls.kill": "Restart",
4+
"controls.stop": "Stop",
5+
"controls.resume": "Resume",
6+
"dialog.kill": "The tablet will be restarted. Do you want to proceed?",
7+
"dialog.stop": "The tablet will be stopped. Do you want to proceed?",
8+
"dialog.resume": "The tablet will be resumed. Do you want to proceed?",
9+
"emptyState": "The tablet was not found"
10+
}

src/containers/Tablet/i18n/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {i18n, Lang} from '../../../utils/i18n';
2+
3+
import en from './en.json';
4+
import ru from './ru.json';
5+
6+
const COMPONENT = 'ydb-tablet-page';
7+
8+
i18n.registerKeyset(Lang.En, COMPONENT, en);
9+
i18n.registerKeyset(Lang.Ru, COMPONENT, ru);
10+
11+
export default i18n.keyset(COMPONENT);

src/containers/Tablet/i18n/ru.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tablet.header": "Таблетка",
3+
"controls.kill": "Перезапустить",
4+
"controls.stop": "Остановить",
5+
"controls.resume": "Запустить",
6+
"dialog.kill": "Таблетка будет перезапущена. Вы хотите продолжить?",
7+
"dialog.stop": "Таблетка будет остановлена. Вы хотите продолжить?",
8+
"dialog.resume": "Таблетка будет запущена. Вы хотите продолжить?",
9+
"emptyState": "Таблетка не найдена"
10+
}

0 commit comments

Comments
 (0)