mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: footer lang
This commit is contained in:
1 parent
4e80490fd4
commit
baa16840df
5 files changed
+37
-19
No files matched your search
@@ -824,7 +824,8 @@
|
|||||||
"other_projects": {
|
"other_projects": {
|
||||||
"title": "Other cool projects"
|
"title": "Other cool projects"
|
||||||
},
|
},
|
||||||
"help_translate": "Please help translate %s1 to %s2!"
|
"help_translate": "Please help translate %s1 to %s2!",
|
||||||
|
"seo_description": "Tools for everything World of Tanks Blitz"
|
||||||
},
|
},
|
||||||
|
|
||||||
"tools": {
|
"tools": {
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
---
|
---
|
||||||
import { assertSecret, fetchGameDefinitions } from '@blitzkit/core';
|
import { assertSecret, fetchGameDefinitions } from '@blitzkit/core';
|
||||||
import { Code, Flex, Heading, Link, Text } from '@radix-ui/themes';
|
import { DEFAULT_LOCALE } from '@blitzkit/i18n';
|
||||||
|
import { Box, Code, Flex, Heading, Link, Text } from '@radix-ui/themes';
|
||||||
import packageJson from '../../../../package.json';
|
import packageJson from '../../../../package.json';
|
||||||
import { getStrings } from '../core/i18n/getStrings';
|
import { getStrings } from '../core/i18n/getStrings';
|
||||||
|
import { LocaleSwitcherThemeWrapper } from './LocaleSwitcher';
|
||||||
|
|
||||||
const gameDefinitions = await fetchGameDefinitions();
|
const gameDefinitions = await fetchGameDefinitions();
|
||||||
const PUBLIC_ASSET_BRANCH = assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH);
|
const PUBLIC_ASSET_BRANCH = assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH);
|
||||||
const { locale } = Astro.params;
|
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
|
||||||
const strings = getStrings(locale);
|
const strings = getStrings(locale);
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -39,6 +41,10 @@ const strings = getStrings(locale);
|
|||||||
<Text size="1" color="gray">
|
<Text size="1" color="gray">
|
||||||
{strings.website.footer.copyright}
|
{strings.website.footer.copyright}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
|
<Box mt="2">
|
||||||
|
<LocaleSwitcherThemeWrapper {locale} client:load />
|
||||||
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ import {
|
|||||||
} from '@blitzkit/i18n';
|
} from '@blitzkit/i18n';
|
||||||
import { Select } from '@radix-ui/themes';
|
import { Select } from '@radix-ui/themes';
|
||||||
import type { LocaleAcceptorProps } from '../hooks/useLocale';
|
import type { LocaleAcceptorProps } from '../hooks/useLocale';
|
||||||
|
import { BlitzKitTheme } from './BlitzKitTheme';
|
||||||
|
|
||||||
|
export function LocaleSwitcherThemeWrapper({ locale }: LocaleAcceptorProps) {
|
||||||
|
return (
|
||||||
|
<BlitzKitTheme style={{ background: 'transparent' }}>
|
||||||
|
<LocaleSwitcher locale={locale} />
|
||||||
|
</BlitzKitTheme>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function LocaleSwitcher({ locale }: LocaleAcceptorProps) {
|
export function LocaleSwitcher({ locale }: LocaleAcceptorProps) {
|
||||||
return (
|
return (
|
||||||
@@ -14,7 +23,19 @@ export function LocaleSwitcher({ locale }: LocaleAcceptorProps) {
|
|||||||
defaultValue={locale}
|
defaultValue={locale}
|
||||||
onValueChange={(locale) => {
|
onValueChange={(locale) => {
|
||||||
localStorage.setItem('preferred-locale', locale);
|
localStorage.setItem('preferred-locale', locale);
|
||||||
window.location.pathname = `/${locale === DEFAULT_LOCALE ? '' : locale}`;
|
|
||||||
|
let rawPath = window.location.pathname;
|
||||||
|
|
||||||
|
for (const supportedLocale of SUPPORTED_LOCALES) {
|
||||||
|
if (window.location.pathname.startsWith(`/${supportedLocale}`)) {
|
||||||
|
rawPath = rawPath.replace(`/${supportedLocale}`, '');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.pathname = `${
|
||||||
|
locale === DEFAULT_LOCALE ? '' : `/${locale}`
|
||||||
|
}${rawPath}`;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Select.Trigger />
|
<Select.Trigger />
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ 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/i18n';
|
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from '@blitzkit/i18n';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
noFooter?: boolean;
|
noFooter?: boolean;
|
||||||
@@ -14,23 +14,10 @@ export interface Props {
|
|||||||
|
|
||||||
const { noFooter } = Astro.props;
|
const { noFooter } = Astro.props;
|
||||||
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
|
const locale = Astro.params.locale ?? DEFAULT_LOCALE;
|
||||||
const { pathname } = Astro.url;
|
|
||||||
const isRoot = pathname === '/';
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<html lang={locale}>
|
<html lang={locale}>
|
||||||
<head>
|
<head>
|
||||||
{
|
|
||||||
isRoot && (
|
|
||||||
<>
|
|
||||||
<title>BlitzKit</title>
|
|
||||||
<meta
|
|
||||||
name="description"
|
|
||||||
content="🎉 Tools for everything World of Tanks Blitz"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
<meta property="og:site_name" content="BlitzKit" />
|
<meta property="og:site_name" content="BlitzKit" />
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/x-icon" href="/favicon.png" />
|
<link rel="icon" type="image/x-icon" href="/favicon.png" />
|
||||||
@@ -41,7 +28,7 @@ const isRoot = pathname === '/';
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { SUPPORTED_LOCALES } from '@blitzkit/i18n';
|
import { SUPPORTED_LOCALES } from '@blitzkit/i18n';
|
||||||
import { getBestLocale } from '../core/i18n/getBestLocale';
|
import { getBestLocale } from '../core/i18n/getBestLocale';
|
||||||
|
|
||||||
const isI18nPath = SUPPORTED_LOCALES.some((locale) =>
|
const isI18nPath = SUPPORTED_LOCALES.some((locale) =>
|
||||||
window.location.pathname.startsWith(`/${locale}`),
|
window.location.pathname.startsWith(`/${locale}`),
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ export const getStaticPaths = (() => {
|
|||||||
}) satisfies GetStaticPaths;
|
}) satisfies GetStaticPaths;
|
||||||
---
|
---
|
||||||
|
|
||||||
|
<title>BlitzKit</title>
|
||||||
|
<meta name="description" content={strings.website.home.seo_description} />
|
||||||
|
|
||||||
<BaseLayout>
|
<BaseLayout>
|
||||||
<HomeHero />
|
<HomeHero />
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user