Skip to content

Commit 563a65b

Browse files
committed
migrate hooks and translations
1 parent 6d0030b commit 563a65b

File tree

127 files changed

+354
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+354
-292
lines changed

docs/best-practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Markdown will be translated as whole pages of content, so no specific action is
6666
- **Method two: `t()`**
6767

6868
```tsx
69-
import { useTranslation } from "next-i18next"
69+
import { useTranslation } from "@/hooks/useTranslation"
7070
7171
// Utilize anywhere in JS using
7272
const { t } = useTranslation()

src/components/AdoptionChart.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useTranslation } from "next-i18next"
21
import { useTheme } from "next-themes"
32

43
import type { ChildOnlyProp } from "@/lib/types"
@@ -7,6 +6,8 @@ import { cn } from "@/lib/utils/cn"
76

87
import { Flex } from "./ui/flex"
98

9+
import useTranslation from "@/hooks/useTranslation"
10+
1011
type CellProps = ChildOnlyProp & {
1112
color?: string
1213
className?: string

src/components/AssetDownload/AssetDownloadArtist.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { useTranslation } from "next-i18next"
2-
31
import Emoji from "@/components/Emoji"
42

53
import { cn } from "@/lib/utils/cn"
64

75
import { Flex } from "../ui/flex"
86
import { BaseLink } from "../ui/Link"
97

8+
import { useTranslation } from "@/hooks/useTranslation"
9+
1010
type AssetDownloadArtistProps = {
1111
artistName: string
1212
artistUrl?: string

src/components/AssetDownload/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { extname } from "path"
22

33
import { BaseHTMLAttributes } from "react"
44
import type { ImageProps, StaticImageData } from "next/image"
5-
import { useTranslation } from "next-i18next"
65

76
import AssetDownloadArtist from "@/components/AssetDownload/AssetDownloadArtist"
87
import AssetDownloadImage from "@/components/AssetDownload/AssetDownloadImage"
@@ -13,6 +12,8 @@ import { trackCustomEvent } from "@/lib/utils/matomo"
1312
import { ButtonLink } from "../ui/buttons/Button"
1413
import { Flex, Stack } from "../ui/flex"
1514

15+
import { useTranslation } from "@/hooks/useTranslation"
16+
1617
type AssetDownloadProps = {
1718
title: string
1819
alt: string

src/components/Banners/DismissableBanner/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useEffect, useState } from "react"
2-
import { useTranslation } from "next-i18next"
32
import { MdClose } from "react-icons/md"
43

54
import { Button } from "@/components/ui/buttons/Button"
@@ -9,6 +8,8 @@ import { cn } from "@/lib/utils/cn"
98

109
import BannerNotification from "../BannerNotification"
1110

11+
import { useTranslation } from "@/hooks/useTranslation"
12+
1213
type DismissableBannerProps = React.HTMLAttributes<HTMLDivElement> & {
1314
storageKey: string
1415
}

src/components/BigNumber/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { type ReactNode } from "react"
2-
import { useRouter } from "next/router"
3-
import { useTranslation } from "next-i18next"
2+
import { useLocale } from "next-intl"
43
import { MdInfoOutline } from "react-icons/md"
54

65
import { cn } from "@/lib/utils/cn"
@@ -9,6 +8,8 @@ import { isValidDate } from "@/lib/utils/date"
98
import Tooltip from "../Tooltip"
109
import Link from "../ui/Link"
1110

11+
import { useTranslation } from "@/hooks/useTranslation"
12+
1213
type BigNumberProps = {
1314
children: ReactNode
1415
value?: ReactNode
@@ -27,7 +28,7 @@ const BigNumber = ({
2728
className,
2829
}: BigNumberProps) => {
2930
const { t } = useTranslation("common")
30-
const { locale } = useRouter()
31+
const locale = useLocale()
3132
const lastUpdatedDisplay =
3233
lastUpdated && isValidDate(lastUpdated)
3334
? new Intl.DateTimeFormat(locale, {

src/components/Breadcrumbs/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Fragment } from "react"
2-
import { useRouter } from "next/router"
3-
import { useTranslation } from "next-i18next"
2+
import { useLocale } from "next-intl"
43

54
import type { Lang } from "@/lib/types"
65

@@ -16,6 +15,9 @@ import {
1615
BreadcrumbSeparator,
1716
} from "../ui/breadcrumb"
1817

18+
import { useTranslation } from "@/hooks/useTranslation"
19+
import { usePathname } from "@/i18n/routing"
20+
1921
export type BreadcrumbsProps = BreadcrumbProps & {
2022
slug: string
2123
startDepth?: number
@@ -41,10 +43,11 @@ type Crumb = {
4143
// ]
4244
const Breadcrumbs = ({ slug, startDepth = 0, ...props }: BreadcrumbsProps) => {
4345
const { t } = useTranslation("common")
44-
const { locale, asPath } = useRouter()
46+
const locale = useLocale()
47+
const pathname = usePathname()
4548
const dir = isLangRightToLeft(locale! as Lang) ? "rtl" : "ltr"
4649

47-
const hasHome = asPath !== "/"
50+
const hasHome = pathname !== "/"
4851
const slugChunk = slug.split("/")
4952
const sliced = slugChunk.filter((item) => !!item)
5053

src/components/BugBountyCards.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { BaseHTMLAttributes } from "react"
2-
import { useTranslation } from "next-i18next"
32

43
import type { ChildOnlyProp, TranslationKey } from "@/lib/types"
54

@@ -8,6 +7,8 @@ import { cn } from "@/lib/utils/cn"
87
import { ButtonLink, ButtonLinkProps } from "./ui/buttons/Button"
98
import { Center, Flex, Stack } from "./ui/flex"
109

10+
import { useTranslation } from "@/hooks/useTranslation"
11+
1112
type FlexProps = BaseHTMLAttributes<HTMLDivElement>
1213

1314
const CardRow = ({ children }: ChildOnlyProp) => (

src/components/Callout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { useTranslation } from "next-i18next"
2-
31
import type { TranslationKey } from "@/lib/types"
42

53
import Emoji from "@/components/Emoji"
64
import { type ImageProps, TwImage } from "@/components/Image"
75

86
import { cn } from "@/lib/utils/cn"
97

8+
import { useTranslation } from "@/hooks/useTranslation"
9+
1010
export type CalloutProps = {
1111
children?: React.ReactNode
1212
image?: ImageProps["src"]

src/components/CalloutBanner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { useTranslation } from "next-i18next"
2-
31
import type { TranslationKey } from "@/lib/types"
42

53
import { type ImageProps, TwImage } from "@/components/Image"
64

75
import { cn } from "@/lib/utils/cn"
86

7+
import { useTranslation } from "@/hooks/useTranslation"
8+
99
export type CalloutBannerProps = React.HTMLAttributes<HTMLDivElement> & {
1010
image: ImageProps["src"]
1111
imageWidth?: number

0 commit comments

Comments
 (0)