mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: localize tank search
This commit is contained in:
1 parent
06cbe1e733
commit
ade6ec8af1
5 files changed
+21
-6
No files matched your search
@@ -731,6 +731,11 @@
|
|||||||
"count_singular": "1 tank",
|
"count_singular": "1 tank",
|
||||||
"count_plural": "%s1 tanks",
|
"count_plural": "%s1 tanks",
|
||||||
"sorting_by": "Sorting by %s1",
|
"sorting_by": "Sorting by %s1",
|
||||||
|
"no_tanks_found": {
|
||||||
|
"body": "No tanks found.",
|
||||||
|
"search_again": "Try searching again.",
|
||||||
|
"clear_filters": "Try clearing filters."
|
||||||
|
},
|
||||||
"sort": {
|
"sort": {
|
||||||
"meta.none": "none",
|
"meta.none": "none",
|
||||||
"survivability.health": "health",
|
"survivability.health": "health",
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
import { DEFAULT_LOCALE } from '@blitzkit/core';
|
||||||
import { Link, type LinkProps } from '@radix-ui/themes';
|
import { Link, type LinkProps } from '@radix-ui/themes';
|
||||||
import type { LocaleAcceptorProps } from '../hooks/useLocale';
|
import type { LocaleAcceptorProps } from '../hooks/useLocale';
|
||||||
|
|
||||||
type LinkI18nProps = LinkProps & LocaleAcceptorProps;
|
type LinkI18nProps = LinkProps & LocaleAcceptorProps;
|
||||||
|
|
||||||
export function LinkI18n({ locale, href, ...props }: LinkI18nProps) {
|
export function LinkI18n({ locale, href, ...props }: LinkI18nProps) {
|
||||||
const prefix = locale === undefined ? '' : `/${locale}`;
|
const prefix =
|
||||||
|
locale === undefined || locale === DEFAULT_LOCALE ? '' : `/${locale}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={href?.startsWith('/') ? `${prefix}${href}` : href} {...props} />
|
<Link href={href?.startsWith('/') ? `${prefix}${href}` : href} {...props} />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Flex, Link, Text } from '@radix-ui/themes';
|
import { Flex, Link, Text } from '@radix-ui/themes';
|
||||||
|
import { useLocale } from '../../../hooks/useLocale';
|
||||||
import { $tankFilters, initialTankFilters } from '../../../stores/tankFilters';
|
import { $tankFilters, initialTankFilters } from '../../../stores/tankFilters';
|
||||||
|
|
||||||
interface NoResultsProps {
|
interface NoResultsProps {
|
||||||
@@ -6,10 +7,12 @@ interface NoResultsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function NoResults({ type = 'filters' }: NoResultsProps) {
|
export function NoResults({ type = 'filters' }: NoResultsProps) {
|
||||||
|
const { strings } = useLocale();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex flexGrow="1" align="center" justify="center">
|
<Flex flexGrow="1" align="center" justify="center">
|
||||||
<Text color="gray">
|
<Text color="gray">
|
||||||
No tanks found.{' '}
|
{strings.website.common.tank_search.no_tanks_found.body}.{' '}
|
||||||
<Link
|
<Link
|
||||||
href="#"
|
href="#"
|
||||||
underline="always"
|
underline="always"
|
||||||
@@ -18,7 +21,9 @@ export function NoResults({ type = 'filters' }: NoResultsProps) {
|
|||||||
$tankFilters.set(initialTankFilters);
|
$tankFilters.set(initialTankFilters);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{type === 'filters' ? 'Try clearing filters' : 'Try searching again'}
|
{type === 'filters'
|
||||||
|
? strings.website.common.tank_search.no_tanks_found.clear_filters
|
||||||
|
: strings.website.common.tank_search.no_tanks_found.search_again}
|
||||||
</Link>
|
</Link>
|
||||||
.
|
.
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Flex, Separator, Text } from '@radix-ui/themes';
|
|||||||
import { isEqual } from 'lodash-es';
|
import { isEqual } from 'lodash-es';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { awaitableTankDefinitions } from '../../../core/awaitables/tankDefinitions';
|
import { awaitableTankDefinitions } from '../../../core/awaitables/tankDefinitions';
|
||||||
|
import { useLocale } from '../../../hooks/useLocale';
|
||||||
import { $tankFilters, initialTankFilters } from '../../../stores/tankFilters';
|
import { $tankFilters, initialTankFilters } from '../../../stores/tankFilters';
|
||||||
import { TankopediaPersistent } from '../../../stores/tankopediaPersistent';
|
import { TankopediaPersistent } from '../../../stores/tankopediaPersistent';
|
||||||
import { $tankopediaSort } from '../../../stores/tankopediaSort';
|
import { $tankopediaSort } from '../../../stores/tankopediaSort';
|
||||||
@@ -27,6 +28,7 @@ export function RecentlyViewed() {
|
|||||||
}),
|
}),
|
||||||
[filters],
|
[filters],
|
||||||
);
|
);
|
||||||
|
const { strings } = useLocale();
|
||||||
|
|
||||||
if (recentlyViewed.length === 0 || sort.by !== 'meta.none' || hasFilters) {
|
if (recentlyViewed.length === 0 || sort.by !== 'meta.none' || hasFilters) {
|
||||||
return null;
|
return null;
|
||||||
@@ -35,7 +37,7 @@ export function RecentlyViewed() {
|
|||||||
return (
|
return (
|
||||||
<Flex direction="column" gap="2" mt="2" mb="6">
|
<Flex direction="column" gap="2" mt="2" mb="6">
|
||||||
<Text color="gray" align="center">
|
<Text color="gray" align="center">
|
||||||
Recently viewed
|
{strings.website.common.tank_search.recent}
|
||||||
</Text>
|
</Text>
|
||||||
<TankCardWrapper>
|
<TankCardWrapper>
|
||||||
{recentlyViewed.map((id) => (
|
{recentlyViewed.map((id) => (
|
||||||
|
|||||||
@@ -6,18 +6,19 @@ import Footer from '../components/Footer.astro';
|
|||||||
import Navbar from '../components/Navbar.astro';
|
import Navbar from '../components/Navbar.astro';
|
||||||
import Party3 from '../components/Party3.astro';
|
import Party3 from '../components/Party3.astro';
|
||||||
import './base.css';
|
import './base.css';
|
||||||
|
import { DEFAULT_LOCALE } from '@blitzkit/core';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
noFooter?: boolean;
|
noFooter?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { noFooter } = Astro.props;
|
const { noFooter } = Astro.props;
|
||||||
const { locale } = Astro.params;
|
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
|
||||||
const { pathname } = Astro.url;
|
const { pathname } = Astro.url;
|
||||||
const isRoot = pathname === '/';
|
const isRoot = pathname === '/';
|
||||||
---
|
---
|
||||||
|
|
||||||
<html lang="en">
|
<html lang={locale}>
|
||||||
<head>
|
<head>
|
||||||
{
|
{
|
||||||
isRoot && (
|
isRoot && (
|
||||||
|
|||||||
Reference in new issue
Block a user