1
Fork 0
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:
Steffo 2023-08-08 16:30:02 +02:00
parent 002473bf1a
commit 53478aaf27
Signed by: steffo
GPG key ID: 2A24051445686895
9 changed files with 16 additions and 16 deletions

View file

@ -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(

View file

@ -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),

View file

@ -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"}>

View file

@ -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);

View file

@ -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();

View file

@ -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"}>

View file

@ -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();

View file

@ -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}>

View file

@ -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()