From 965777371715e1697678150b9215f9cd3f7394a5 Mon Sep 17 00:00:00 2001 From: bakhirev Date: Fri, 13 Oct 2023 17:30:21 +0300 Subject: [PATCH] JIRA-1234 feat(lang): test test test --- .../components/Notifications/store/index.ts | 3 +- src/ts/config/translations/ru.ts | 14 ++++++ .../PageWrapper/components/header/Button.tsx | 3 +- .../PageWrapper/components/header/Filters.tsx | 10 ++--- .../PageWrapper/components/header/index.tsx | 5 ++- .../PageWrapper/components/sidebar/Switch.tsx | 43 +++++++++++-------- .../PageWrapper/components/sidebar/index.tsx | 12 +++++- .../pages/Person/components/print/Total.tsx | 6 ++- src/ts/pages/Settings/store/Form.ts | 2 +- src/ts/pages/Team/components/Author.tsx | 4 +- 10 files changed, 67 insertions(+), 35 deletions(-) diff --git a/src/ts/components/Notifications/store/index.ts b/src/ts/components/Notifications/store/index.ts index 5b08cd6..78683ea 100644 --- a/src/ts/components/Notifications/store/index.ts +++ b/src/ts/components/Notifications/store/index.ts @@ -1,6 +1,7 @@ import { makeObservable, observable, action } from 'mobx'; import IMessage from '../interfaces/Message'; +import localization from "../../../helpers/Localization"; interface INotificationsStore { timer: any; @@ -31,7 +32,7 @@ class NotificationsStore implements INotificationsStore { show(message?: any) { this.messages.push({ id: NotificationsStore.getTime(), - title: message?.title || message || 'Изменения сохранены', + title: localization.get(message?.title || message || 'common.notifications.save'), description: message?.description || '', type: message?.type || 'success', }); diff --git a/src/ts/config/translations/ru.ts b/src/ts/config/translations/ru.ts index 393c48e..e0d234d 100644 --- a/src/ts/config/translations/ru.ts +++ b/src/ts/config/translations/ru.ts @@ -2,6 +2,17 @@ import localization from 'ts/helpers/Localization'; localization.parse('ru', ` § common.filters: Фильтры +§ common.notifications.save: Изменения сохранены +§ common.notifications.setting: Настройки сохранены +§ sidebar.switch.team: Команда +§ sidebar.switch.person: Сотрудник +§ sidebar.buttons.settings: Настройки +§ sidebar.buttons.print: Печать +§ sidebar.filters.all: всё время +§ sidebar.filters.year: год +§ sidebar.filters.halfYear: пол года +§ sidebar.filters.month: месяц +§ sidebar.filters.week: неделя § sidebar.team.total: Общая информация § sidebar.team.scope: Фичи § sidebar.team.author: Сотрудники @@ -42,6 +53,7 @@ localization.parse('ru', ` § page.team.author.commits: Коммитов § page.team.author.commitsSmall: коммитов § page.team.author.tasks: Задач +§ page.team.author.tasksSmall: задач § page.team.author.workedLosses: Дни с коммитами и без § page.team.author.worked: работа § page.team.author.losses: дни без коммитов @@ -124,6 +136,8 @@ localization.parse('ru', ` § page.team.week.hasNotCommits: небыло коммитов § page.team.week.days: дней § page.team.week.tasks: задач +§ page.person.print.photo.title: Фотография +§ page.person.print.photo.description: место для фотографии § page.person.total.title: Основные характеристики § page.person.total.daysWorked.title: дней работы § page.person.total.daysWorked.description: Учтены только дни, в которые делались коммиты diff --git a/src/ts/pages/PageWrapper/components/header/Button.tsx b/src/ts/pages/PageWrapper/components/header/Button.tsx index ce47481..28e5677 100644 --- a/src/ts/pages/PageWrapper/components/header/Button.tsx +++ b/src/ts/pages/PageWrapper/components/header/Button.tsx @@ -1,6 +1,7 @@ import React from 'react'; import settingsStore from 'ts/store/Settings'; +import localization from 'ts/helpers/Localization'; import style from '../../styles/filters.module.scss'; @@ -20,7 +21,7 @@ function Button({ settingsStore.setFilterByDateType(type); }} > - {title || ''} + {localization.get(title)} ); } diff --git a/src/ts/pages/PageWrapper/components/header/Filters.tsx b/src/ts/pages/PageWrapper/components/header/Filters.tsx index 862bfeb..0ec1beb 100644 --- a/src/ts/pages/PageWrapper/components/header/Filters.tsx +++ b/src/ts/pages/PageWrapper/components/header/Filters.tsx @@ -19,23 +19,23 @@ function Logo() { />
diff --git a/src/ts/pages/PageWrapper/components/header/index.tsx b/src/ts/pages/PageWrapper/components/header/index.tsx index 536c870..aa6e63b 100644 --- a/src/ts/pages/PageWrapper/components/header/index.tsx +++ b/src/ts/pages/PageWrapper/components/header/index.tsx @@ -9,6 +9,7 @@ import style from '../../styles/header.module.scss'; import Title from './Title'; import Filters from './Filters'; import printStore from '../../store/Print'; +import localization from "../../../../helpers/Localization"; const Header = observer((): React.ReactElement | null => { const navigate = useNavigate(); @@ -23,7 +24,7 @@ const Header = observer((): React.ReactElement | null => { <> { @@ -31,7 +32,7 @@ const Header = observer((): React.ReactElement | null => { }} /> { diff --git a/src/ts/pages/PageWrapper/components/sidebar/Switch.tsx b/src/ts/pages/PageWrapper/components/sidebar/Switch.tsx index d2dc320..58afcb8 100644 --- a/src/ts/pages/PageWrapper/components/sidebar/Switch.tsx +++ b/src/ts/pages/PageWrapper/components/sidebar/Switch.tsx @@ -1,5 +1,7 @@ import React from 'react'; +import localization from 'ts/helpers/Localization'; + import style from '../../styles/switch.module.scss'; interface ISwitchProps { @@ -13,25 +15,28 @@ function Switch({ options, onChange, }: ISwitchProps) { - const buttons = options.map((item: any) => ( -
{ - if (onChange) onChange(item?.id); - }} - > - {item?.title - - {item?.title || ''} - -
- )); + const buttons = options.map((item: any) => { + const title = localization.get(item?.title); + return ( +
{ + if (onChange) onChange(item?.id); + }} + > + {title + + {title || ''} + +
+ ); + }); return (
diff --git a/src/ts/pages/PageWrapper/components/sidebar/index.tsx b/src/ts/pages/PageWrapper/components/sidebar/index.tsx index a35fff9..7e25946 100644 --- a/src/ts/pages/PageWrapper/components/sidebar/index.tsx +++ b/src/ts/pages/PageWrapper/components/sidebar/index.tsx @@ -18,8 +18,16 @@ function SideBar() { { if (newType === type) return; diff --git a/src/ts/pages/Person/components/print/Total.tsx b/src/ts/pages/Person/components/print/Total.tsx index 6c3a5ce..b0d2a7f 100644 --- a/src/ts/pages/Person/components/print/Total.tsx +++ b/src/ts/pages/Person/components/print/Total.tsx @@ -8,6 +8,8 @@ import PageColumn from 'ts/components/Page/column'; import Title from 'ts/components/Title'; import dataGripStore from 'ts/store/DataGrip'; +import localization from 'ts/helpers/Localization'; + import style from '../../styles/print.module.scss'; const Total = observer((): React.ReactElement => { @@ -21,10 +23,10 @@ const Total = observer((): React.ReactElement => {
- место для фотографии + {localization.get('page.person.print.photo.description')}
diff --git a/src/ts/pages/Settings/store/Form.ts b/src/ts/pages/Settings/store/Form.ts index 4872cd9..64aa719 100644 --- a/src/ts/pages/Settings/store/Form.ts +++ b/src/ts/pages/Settings/store/Form.ts @@ -18,7 +18,7 @@ class FormStore extends Form { const { saveSettings } = settingsApi; return this.submit(saveSettings, body, false) .then((response: any) => { - notificationsStore.show('Настройки сохранены'); + notificationsStore.show('common.notifications.setting'); userSettings.loadUserSettings(); this.setInitState(this.state); return Promise.resolve(response); diff --git a/src/ts/pages/Team/components/Author.tsx b/src/ts/pages/Team/components/Author.tsx index 4fb5457..4f1f48d 100644 --- a/src/ts/pages/Team/components/Author.tsx +++ b/src/ts/pages/Team/components/Author.tsx @@ -36,8 +36,8 @@ function AuthorView({ response, updateSort }: IAuthorViewProps) { const textWork = localization.get('page.team.author.worked'); const textLosses = localization.get('page.team.author.losses'); - const daysWorked = getOptions({ order: [textWork, textLosses], suffix: 'дней' }); - const taskChart = getOptions({ max: getMaxByLength(response, 'tasks'), suffix: 'задач' }); + const daysWorked = getOptions({ order: [textWork, textLosses], suffix: 'page.team.author.days' }); + const taskChart = getOptions({ max: getMaxByLength(response, 'tasks'), suffix: 'page.team.author.tasksSmall' }); const commitsChart = getOptions({ max: getMax(response, 'commits') }); const typeChart = getOptions({ order: dataGripStore.dataGrip.type.list });