Skip to content

Commit

Permalink
easy
Browse files Browse the repository at this point in the history
  • Loading branch information
0-don committed May 19, 2024
1 parent a7ae958 commit f7f9b6e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"framer-motion": "^11.2.4",
"gql.tada": "^1.7.5",
"next": "14.2.3",
"next-intl": "3.13.0",
"next-intl": "3.14.0",
"next-themes": "^0.3.0",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand Down
5 changes: 4 additions & 1 deletion web/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export default function LocaleLayout({ children, params }: LocaleLayoutProps) {
md:w-2/5 lg:w-2/5 xl:w-3/5 2xl:w-3/5`}
/>

<NextIntlProvider tree={["Alerts", "Navbar"]}>
<NextIntlProvider tree={["Alerts"]}>
<Alerts />
</NextIntlProvider>

<NextIntlProvider tree={["Navbar"]}>
<Navbar />
</NextIntlProvider>
{children}
Expand Down
6 changes: 4 additions & 2 deletions web/src/components/NextIntlProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { LOCALES } from "@/middleware";
import { localePath } from "@/utils/constants";
import {
getMessageFallbackTranslation,
onErrorTranslation,
} from "@/utils/helpers/translationHelper";
import { NextIntlClientProvider, useLocale } from "next-intl";
import { NextIntlClientProvider } from "next-intl";
import { cookies } from "next/headers";

interface NextIntlProviderProps {
children: React.ReactNode;
Expand All @@ -14,7 +16,7 @@ export default async function NextIntlProvider({
children,
tree,
}: NextIntlProviderProps) {
const locale = useLocale();
const locale = cookies().get("NEXT_LOCALE")?.value || LOCALES[0];
const messages = await localePath(locale);
return (
<NextIntlClientProvider
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/container/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LanguageSwitch } from "@/components/utils/LanguageSwitch";
import { ThemeSwitch } from "@/components/utils/ThemeSwitch";
import { ME } from "@/documents/query/auth";
import { LOCALES } from "@/middleware";
import { prefetchQuery, ssrUrl } from "@/utils/helpers/serverComponentsUtil";
import { Link } from "@nextui-org/link";
import {
Expand All @@ -11,7 +12,7 @@ import {
} from "@nextui-org/navbar";
import logo_mini from "@public/images/logo_mini.svg";
import { HydrationBoundary } from "@tanstack/react-query";
import { useLocale } from "next-intl";
import { cookies } from "next/headers";
import Image from "next/image";
import React from "react";
import { MainMenu } from "./MainMenu";
Expand All @@ -21,7 +22,7 @@ interface NavbarProps {}

export const Navbar: React.FC<NavbarProps> = async ({}) => {
const { state } = await prefetchQuery([{ document: ME }]);
const locale = useLocale();
const locale = cookies().get("NEXT_LOCALE")?.value || LOCALES[0];
const pathname = ssrUrl().pathname;

const Items = (
Expand Down

0 comments on commit f7f9b6e

Please sign in to comment.