mirror of
https://github.com/Steffo99/todocolors.git
synced 2024-11-22 08:14:18 +00:00
Rename useTranslation
to useServerTranslation
and useClientTranslation
for easier autocompletion
This commit is contained in:
parent
002473bf1a
commit
53478aaf27
9 changed files with 16 additions and 16 deletions
|
@ -20,7 +20,7 @@ async function init(lng: string, ns: string): Promise<i18n> {
|
|||
return instance
|
||||
}
|
||||
|
||||
export function useTranslation(lng: string, ns: string) {
|
||||
export function useClientTranslation(lng: string, ns: string) {
|
||||
const [instance, setInstance] = useState<i18n | undefined>(undefined);
|
||||
|
||||
useEffect(
|
||||
|
|
|
@ -18,7 +18,7 @@ async function init(lng: string, ns: string): Promise<i18n> {
|
|||
return instance
|
||||
}
|
||||
|
||||
export async function useTranslation(lng: string, ns: string) {
|
||||
export async function useServerTranslation(lng: string, ns: string) {
|
||||
const instance = await init(lng, ns)
|
||||
return {
|
||||
t: instance.getFixedT(lng, Array.isArray(ns) ? ns[0] : ns),
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {useTranslation} from "@/app/(i18n)/server"
|
||||
import {useServerTranslation} from "@/app/(i18n)/server"
|
||||
import {CreatePrivateBoardPanel} from "@/app/[lang]/(page)/CreatePrivateBoardPanel"
|
||||
import {CreatePublicBoardPanel} from "@/app/[lang]/(page)/CreatePublicBoardPanel"
|
||||
import {default as React} from "react"
|
||||
|
||||
|
||||
export async function CreateBoardChapter({lng}: {lng: string}) {
|
||||
const {t} = await useTranslation(lng, "root")
|
||||
const {t} = await useServerTranslation(lng, "root")
|
||||
|
||||
return (
|
||||
<div className={"chapter-2"}>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import {useTranslation} from "@/app/(i18n)/client"
|
||||
import {useClientTranslation} from "@/app/(i18n)/client"
|
||||
import {faLock} from "@fortawesome/free-solid-svg-icons"
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
||||
import classNames from "classnames"
|
||||
|
@ -8,7 +8,7 @@ import {useRouter} from "next/navigation"
|
|||
import {default as React, SyntheticEvent, useCallback, useEffect, useState} from "react"
|
||||
|
||||
export function CreatePrivateBoardPanel({lng}: {lng: string}) {
|
||||
const {t} = useTranslation(lng, "root")
|
||||
const {t} = useClientTranslation(lng, "root")
|
||||
const router = useRouter();
|
||||
const [canCreate, setCanCreate] = useState<boolean | null>(null);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import {useTranslation} from "@/app/(i18n)/client"
|
||||
import {useClientTranslation} from "@/app/(i18n)/client"
|
||||
import {useLowerKebabState} from "@/app/[lang]/useKebabState"
|
||||
import {faGlobe} from "@fortawesome/free-solid-svg-icons"
|
||||
import cn from "classnames"
|
||||
|
@ -10,7 +10,7 @@ import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
|||
|
||||
|
||||
export function CreatePublicBoardPanel({lng}: {lng: string}) {
|
||||
const {t} = useTranslation(lng, "root")
|
||||
const {t} = useClientTranslation(lng, "root")
|
||||
const [code, setCode] = useLowerKebabState("")
|
||||
const router = useRouter();
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {useTranslation} from "@/app/(i18n)/server"
|
||||
import {useServerTranslation} from "@/app/(i18n)/server"
|
||||
import {KnownBoardsPanel} from "@/app/[lang]/(page)/KnownBoardsPanel"
|
||||
import {StarredBoardsPanel} from "@/app/[lang]/(page)/StarredBoardsPanel"
|
||||
import {default as React} from "react"
|
||||
|
||||
|
||||
export async function ExistingBoardChapter({lng}: {lng: string}) {
|
||||
const {t} = await useTranslation(lng, "root")
|
||||
const {t} = await useServerTranslation(lng, "root")
|
||||
|
||||
return (
|
||||
<div className={"chapter-2"}>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import {useTranslation} from "@/app/(i18n)/client"
|
||||
import {useClientTranslation} from "@/app/(i18n)/client"
|
||||
import {useLowerKebabState} from "@/app/[lang]/useKebabState"
|
||||
import {faKey} from "@fortawesome/free-solid-svg-icons"
|
||||
import cn from "classnames"
|
||||
|
@ -10,7 +10,7 @@ import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
|||
|
||||
|
||||
export function KnownBoardsPanel({lng}: {lng: string}) {
|
||||
const {t} = useTranslation(lng, "root")
|
||||
const {t} = useClientTranslation(lng, "root")
|
||||
const [code, setCode] = useLowerKebabState("")
|
||||
const router = useRouter();
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import {useTranslation} from "@/app/(i18n)/server"
|
||||
import {useServerTranslation} from "@/app/(i18n)/server"
|
||||
import style from "./RootHeader.module.css"
|
||||
import {default as React} from "react"
|
||||
|
||||
|
||||
export async function RootHeader({lng}: {lng: string}) {
|
||||
const {t} = await useTranslation(lng, "root")
|
||||
const {t} = await useServerTranslation(lng, "root")
|
||||
|
||||
return (
|
||||
<header className={style.pageHeader}>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"use client";
|
||||
|
||||
import {useTranslation} from "@/app/(i18n)/client"
|
||||
import {useClientTranslation} from "@/app/(i18n)/client"
|
||||
import {useManagedStarred} from "@/app/[lang]/StarContext"
|
||||
import {faStar} from "@fortawesome/free-solid-svg-icons"
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
||||
|
@ -10,7 +10,7 @@ import {useEffect, useState} from "react"
|
|||
|
||||
|
||||
export function StarredBoardsPanel({lng}: {lng: string}) {
|
||||
const {t} = useTranslation(lng, "root")
|
||||
const {t} = useClientTranslation(lng, "root")
|
||||
const [isClient, setIsClient] = useState<true | null>(null);
|
||||
const {starred} = useManagedStarred()
|
||||
|
||||
|
|
Loading…
Reference in a new issue