Add path based i18n

This commit is contained in:
Zoe Roux 2022-09-24 16:06:35 +09:00
parent a776278caf
commit ca41ddb271
8 changed files with 78 additions and 50 deletions

View File

@ -2,6 +2,7 @@
"extends": ["next/core-web-vitals", "prettier"],
"plugins": ["header"],
"rules": {
"@next/next/no-img-element": "off",
"header/header": [
"error",
"block",

View File

@ -13,6 +13,7 @@
},
"browse": {
"sortby": "Sort by {{key}}",
"sortby-tt": "Sort by",
"sortkey": {
"name": "Name",
"startAir": "Start air",
@ -21,6 +22,12 @@
"sortord": {
"asc": "asc",
"desc": "decs"
}
},
"switchToGrid": "Switch to grid view",
"switchToList": "Switch to list view"
},
"misc": {
"prev-page": "Previous page",
"next-page": "Next page"
}
}

View File

@ -8,11 +8,12 @@
"staff": "Staff",
"staff-none": "Aucun membre du staff connu",
"noOverview": "Aucune description disponible",
"episode-none": "Il n'y a pas d'episodes dans cette saison",
"episode-none": "Il n'y a pas d'épisodes dans cette saison",
"episodeNoMetadata": "Aucune metadonnée disponible"
},
"browse": {
"sortby": "Trier par {{key}}",
"sortby-tt": "Trier par",
"sortkey": {
"name": "Nom",
"startAir": "Date de sortie",
@ -21,6 +22,12 @@
"sortord": {
"asc": "asc",
"desc": "decs"
}
},
"switchToGrid": "Passer en vue grille",
"switchToList": "Passer en vue liste"
},
"misc": {
"prev-page": "Page précédente",
"next-page": "Page suivante"
}
}

View File

