Further i18n

This commit is contained in:
James Hawkins 2022-12-17 09:04:13 +00:00
parent 03ffea333a
commit aa26b796b8
3 changed files with 25 additions and 12 deletions

View File

@ -5,8 +5,8 @@
"search": { "search": {
"loading": "Fetching your favourite shows...", "loading": "Fetching your favourite shows...",
"providersFailed": "{{fails}}/{{total}} providers failed!", "providersFailed": "{{fails}}/{{total}} providers failed!",
"allResults": "That's all we have!", "allResults": "That's all we have!",
"noResults": "We couldn't find anything!", "noResults": "We couldn't find anything!",
"allFailed": "All providers have failed!", "allFailed": "All providers have failed!",
"headingTitle": "Search results", "headingTitle": "Search results",
"headingLink": "Back to home", "headingLink": "Back to home",
@ -23,19 +23,24 @@
"notFound": { "notFound": {
"backArrow": "Back to home", "backArrow": "Back to home",
"media": { "media": {
"title": "Couldn't find that media", "title": "Couldn't find that media",
"description": "We couldn't find the media you requested. Either it's been removed or you tampered with the URL" "description": "We couldn't find the media you requested. Either it's been removed or you tampered with the URL"
}, },
"provider": { "provider": {
"title": "This provider has been disabled", "title": "This provider has been disabled",
"description": "We had issues with the provider or it was too unstable to use, so we had to disable it." "description": "We had issues with the provider or it was too unstable to use, so we had to disable it."
}, },
"page": { "page": {
"title": "Couldn't find that page", "title": "Couldn't find that page",
"description": "We looked everywhere: under the bins, in the closet, behind the proxy but ultimately couldn't find the page you are looking for." "description": "We looked everywhere: under the bins, in the closet, behind the proxy but ultimately couldn't find the page you are looking for."
} }
}, },
"searchBar": {
"movie": "Movie",
"series": "Series",
"Search": "Search"
},
"errorBoundary": { "errorBoundary": {
"text": "The app encountered an error and wasn't able to recover, please report it to the" "text": "The app encountered an error and wasn't able to recover, please report it to the"
} }
} }

View File

@ -1,5 +1,6 @@
import { useState } from "react"; import { useState } from "react";
import { MWMediaType, MWQuery } from "@/providers"; import { MWMediaType, MWQuery } from "@/providers";
import { useTranslation } from "react-i18next";
import { DropdownButton } from "./buttons/DropdownButton"; import { DropdownButton } from "./buttons/DropdownButton";
import { Icons } from "./Icon"; import { Icons } from "./Icon";
import { TextInputControl } from "./text-inputs/TextInputControl"; import { TextInputControl } from "./text-inputs/TextInputControl";
@ -13,6 +14,8 @@ export interface SearchBarProps {
} }
export function SearchBarInput(props: SearchBarProps) { export function SearchBarInput(props: SearchBarProps) {
const { t } = useTranslation();
const [dropdownOpen, setDropdownOpen] = useState(false); const [dropdownOpen, setDropdownOpen] = useState(false);
function setSearch(value: string) { function setSearch(value: string) {
props.onChange( props.onChange(
@ -52,12 +55,12 @@ export function SearchBarInput(props: SearchBarProps) {
options={[ options={[
{ {
id: MWMediaType.MOVIE, id: MWMediaType.MOVIE,
name: "Movie", name: t('searchBar.movie'),
icon: Icons.FILM, icon: Icons.FILM,
}, },
{ {
id: MWMediaType.SERIES, id: MWMediaType.SERIES,
name: "Series", name: t('searchBar.series'),
icon: Icons.CLAPPER_BOARD, icon: Icons.CLAPPER_BOARD,
}, },
// { // {
@ -68,7 +71,7 @@ export function SearchBarInput(props: SearchBarProps) {
]} ]}
onClick={() => setDropdownOpen((old) => !old)} onClick={() => setDropdownOpen((old) => !old)}
> >
{props.buttonText || "Search"} {props.buttonText || t('searchBar.search')}
</DropdownButton> </DropdownButton>
</div> </div>
); );

View File

@ -14,12 +14,15 @@ import {
MWPortableMedia, MWPortableMedia,
} from "@/providers"; } from "@/providers";
import { getSeasonDataFromMedia } from "@/providers/methods/seasons"; import { getSeasonDataFromMedia } from "@/providers/methods/seasons";
import { useTranslation } from "react-i18next";
export interface SeasonsProps { export interface SeasonsProps {
media: MWMedia; media: MWMedia;
} }
export function LoadingSeasons(props: { error?: boolean }) { export function LoadingSeasons(props: { error?: boolean }) {
const { t } = useTranslation();
return ( return (
<div> <div>
<div> <div>
@ -34,7 +37,7 @@ export function LoadingSeasons(props: { error?: boolean }) {
) : ( ) : (
<div className="flex items-center space-x-3"> <div className="flex items-center space-x-3">
<IconPatch icon={Icons.WARNING} className="text-red-400" /> <IconPatch icon={Icons.WARNING} className="text-red-400" />
<p>Failed to load seasons and episodes</p> <p>{t('seasons.failed')}</p>
</div> </div>
)} )}
</div> </div>
@ -42,6 +45,8 @@ export function LoadingSeasons(props: { error?: boolean }) {
} }
export function Seasons(props: SeasonsProps) { export function Seasons(props: SeasonsProps) {
const { t } = useTranslation();
const [searchSeasons, loading, error, success] = useLoading( const [searchSeasons, loading, error, success] = useLoading(
(portableMedia: MWPortableMedia) => getSeasonDataFromMedia(portableMedia) (portableMedia: MWPortableMedia) => getSeasonDataFromMedia(portableMedia)
); );
@ -70,7 +75,7 @@ export function Seasons(props: SeasonsProps) {
const mapSeason = (season: MWMediaSeason) => ({ const mapSeason = (season: MWMediaSeason) => ({
id: season.id, id: season.id,
name: season.title || `Season ${season.sort}`, name: season.title || `${t('seasons.season')} ${season.sort}`,
}); });
const options = seasons.seasons.map(mapSeason); const options = seasons.seasons.map(mapSeason);