Skip to content

Commit

Permalink
feat: add i18n to gitness, basics
Browse files Browse the repository at this point in the history
  • Loading branch information
sans-harness committed Nov 26, 2024
1 parent ad8787e commit a81b482
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/gitness/src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ i18n.on('languageChanged', lng => {
console.log('languageChanged here', lng)
i18nextViewsInstance.i18nextViewsInstance.changeLanguage('fr')
})
i18n.changeLanguage('fr')
i18n.changeLanguage('en')
// i18nextViewsInstance.changeLanguage('fr')

export default i18n
4 changes: 3 additions & 1 deletion packages/ui/src/data/navbar-menu-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { MenuGroupType, MenuGroupTypes } from '@components/navbar/types'

import { i18nextViewsInstance } from '../i18n/i18n'

export const navbarMenuData: MenuGroupType[] = [
// import { t } from 'i18next'

export const getNavbarMenuData = (): MenuGroupType[] => [
{
groupId: 0,
title: i18nextViewsInstance.t('navbar.devops'),
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/data/pinned-menu-items-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NavbarItemType } from '@components/navbar/types'

import { i18nextViewsInstance } from '../i18n/i18n'

export const pinnedMenuItemsData: NavbarItemType[] = [
export const getPinnedMenuItemsData = (): NavbarItemType[] => [
{
id: 0,
iconName: 'repositories-gradient',
Expand Down
11 changes: 8 additions & 3 deletions packages/ui/src/views/layouts/SandboxRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'reac
import { Outlet, useLocation } from 'react-router-dom'

import { ManageNavigation, MoreSubmenu, Navbar, SettingsMenu } from '@/components'
import { navbarMenuData } from '@/data/navbar-menu-data'
import { pinnedMenuItemsData } from '@/data/pinned-menu-items-data'
import { getNavbarMenuData } from '@/data/navbar-menu-data'
import { getPinnedMenuItemsData } from '@/data/pinned-menu-items-data'
import { MenuGroupType, MenuGroupTypes, NavbarItemIdType, NavbarItemType } from '@components/navbar/types'

import { SandboxLayout } from '../index'
Expand All @@ -17,6 +17,8 @@ import type { TypesUser } from './types'
const getArrayOfNavItems = (data: NavbarItemIdType[]) => {
if (!data.length) return []

const navbarMenuData = getNavbarMenuData()

return navbarMenuData.reduce<NavbarItemType[]>((acc, { items }) => {
const currentIndex = items.findIndex(item => data.includes(item.id))

Expand Down Expand Up @@ -58,6 +60,8 @@ export const SandboxRoot = ({
const [showSettingMenu, setShowSettingMenu] = useState(false)
const [showCustomNav, setShowCustomNav] = useState(false)

const pinnedMenuItemsData = getPinnedMenuItemsData()

/**
* Update pinned manu
*/
Expand All @@ -81,6 +85,7 @@ export const SandboxRoot = ({
* Map mock data menu by type to Settings and More
*/
const { moreMenu, settingsMenu } = useMemo(() => {
const navbarMenuData = getNavbarMenuData()
return navbarMenuData.reduce<{
moreMenu: MenuGroupType[]
settingsMenu: MenuGroupType[]
Expand Down Expand Up @@ -220,7 +225,7 @@ export const SandboxRoot = ({
<ManageNavigation
pinnedItems={pinnedMenuItems}
recentItems={recentMenuItems}
navbarMenuData={navbarMenuData}
navbarMenuData={getNavbarMenuData()}
showManageNavigation={showCustomNav}
isSubmitting={false}
submitted={false}
Expand Down

0 comments on commit a81b482

Please sign in to comment.