Skip to content

Commit

Permalink
add locales
Browse files Browse the repository at this point in the history
  • Loading branch information
idoubi committed Apr 6, 2024
1 parent 4bcb62b commit 57e335e
Show file tree
Hide file tree
Showing 16 changed files with 261 additions and 78 deletions.
49 changes: 8 additions & 41 deletions app/[locale]/(default)/_components/header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,65 +1,30 @@
"use client";

import {
Bell,
CircleUser,
Home,
LineChart,
Menu,
Package,
Package2,
Search,
ShoppingCart,
Users,
} from "lucide-react";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";

import { AppContext } from "@/contexts/app";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import Link from "next/link";
import Locales from "../locales";
import { Nav } from "@/types/nav";
import { ReactNode } from "react";
import { Menu } from "lucide-react";
import Sidenav from "../sidenav";
import Sidepanel from "../sidepanel";
import Social from "../social";
import Theme from "../theme";
import User from "../user";
import { useContext } from "react";
import { usePathname } from "next/navigation";
import { useAppContext } from "@/contexts/app";

export default function () {
const { user } = useContext(AppContext);
const pathname = usePathname();
const navigations: Nav[] = [];
const { isSiderOpen, setIsSiderOpen } = useAppContext();

return (
<header className="flex h-16 left-0 right-0 fixed bg-base-100 z-50 items-center gap-4 border-b border-base-300 px-4 lg:h-[80px] lg:px-6">
<Sheet>
<Sheet open={isSiderOpen}>
<SheetTrigger asChild>
<Button
variant="outline"
size="icon"
className="bg-base-200 border-base-300 shrink-0 md:hidden"
>
<Menu className="h-5 w-5" />
<Menu className="h-5 w-5" onClick={() => setIsSiderOpen(true)} />
<span className="sr-only">Toggle navigation menu</span>
</Button>
</SheetTrigger>
Expand All @@ -74,7 +39,9 @@ export default function () {
<div className="mr-8">
<Link href="/" className="flex items-center gap-x-2 font-semibold">
<img src="/logo.png" className="w-16 h-16" />
<span className="hidden md:block text-3xl font-bold">Melodisco</span>
<span className="hidden md:block text-2xl font-medium">
Melodisco
</span>
</Link>
</div>
<div className="w-full flex-1">
Expand Down
10 changes: 6 additions & 4 deletions app/[locale]/(default)/_components/sidenav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { usePathname, useRouter } from "next/navigation";
import { Button } from "@/components/ui/button";
import { Nav } from "@/types/nav";
import { PiPlaylistDuotone } from "react-icons/pi";
import { Playlist } from "../../_data/playlists";
import { ScrollArea } from "@/components/ui/scroll-area";
import { cn } from "@/lib/utils";
import { useAppContext } from "@/contexts/app";
import { useTranslations } from "next-intl";

export default function () {
const t = useTranslations("nav");

const { setIsSiderOpen } = useAppContext();
const router = useRouter();
const pathname = usePathname();
const musicNavs: Nav[] = [
Expand Down Expand Up @@ -83,12 +83,13 @@ export default function () {
<Button
key={idx}
variant="ghost"
className={`w-full justify-start gap-x-1 ${
className={`md:w-full justify-start gap-x-1 ${
nav.active ? "bg-base-300 text-base-content" : ""
}`}
onClick={() => {
if (nav.url) {
router.push(nav.url);
setIsSiderOpen(false);
}
}}
>
Expand All @@ -113,6 +114,7 @@ export default function () {
onClick={() => {
if (nav.url) {
router.push(nav.url);
setIsSiderOpen(false);
}
}}
>
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/(default)/_components/song/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function ({ song }: { song: Song }) {
) : (
<Button
size="sm"
className="flex items-center gap-x-1 w-20"
className="flex items-center gap-x-1 w-20 truncate"
onClick={() => playSong(song)}
>
<MdOutlinePlayArrow className="text-2xl" />
Expand Down
1 change: 0 additions & 1 deletion app/[locale]/(default)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Header from "./_components/header";
import Link from "next/link";
import Player from "./_components/player";
import { ReactNode } from "react";
import Sidenav from "./_components/sidenav";
Expand Down
48 changes: 24 additions & 24 deletions components/ui/sheet.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"use client"
"use client";

import * as React from "react"
import * as SheetPrimitive from "@radix-ui/react-dialog"
import { cva, type VariantProps } from "class-variance-authority"
import { X } from "lucide-react"
import * as React from "react";
import * as SheetPrimitive from "@radix-ui/react-dialog";
import { cva, type VariantProps } from "class-variance-authority";
import { X } from "lucide-react";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

const Sheet = SheetPrimitive.Root
const Sheet = SheetPrimitive.Root;

const SheetTrigger = SheetPrimitive.Trigger
const SheetTrigger = SheetPrimitive.Trigger;

const SheetClose = SheetPrimitive.Close
const SheetClose = SheetPrimitive.Close;

const SheetPortal = SheetPrimitive.Portal
const SheetPortal = SheetPrimitive.Portal;

const SheetOverlay = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Overlay>,
Expand All @@ -27,8 +27,8 @@ const SheetOverlay = React.forwardRef<
{...props}
ref={ref}
/>
))
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
));
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;

const sheetVariants = cva(
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
Expand All @@ -47,7 +47,7 @@ const sheetVariants = cva(
side: "right",
},
}
)
);

interface SheetContentProps
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
Expand All @@ -71,8 +71,8 @@ const SheetContent = React.forwardRef<
</SheetPrimitive.Close>
</SheetPrimitive.Content>
</SheetPortal>
))
SheetContent.displayName = SheetPrimitive.Content.displayName
));
SheetContent.displayName = SheetPrimitive.Content.displayName;

const SheetHeader = ({
className,
Expand All @@ -85,8 +85,8 @@ const SheetHeader = ({
)}
{...props}
/>
)
SheetHeader.displayName = "SheetHeader"
);
SheetHeader.displayName = "SheetHeader";

const SheetFooter = ({
className,
Expand All @@ -99,8 +99,8 @@ const SheetFooter = ({
)}
{...props}
/>
)
SheetFooter.displayName = "SheetFooter"
);
SheetFooter.displayName = "SheetFooter";

const SheetTitle = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Title>,
Expand All @@ -111,8 +111,8 @@ const SheetTitle = React.forwardRef<
className={cn("text-lg font-semibold text-foreground", className)}
{...props}
/>
))
SheetTitle.displayName = SheetPrimitive.Title.displayName
));
SheetTitle.displayName = SheetPrimitive.Title.displayName;

const SheetDescription = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Description>,
Expand All @@ -123,8 +123,8 @@ const SheetDescription = React.forwardRef<
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
SheetDescription.displayName = SheetPrimitive.Description.displayName
));
SheetDescription.displayName = SheetPrimitive.Description.displayName;

export {
Sheet,
Expand All @@ -137,4 +137,4 @@ export {
SheetFooter,
SheetTitle,
SheetDescription,
}
};
2 changes: 2 additions & 0 deletions configs/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const locales = [
"ru",
"fr",
"de",
"ar",
];
export const localeNames: any = {
en: "🇺🇸 English",
Expand All @@ -22,6 +23,7 @@ export const localeNames: any = {
ru: "🇷🇺 Русский",
fr: "🇫🇷 Français",
de: "🇩🇪 Deutsch",
ar: "🇪🇬 اَلْعَرَبِيَّةُ",
};

export const defaultLocale = "en";
Expand Down
3 changes: 3 additions & 0 deletions contexts/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const AppContextProvider = ({ children }: ContextProviderProps) => {

const [theme, setTheme] = useState("light");
const [locale, setLocale] = useState("");
const [isSiderOpen, setIsSiderOpen] = useState(false);
const [user, setUser] = useState<User | null>(null);
const [playlist, setPlaylist] = useState<Song[]>([]);
const [currentSong, setCurrentSong] = useState<Song | null>(null);
Expand Down Expand Up @@ -54,6 +55,8 @@ export const AppContextProvider = ({ children }: ContextProviderProps) => {
setTheme,
locale,
setLocale,
isSiderOpen,
setIsSiderOpen,
user,
setUser,
playlist,
Expand Down
35 changes: 35 additions & 0 deletions messages/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"metadata": {
"title": "ميلوديسكو - مشغل موسيقى الذكاء الاصطناعي",
"description": "اكتشف عالم الموسيقى المسحور الذي يولده الذكاء الاصطناعي",
"detail": "بواسطة ميلوديسكو - مشغل موسيقى الذكاء الاصطناعي"
},
"brand": {
"name": "ميلوديسكو",
"tagline": "اكتشف عالم الموسيقى المسحور الذي يولده الذكاء الاصطناعي"
},
"user": {
"sign_in": "تسجيل الدخول",
"sign_out": "تسجيل الخروج",
"feedback": "التعليقات"
},
"nav": {
"music": "الموسيقى",
"library": "المكتبة",
"discover": "اكتشف",
"trending": "الشائع",
"newest": "الأحدث",
"roaming": "التجوال",
"recommended": "الموصى بها",
"playlists": "قوائم التشغيل",
"favorites": "المفضلة",
"recently": "مؤخراً"
},
"song": {
"title": "العنوان",
"tags": "الوسوم",
"duration": "المدة",
"lyrics": "الكلمات",
"play": "تشغيل"
}
}
35 changes: 35 additions & 0 deletions messages/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"metadata": {
"title": "Melodisco - AI Musikplayer",
"description": "Entdecken Sie die bezaubernde Welt der von KI generierten Musik",
"detail": "von Melodisco - AI Musikplayer"
},
"brand": {
"name": "Melodisco",
"tagline": "Entdecken Sie die bezaubernde Welt der von KI generierten Musik"
},
"user": {
"sign_in": "Anmelden",
"sign_out": "Abmelden",
"feedback": "Feedback"
},
"nav": {
"music": "Musik",
"library": "Bibliothek",
"discover": "Entdecken",
"trending": "Trends",
"newest": "Neueste",
"roaming": "Stöbern",
"recommended": "Empfohlen",
"playlists": "Playlists",
"favorites": "Favoriten",
"recently": "Kürzlich"
},
"song": {
"title": "Titel",
"tags": "Tags",
"duration": "Dauer",
"lyrics": "Texte",
"play": "Abspielen"
}
}
4 changes: 2 additions & 2 deletions messages/en.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"metadata": {
"title": "Melodisco - AI Music Community",
"title": "Melodisco - AI Music Player",
"description": "Discover the enchanting world of AI-generated music",
"detail": "by Melodisco - AI Music Community"
"detail": "by Melodisco - AI Music Player"
},
"brand": {
"name": "Melodisco",
Expand Down
35 changes: 35 additions & 0 deletions messages/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"metadata": {
"title": "Melodisco - Lecteur de Musique AI",
"description": "Découvrez le monde enchanteur de la musique générée par IA",
"detail": "par Melodisco - Lecteur de Musique AI"
},
"brand": {
"name": "Melodisco",
"tagline": "Découvrez le monde enchanteur de la musique générée par IA"
},
"user": {
"sign_in": "Se connecter",
"sign_out": "Se déconnecter",
"feedback": "Retour d'information"
},
"nav": {
"music": "Musique",
"library": "Bibliothèque",
"discover": "Découvrir",
"trending": "Tendance",
"newest": "Les plus récents",
"roaming": "Flâner",
"recommended": "Recommandé",
"playlists": "Playlists",
"favorites": "Favoris",
"recently": "Récemment"
},
"song": {
"title": "Titre",
"tags": "Tags",
"duration": "Durée",
"lyrics": "Paroles",
"play": "Lire"
}
}
Loading

0 comments on commit 57e335e

Please sign in to comment.