@@ -28,13 +28,15 @@ import {
2828 UserAvatar ,
2929} from '@carbon/icons-react' ;
3030import { Link as RouterLink , useLocation } from 'react-router' ;
31+ import { useTranslation } from 'react-i18next' ;
3132import ProfilePanel from '../profilePanel/ProfilePanel' ;
3233
3334import { routesInHeader , routesInSideNav } from '../../routes/config' ;
3435import { NavHeaderItems } from './NavHeaderItems' ;
3536import { NavSideItems } from './NavSideItems' ;
3637
3738export const Nav = ( ) => {
39+ const { t } = useTranslation ( ) ;
3840 const location = useLocation ( ) ;
3941 const [ isSideNavExpanded , setIsSideNavExpanded ] = useState ( false ) ;
4042 const [ isProfileOpen , setIsProfileOpen ] = useState ( false ) ;
@@ -54,14 +56,18 @@ export const Nav = () => {
5456 < Header aria-label = "fed-at-ibm" >
5557 < SkipToContent />
5658 < HeaderMenuButton
57- aria-label = { isSideNavExpanded ? 'Close menu' : 'Open menu' }
59+ aria-label = {
60+ isSideNavExpanded
61+ ? t ( 'nav.menu.close' , 'Close menu' )
62+ : t ( 'nav.menu.open' , 'Open menu' )
63+ }
5864 onClick = { toggleNav }
5965 isCollapsible = { true }
6066 isActive = { isSideNavExpanded }
6167 aria-expanded = { isSideNavExpanded }
6268 />
6369 < HeaderName as = { RouterLink } to = "/" prefix = "Carbon" >
64- React starter template
70+ { t ( 'nav.header.name' , ' React starter template' ) }
6571 </ HeaderName >
6672 { routesInHeader . length > 0 && (
6773 < HeaderNavigation aria-label = "fed-at-ibm" >
@@ -72,17 +78,20 @@ export const Nav = () => {
7278 </ HeaderNavigation >
7379 ) }
7480 < HeaderGlobalBar >
75- < HeaderGlobalAction aria-label = " Search" >
81+ < HeaderGlobalAction aria-label = { t ( 'nav.actions.search' , ' Search' ) } >
7682 < Search size = { 20 } />
7783 </ HeaderGlobalAction >
7884 < HeaderGlobalAction
79- aria-label = " User profile"
85+ aria-label = { t ( 'nav.actions.userProfile' , ' User profile' ) }
8086 tooltipAlignment = "end"
8187 onClick = { handleProfileOpen }
8288 >
8389 < UserAvatar size = { 20 } />
8490 </ HeaderGlobalAction >
85- < HeaderGlobalAction aria-label = "App switcher" tooltipAlignment = "end" >
91+ < HeaderGlobalAction
92+ aria-label = { t ( 'nav.actions.appSwitcher' , 'App switcher' ) }
93+ tooltipAlignment = "end"
94+ >
8695 < SwitcherIcon size = { 20 } />
8796 </ HeaderGlobalAction >
8897 </ HeaderGlobalBar >
@@ -92,7 +101,7 @@ export const Nav = () => {
92101 </ HeaderPanel >
93102 </ Header >
94103 < SideNav
95- aria-label = " Side navigation"
104+ aria-label = { t ( 'nav.sideNav.ariaLabel' , ' Side navigation' ) }
96105 expanded = { isSideNavExpanded }
97106 isPersistent = { false }
98107 >
0 commit comments