Skip to content

Commit

Permalink
chore(AsideNavigation): add i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
artemmufazalov committed Oct 13, 2023
1 parent 7f1266d commit 2c72ff4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/containers/AsideNavigation/AsideNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {ASIDE_HEADER_COMPACT_KEY, TENANT_INITIAL_PAGE_KEY} from '../../utils/con
import {getTenantPath} from '../Tenant/TenantPages';
import {UserSettings} from '../UserSettings/UserSettings';

import i18n from './i18n';
import './AsideNavigation.scss';

const b = cn('kv-navigation');
Expand Down Expand Up @@ -58,15 +59,19 @@ function YbdInternalUser({ydbUser, logout}: YbdInternalUserProps) {
return (
<div className={b('internal-user')}>
<div className={b('user-info-wrapper')}>
<div className={b('ydb-internal-user-title')}>YDB user</div>
<div className={b('ydb-internal-user-title')}>{i18n('account.user')}</div>
{ydbUser && <div className={b('username')}>{ydbUser}</div>}
</div>
{ydbUser ? (
<Button view="flat-secondary" onClick={logout} title="logout">
<Button view="flat-secondary" title={i18n('account.logout')} onClick={logout}>
<Icon data={signOutIcon} size={16} />
</Button>
) : (
<Button view="flat-secondary" title="login" onClick={handleLoginClick}>
<Button
view="flat-secondary"
title={i18n('account.login')}
onClick={handleLoginClick}
>
<Icon data={signInIcon} size={16} />
</Button>
)}
Expand All @@ -91,7 +96,7 @@ function YdbUserDropdown({isCompact, popupAnchor, ydbUser}: YdbUserDropdownProps
compact={isCompact}
item={{
id: 'user-popup',
title: ydbUser?.login ?? 'Account',
title: ydbUser?.login ?? i18n('navigation-item.account'),
current: isUserDropdownVisible,
icon: iconData,
iconSize: 22,
Expand Down Expand Up @@ -142,7 +147,7 @@ export const useGetLeftNavigationItems = () => {
const items: MenuItem[] = [
{
id: TENANT_PAGES_IDS.query,
title: 'Query',
title: i18n('pages.query'),
icon: terminalIcon,
iconSize: 20,
location: getTenantPath({
Expand All @@ -152,7 +157,7 @@ export const useGetLeftNavigationItems = () => {
},
{
id: TENANT_PAGES_IDS.diagnostics,
title: 'Diagnostics',
title: i18n('pages.diagnostics'),
icon: pulseIcon,
iconSize: 20,
location: getTenantPath({
Expand Down Expand Up @@ -197,7 +202,7 @@ function AsideNavigation(props: AsideNavigationProps) {
<React.Fragment>
<AsideHeader
logo={{
text: 'YDB',
text: i18n('logo.title'),
icon: ydbLogoIcon,
onClick: () => history.push('/'),
}}
Expand All @@ -212,7 +217,7 @@ function AsideNavigation(props: AsideNavigationProps) {
compact={compact}
item={{
id: 'documentation',
title: 'Documentation',
title: i18n('navigation-item.documentation'),
icon: supportIcon,
iconSize: 24,
onItemClick: () => {
Expand All @@ -224,7 +229,7 @@ function AsideNavigation(props: AsideNavigationProps) {
<FooterItem
item={{
id: 'user-settings',
title: 'Settings',
title: i18n('navigation-item.settings'),
icon: settingsIcon,
iconSize: 24,
current: visiblePanel === Panel.UserSettings,
Expand Down
15 changes: 15 additions & 0 deletions src/containers/AsideNavigation/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"logo.title": "YDB",

"pages.query": "Query",
"pages.diagnostics": "Diagnostics",

"navigation-item.documentation": "Documentation",
"navigation-item.settings": "Settings",
"navigation-item.account": "Account",

"account.user": "YDB User",

"account.login": "Login",
"account.logout": "Logout"
}
11 changes: 11 additions & 0 deletions src/containers/AsideNavigation/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {i18n, Lang} from '../../../utils/i18n';

import en from './en.json';
import ru from './ru.json';

const COMPONENT = 'ydb-aside-navigation';

i18n.registerKeyset(Lang.En, COMPONENT, en);
i18n.registerKeyset(Lang.Ru, COMPONENT, ru);

export default i18n.keyset(COMPONENT);
15 changes: 15 additions & 0 deletions src/containers/AsideNavigation/i18n/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"logo.title": "YDB",

"pages.query": "Редактор запросов",
"pages.diagnostics": "Диагностика",

"navigation-item.documentation": "Документация",
"navigation-item.settings": "Настройки",
"navigation-item.account": "Аккаунт",

"account.user": "Пользователь YDB",

"account.login": "Войти",
"account.logout": "Выйти"
}

0 comments on commit 2c72ff4

Please sign in to comment.