@ -34,6 +34,10 @@ const nextConfig = {
},
];
},
i18n: {
locales: ["en", "fr"],
defaultLocale: "en",
},
};
if (process.env.NODE_ENV !== "production") {

View File

@ -19,11 +19,13 @@
*/
import { ArrowLeft, ArrowRight } from "@mui/icons-material";
import { Box, IconButton, Typography } from "@mui/material";
import { Box, IconButton, Tooltip, Typography } from "@mui/material";
import { ReactNode, useRef } from "react";
import { Container } from "./container";
import useTranslation from "next-translate/useTranslation";
export const HorizontalList = ({ title, noContent, children }: { title: string, noContent: string, children: ReactNode[] }) => {
const { t } = useTranslation("browse");
const ref = useRef<HTMLDivElement>(null);
const getScrollSize = () => {
const childSize = ref.current?.children[0].clientWidth;
@ -39,38 +41,42 @@ export const HorizontalList = ({ title, noContent, children }: { title: string,
<>
<Container
sx={{ display: "flex", flexDirection: "row", justifyContent: "space-between", py: 3 }}
>
>
<Typography variant="h4" component="h2">
{title}
</Typography>
<Box>
<IconButton onClick={() => ref.current?.scrollBy({ left: -getScrollSize(), behavior: "smooth" })}>
<ArrowLeft />
</IconButton>
<IconButton onClick={() => ref.current?.scrollBy({ left: getScrollSize(), behavior: "smooth" })}>
<ArrowRight />
</IconButton>
<Tooltip title={t("misc.prev-page")}>
<IconButton aria-label={t("misc.prev-page")} onClick={() => ref.current?.scrollBy({ left: -getScrollSize(), behavior: "smooth" })}>
<ArrowLeft />
</IconButton>
</Tooltip>
<Tooltip title={t("misc.next-page")}>
<IconButton aria-label={t("misc.next-page")} onClick={() => ref.current?.scrollBy({ left: getScrollSize(), behavior: "smooth" })}>
<ArrowRight />
</IconButton>
</Tooltip>
</Box>
</Container>
{children.length == 0 ? (
<Box sx={{ display: "flex", justifyContent: "center" }}>
<Typography sx={{ py: 3 }}>{noContent}</Typography>
</Box>
) : (
<Container
sx={{
display: "flex",
flexDirection: "row",
maxWidth: "100%",
overflowY: "auto",
pt: 1,
pb: 2,
overflowX: "visible",
}}
ref={ref}
>
) : (
<Container
sx={{
display: "flex",
flexDirection: "row",
maxWidth: "100%",
overflowY: "auto",
pt: 1,
pb: 2,
overflowX: "visible",
}}
ref={ref}
>
{children}
</Container>
</Container>
)}
</>
);

View File

@ -32,7 +32,6 @@ import {
AppBarProps,
} from "@mui/material";
import MenuIcon from "@mui/icons-material/Menu";
/* import logo from "../public/icons/icon.svg"; */
import useTranslation from "next-translate/useTranslation";
import Image from "next/image";
import { ButtonLink } from "~/utils/link";
@ -55,7 +54,7 @@ const KyooTitle = (props: { sx: SxProps<Theme> }) => {
}}
href="/"
>
<Image src={"/icon.svg"} width={24} height={24} alt="" />
<img src={"/icon.svg"} width="24px" height="24px" alt="" />
<Typography
variant="h6"
noWrap

View File

@ -18,14 +18,7 @@
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
*/
import {
FilterList,
GridView,
North,
Sort,
South,
ViewList,
} from "@mui/icons-material";
import { FilterList, GridView, North, Sort, South, ViewList } from "@mui/icons-material";
import {
Box,
Button,
@ -36,6 +29,7 @@ import {
Menu,
Skeleton,
Divider,
Tooltip,
Typography,
} from "@mui/material";
import useTranslation from "next-translate/useTranslation";
@ -253,6 +247,8 @@ const BrowseSettings = ({
const router = useRouter();
const { t } = useTranslation("browse");
const switchViewTitle = layout === Layout.Grid ? t("browse.switchToList") : t("browse.switchToGrid");
return (
<>
<Box sx={{ display: "flex", justifyContent: "space-around" }}>
@ -260,20 +256,28 @@ const BrowseSettings = ({
<Button disabled>
<FilterList />
</Button>
<Button
id="sortby"
aria-controls={sortAnchor ? "sorby-menu" : undefined}
aria-haspopup="true"
aria-expanded={sortAnchor ? "true" : undefined}
onClick={(event: MouseEvent<HTMLElement>) => setSortAnchor(event.currentTarget)}
>
<Sort />
{t("browse.sortby", { key: t(`browse.sortkey.${sortKey}`) })}
{sortOrd === SortOrd.Asc ? <South fontSize="small" /> : <North fontSize="small" />}
</Button>
<Button onClick={() => setLayout(layout === Layout.List ? Layout.Grid : Layout.List)}>
{layout === Layout.List ? <GridView /> : <ViewList />}
</Button>
<Tooltip title={t("browse.sortby-tt")}>
<Button
id="sortby"
aria-label={t("browse.sortby-tt")}
aria-controls={sortAnchor ? "sorby-menu" : undefined}
aria-haspopup="true"
aria-expanded={sortAnchor ? "true" : undefined}
onClick={(event: MouseEvent<HTMLElement>) => setSortAnchor(event.currentTarget)}
>
<Sort />
{t("browse.sortby", { key: t(`browse.sortkey.${sortKey}`) })}
{sortOrd === SortOrd.Asc ? <South fontSize="small" /> : <North fontSize="small" />}
</Button>
</Tooltip>
<Tooltip title={switchViewTitle}>
<Button
onClick={() => setLayout(layout === Layout.List ? Layout.Grid : Layout.List)}
aria-label={switchViewTitle}
>
{layout === Layout.List ? <GridView /> : <ViewList />}
</Button>
</Tooltip>
</ButtonGroup>
</Box>
<Menu

View File

@ -135,7 +135,7 @@ export const ShowHeader = ({ data }: { data?: Show | Movie }) => {
{data?.name ?? <Skeleton width="15rem" />}
</Typography>
{(!data || getDisplayDate(data)) && (
<Typography variant="h5" sx={{ color: { md: "white" }, fontWeight: 300, mb: ".5rem" }}>
<Typography component="p" variant="h5" sx={{ color: { md: "white" }, fontWeight: 300, mb: ".5rem" }}>
{data != undefined ? (
getDisplayDate(data)
) : (