mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-11-16 14:54:23 +08:00
feat(i18n): add Russian UI and harden localization
This commit is contained in:
@@ -347,7 +347,7 @@ export function createApiSections(rt: RuntimeTranslator): PolicySection[] {
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
<strong>{rt('parameters_ba89685c')}</strong> JSON Body{' '}
|
||||
<strong>{rt('parameters_ba89685c')}</strong> {rt('ui_jsonBody')}{' '}
|
||||
<code className='bg-muted px-1.5 rounded text-xs font-mono'>
|
||||
{rt.raw('name_token_name_is_admin_false_4f3e4868')}
|
||||
</code>
|
||||
|
||||
@@ -262,7 +262,7 @@ X-Access-Token: at_628d022b7a95e26b...`}
|
||||
</p>
|
||||
<ul className='list-disc pl-4 md:pl-5 space-y-2'>
|
||||
<li>
|
||||
<strong>OpenTelemetry Tracing:</strong>{' '}
|
||||
<strong>{rt('ui_openTelemetryTracing')}</strong>{' '}
|
||||
{rt(
|
||||
'tracing_context_is_propagated_automatically_gin_requests_0f549cce',
|
||||
)}
|
||||
|
||||
@@ -13,11 +13,13 @@ import { locales, type AppLocale } from '@/i18n/config';
|
||||
import { switchLocale } from '@/i18n/client';
|
||||
import { cn } from '@/lib/utils';
|
||||
import enNames from '@/messages/fragments/languages.en.json';
|
||||
import ruNames from '@/messages/fragments/languages.ru.json';
|
||||
import zhCNNames from '@/messages/fragments/languages.zh-CN.json';
|
||||
|
||||
// Language names always use their own locale, regardless of the active UI.
|
||||
const nativeNames: Record<AppLocale, string> = {
|
||||
en: enNames.languageNames.en,
|
||||
ru: ruNames.languageNames.ru,
|
||||
'zh-CN': zhCNNames.languageNames['zh-CN'],
|
||||
};
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ export function AuthSourceModal({
|
||||
/>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<Label>Client ID</Label>
|
||||
<Label>{rt('ui_clientId')}</Label>
|
||||
<Input
|
||||
value={form.client_id}
|
||||
onChange={(e) =>
|
||||
@@ -133,7 +133,7 @@ export function AuthSourceModal({
|
||||
/>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<Label>Client Secret</Label>
|
||||
<Label>{rt('ui_clientSecret')}</Label>
|
||||
<Input
|
||||
value={form.client_secret}
|
||||
onChange={(e) =>
|
||||
@@ -156,7 +156,7 @@ export function AuthSourceModal({
|
||||
/>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<Label>Scopes</Label>
|
||||
<Label>{rt('ui_scopes')}</Label>
|
||||
<Input
|
||||
value={form.scopes}
|
||||
onChange={(e) =>
|
||||
|
||||
@@ -117,7 +117,7 @@ export const FooterSection = React.memo(function FooterSection({
|
||||
</div>
|
||||
|
||||
<div className='pt-8 border-t border-border flex flex-col md:flex-row justify-between items-center gap-4 text-sm text-muted-foreground'>
|
||||
<p>© 2026 Modern Platform. All rights reserved.</p>
|
||||
<p>{rt('ui_copyright')}</p>
|
||||
<div className='flex gap-8'>
|
||||
<Link
|
||||
href='/docs/privacy-policy'
|
||||
|
||||
@@ -147,7 +147,7 @@ export const HeroSection = React.memo(function HeroSection({
|
||||
<div className='space-y-4'>
|
||||
<div className='space-y-2'>
|
||||
<div className='text-xs text-muted-foreground mb-2'>
|
||||
Stack
|
||||
{rt('ui_technologyStack')}
|
||||
</div>
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
<span className='inline-block px-2 py-1 bg-blue-500/10 text-blue-500 rounded text-xs font-medium'>
|
||||
@@ -161,10 +161,10 @@ export const HeroSection = React.memo(function HeroSection({
|
||||
<div className='flex justify-between items-end'>
|
||||
<div>
|
||||
<p className='text-sm text-muted-foreground mb-1'>
|
||||
Ready for
|
||||
{rt('ui_readyFor')}
|
||||
</p>
|
||||
<div className='text-lg font-bold tracking-tight text-foreground flex items-center gap-1'>
|
||||
<span>Develop</span>
|
||||
<span>{rt('ui_development')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className='h-8 w-8 rounded-full bg-primary' />
|
||||
@@ -186,9 +186,11 @@ export const HeroSection = React.memo(function HeroSection({
|
||||
<Zap className='size-5' />
|
||||
</div>
|
||||
<div>
|
||||
<p className='text-xs text-muted-foreground'>Features</p>
|
||||
<p className='text-xs text-muted-foreground'>
|
||||
{rt('ui_features')}
|
||||
</p>
|
||||
<div className='text-sm font-bold'>
|
||||
<span>Modern</span>
|
||||
<span>{rt('ui_modern')}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -125,6 +125,8 @@ function parseMenuDisplayConfig(
|
||||
* @returns {React.ReactNode} 应用侧边栏组件
|
||||
*/
|
||||
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
const { toggleSidebar, state, isMobile, setOpenMobile } = useSidebar();
|
||||
const { user, logout, loading: userLoading } = useUser();
|
||||
const { config } = usePublicConfig();
|
||||
@@ -440,8 +442,14 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
</SidebarContent>
|
||||
<SidebarFooter className='mt-auto px-3 py-3 group-data-[collapsible=icon]:hidden'>
|
||||
<div className='border-t border-border/60 pt-3 text-[11px] leading-5 text-muted-foreground'>
|
||||
<div>Version {APP_VERSION}</div>
|
||||
{APP_BUILD_DATE && <div>Build At {APP_BUILD_DATE}</div>}
|
||||
<div>
|
||||
{uiText('ui_versionLabel')} {APP_VERSION}
|
||||
</div>
|
||||
{APP_BUILD_DATE && (
|
||||
<div>
|
||||
{uiText('ui_builtAt')} {APP_BUILD_DATE}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</SidebarFooter>
|
||||
</Sidebar>
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useLocale, useTranslations } from 'next-intl';
|
||||
import { formatDateTime, formatNumber } from '@/i18n/format';
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
||||
|
||||
import enMessages from '@/messages/en.json';
|
||||
import zhCNMessages from '@/messages/zh-CN.json';
|
||||
import ruMessages from '@/messages/ru.json';
|
||||
|
||||
import { AppIntlProvider } from './intl-provider';
|
||||
import { createLocaleBootstrapScript } from '@/i18n/bootstrap';
|
||||
|
||||
function Probe() {
|
||||
const t = useTranslations('common');
|
||||
return <button>{t('save')}</button>;
|
||||
}
|
||||
|
||||
function FormattingProbe() {
|
||||
const locale = useLocale();
|
||||
return (
|
||||
<span data-testid='formats'>
|
||||
{locale}|{formatNumber(1234.5)}|{formatDateTime('2026-01-15T00:00:00Z')}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
const zhSave = (zhCNMessages.common as Record<string, string>).save;
|
||||
const enSave = (enMessages.common as Record<string, string>).save;
|
||||
|
||||
@@ -31,6 +43,7 @@ describe('AppIntlProvider (static export locale resolution)', () => {
|
||||
|
||||
afterEach(() => {
|
||||
document.cookie = 'NEXT_LOCALE=; Max-Age=0; Path=/';
|
||||
document.documentElement.removeAttribute('data-locale-pending');
|
||||
});
|
||||
|
||||
it('flips to the NEXT_LOCALE cookie locale after mount when SSR locale is stale', async () => {
|
||||
@@ -61,6 +74,51 @@ describe('AppIntlProvider (static export locale resolution)', () => {
|
||||
expect(document.documentElement.lang).toBe('zh-CN');
|
||||
});
|
||||
|
||||
it('applies Russian cookies before showing the hydrated English page', () => {
|
||||
document.cookie = 'NEXT_LOCALE=ru; Path=/';
|
||||
new Function(createLocaleBootstrapScript('en'))();
|
||||
expect(document.documentElement.hasAttribute('data-locale-pending')).toBe(
|
||||
true,
|
||||
);
|
||||
render(
|
||||
<AppIntlProvider locale='en' messages={enMessages}>
|
||||
<Probe />
|
||||
</AppIntlProvider>,
|
||||
);
|
||||
expect(screen.getByText(ruMessages.common.save)).toBeInTheDocument();
|
||||
expect(document.documentElement.lang).toBe('ru');
|
||||
expect(document.documentElement.hasAttribute('data-locale-pending')).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
it('recognizes Russian browser variants when there is no preference', () => {
|
||||
Object.defineProperty(navigator, 'languages', {
|
||||
value: ['ru-RU', 'en-US'],
|
||||
configurable: true,
|
||||
});
|
||||
render(
|
||||
<AppIntlProvider locale='en' messages={enMessages}>
|
||||
<Probe />
|
||||
</AppIntlProvider>,
|
||||
);
|
||||
expect(screen.getByText(ruMessages.common.save)).toBeInTheDocument();
|
||||
expect(document.documentElement.lang).toBe('ru');
|
||||
});
|
||||
|
||||
it('formats existing data in Russian on the first localized render', () => {
|
||||
document.documentElement.lang = 'en';
|
||||
document.cookie = 'NEXT_LOCALE=ru; Path=/';
|
||||
render(
|
||||
<AppIntlProvider locale='en' messages={enMessages}>
|
||||
<FormattingProbe />
|
||||
</AppIntlProvider>,
|
||||
);
|
||||
expect(screen.getByTestId('formats').textContent).toBe(
|
||||
'ru|1\u00a0234,5|15.01.2026, 08:00',
|
||||
);
|
||||
});
|
||||
|
||||
it('does not flip without a cookie preference', () => {
|
||||
render(
|
||||
<AppIntlProvider locale='zh-CN' messages={zhCNMessages}>
|
||||
|
||||
@@ -7,11 +7,13 @@ import type { ReactNode } from 'react';
|
||||
import { resolveClientLocale } from '@/i18n/client';
|
||||
import type { AppLocale } from '@/i18n/config';
|
||||
import enMessages from '@/messages/en.json';
|
||||
import ruMessages from '@/messages/ru.json';
|
||||
import zhCNMessages from '@/messages/zh-CN.json';
|
||||
|
||||
const messagesByLocale: Record<AppLocale, AbstractIntlMessages> = {
|
||||
'zh-CN': zhCNMessages,
|
||||
en: enMessages,
|
||||
ru: ruMessages,
|
||||
};
|
||||
|
||||
type Props = {
|
||||
@@ -32,14 +34,25 @@ export function AppIntlProvider({
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const resolved = resolveClientLocale();
|
||||
// Formatting utilities run during the context update's render. Publish
|
||||
// its locale first, while the prepaint gate still hides stale markup.
|
||||
document.documentElement.lang = resolved;
|
||||
if (resolved !== ssrLocale) {
|
||||
setClientLocale(resolved);
|
||||
}
|
||||
document.documentElement.lang = resolved;
|
||||
}, [ssrLocale]);
|
||||
|
||||
const locale = clientLocale ?? ssrLocale;
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (locale === resolveClientLocale()) {
|
||||
document.documentElement.lang = locale;
|
||||
const fallback = document.getElementById('locale-load-fallback');
|
||||
if (fallback) fallback.hidden = true;
|
||||
document.documentElement.removeAttribute('data-locale-pending');
|
||||
}
|
||||
}, [locale]);
|
||||
|
||||
return (
|
||||
<NextIntlClientProvider
|
||||
locale={locale}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
import * as React from 'react';
|
||||
import { Slot } from '@radix-ui/react-slot';
|
||||
import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
||||
@@ -5,7 +8,15 @@ import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
function Breadcrumb({ ...props }: React.ComponentProps<'nav'>) {
|
||||
return <nav aria-label='breadcrumb' data-slot='breadcrumb' {...props} />;
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<nav
|
||||
aria-label={uiText('ui_breadcrumb')}
|
||||
data-slot='breadcrumb'
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {
|
||||
@@ -84,6 +95,8 @@ function BreadcrumbEllipsis({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<'span'>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<span
|
||||
data-slot='breadcrumb-ellipsis'
|
||||
@@ -93,7 +106,7 @@ function BreadcrumbEllipsis({
|
||||
{...props}
|
||||
>
|
||||
<MoreHorizontal className='size-4' />
|
||||
<span className='sr-only'>More</span>
|
||||
<span className='sr-only'>{uiText('ui_more')}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { NextIntlClientProvider } from 'next-intl';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { Calendar } from './calendar';
|
||||
|
||||
describe('Calendar accessibility translations', () => {
|
||||
it('localizes Russian navigation, dropdowns and selected/today labels', () => {
|
||||
const date = new Date(2026, 0, 15);
|
||||
render(
|
||||
<NextIntlClientProvider locale='ru' messages={{}}>
|
||||
<Calendar
|
||||
mode='single'
|
||||
defaultMonth={date}
|
||||
today={date}
|
||||
selected={date}
|
||||
captionLayout='dropdown'
|
||||
/>
|
||||
</NextIntlClientProvider>,
|
||||
);
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Перейти к предыдущему месяцу' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Перейти к следующему месяцу' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('combobox', { name: 'Выберите месяц' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('combobox', { name: 'Выберите год' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('button', { name: /Сегодня.*выбрано/ }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('localizes Chinese navigation too', () => {
|
||||
render(
|
||||
<NextIntlClientProvider locale='zh-CN' messages={{}}>
|
||||
<Calendar defaultMonth={new Date(2026, 0, 1)} />
|
||||
</NextIntlClientProvider>,
|
||||
);
|
||||
expect(
|
||||
screen.getByRole('button', { name: '前往上个月' }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole('button', { name: '前往下个月' }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import { useLocale } from 'next-intl';
|
||||
import { enUS, zhCN } from 'date-fns/locale';
|
||||
import { enUS, ru, zhCN } from 'react-day-picker/locale';
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronLeftIcon,
|
||||
@@ -27,7 +27,9 @@ function Calendar({
|
||||
buttonVariant?: React.ComponentProps<typeof Button>['variant'];
|
||||
}) {
|
||||
const uiLocale = useLocale();
|
||||
const locale = localeOverride ?? (uiLocale === 'zh-CN' ? zhCN : enUS);
|
||||
const locale =
|
||||
localeOverride ??
|
||||
(uiLocale === 'zh-CN' ? zhCN : uiLocale === 'ru' ? ru : enUS);
|
||||
const defaultClassNames = getDefaultClassNames();
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import * as React from 'react';
|
||||
import useEmblaCarousel, {
|
||||
type UseEmblaCarouselType,
|
||||
@@ -177,6 +179,8 @@ function CarouselPrevious({
|
||||
size = 'icon',
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
||||
|
||||
return (
|
||||
@@ -196,7 +200,7 @@ function CarouselPrevious({
|
||||
{...props}
|
||||
>
|
||||
<ArrowLeft />
|
||||
<span className='sr-only'>Previous slide</span>
|
||||
<span className='sr-only'>{uiText('ui_previousSlide')}</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -207,6 +211,8 @@ function CarouselNext({
|
||||
size = 'icon',
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
||||
|
||||
return (
|
||||
@@ -226,7 +232,7 @@ function CarouselNext({
|
||||
{...props}
|
||||
>
|
||||
<ArrowRight />
|
||||
<span className='sr-only'>Next slide</span>
|
||||
<span className='sr-only'>{uiText('ui_nextSlide')}</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Command as CommandPrimitive } from 'cmdk';
|
||||
import { SearchIcon } from 'lucide-react';
|
||||
import { motion } from 'motion/react';
|
||||
@@ -31,8 +32,8 @@ function Command({
|
||||
}
|
||||
|
||||
function CommandDialog({
|
||||
title = 'Command Palette',
|
||||
description = 'Search for a command to run...',
|
||||
title,
|
||||
description,
|
||||
children,
|
||||
className,
|
||||
showCloseButton = false,
|
||||
@@ -45,11 +46,14 @@ function CommandDialog({
|
||||
showCloseButton?: boolean;
|
||||
shouldFilter?: boolean;
|
||||
}) {
|
||||
const t = useTranslations('runtime');
|
||||
return (
|
||||
<Dialog {...props}>
|
||||
<DialogHeader className='sr-only'>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
<DialogDescription>{description}</DialogDescription>
|
||||
<DialogTitle>{title ?? t('ui_commandPalette')}</DialogTitle>
|
||||
<DialogDescription>
|
||||
{description ?? t('ui_commandSearch')}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogContent
|
||||
className={cn('overflow-hidden p-0 shadow-2xl', className)}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import * as React from 'react';
|
||||
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
||||
import { XIcon } from 'lucide-react';
|
||||
@@ -54,6 +56,8 @@ function DialogContent({
|
||||
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
||||
showCloseButton?: boolean;
|
||||
}) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
// 统一小屏样式:全宽留白、适度圆角、滚动保护
|
||||
const mobileBase = 'w-full max-w-[calc(100%-1.5rem)]';
|
||||
const desktopBase = 'sm:max-w-lg md:max-w-xl';
|
||||
@@ -75,7 +79,7 @@ function DialogContent({
|
||||
className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
||||
>
|
||||
<XIcon />
|
||||
<span className='sr-only'>Close</span>
|
||||
<span className='sr-only'>{uiText('ui_closeLabel')}</span>
|
||||
</DialogPrimitive.Close>
|
||||
)}
|
||||
</DialogPrimitive.Content>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import { CropIcon, RotateCcwIcon } from 'lucide-react';
|
||||
import { Slot } from '@radix-ui/react-slot';
|
||||
import {
|
||||
@@ -235,6 +237,8 @@ export const ImageCropContent = ({
|
||||
style,
|
||||
className,
|
||||
}: ImageCropContentProps) => {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
const {
|
||||
imgSrc,
|
||||
crop,
|
||||
@@ -262,7 +266,7 @@ export const ImageCropContent = ({
|
||||
{imgSrc && (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
alt='crop'
|
||||
alt={uiText('ui_imageCrop')}
|
||||
className='size-full'
|
||||
height={400}
|
||||
onLoad={onImageLoad}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
import * as React from 'react';
|
||||
import {
|
||||
ChevronLeftIcon,
|
||||
@@ -9,10 +12,12 @@ import { cn } from '@/lib/utils';
|
||||
import { buttonVariants, type Button } from '@/components/ui/button';
|
||||
|
||||
function Pagination({ className, ...props }: React.ComponentProps<'nav'>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<nav
|
||||
role='navigation'
|
||||
aria-label='pagination'
|
||||
aria-label={uiText('ui_pagination')}
|
||||
data-slot='pagination'
|
||||
className={cn('mx-auto flex w-full justify-center', className)}
|
||||
{...props}
|
||||
@@ -69,15 +74,17 @@ function PaginationPrevious({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof PaginationLink>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<PaginationLink
|
||||
aria-label='Go to previous page'
|
||||
aria-label={uiText('ui_previousPage')}
|
||||
size='default'
|
||||
className={cn('gap-1 px-2.5 sm:pl-2.5', className)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronLeftIcon />
|
||||
<span className='hidden sm:block'>Previous</span>
|
||||
<span className='hidden sm:block'>{uiText('ui_previousLabel')}</span>
|
||||
</PaginationLink>
|
||||
);
|
||||
}
|
||||
@@ -86,14 +93,16 @@ function PaginationNext({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof PaginationLink>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<PaginationLink
|
||||
aria-label='Go to next page'
|
||||
aria-label={uiText('ui_nextPage')}
|
||||
size='default'
|
||||
className={cn('gap-1 px-2.5 sm:pr-2.5', className)}
|
||||
{...props}
|
||||
>
|
||||
<span className='hidden sm:block'>Next</span>
|
||||
<span className='hidden sm:block'>{uiText('ui_nextLabel')}</span>
|
||||
<ChevronRightIcon />
|
||||
</PaginationLink>
|
||||
);
|
||||
@@ -103,6 +112,8 @@ function PaginationEllipsis({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<'span'>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<span
|
||||
aria-hidden
|
||||
@@ -111,7 +122,7 @@ function PaginationEllipsis({
|
||||
{...props}
|
||||
>
|
||||
<MoreHorizontalIcon className='size-4' />
|
||||
<span className='sr-only'>More pages</span>
|
||||
<span className='sr-only'>{uiText('ui_morePages')}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import * as React from 'react';
|
||||
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
||||
import { XIcon } from 'lucide-react';
|
||||
@@ -52,6 +54,8 @@ function SheetContent({
|
||||
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
|
||||
side?: 'top' | 'right' | 'bottom' | 'left';
|
||||
}) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<SheetPortal>
|
||||
<SheetOverlay />
|
||||
@@ -74,7 +78,7 @@ function SheetContent({
|
||||
{children}
|
||||
<SheetPrimitive.Close className='ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none'>
|
||||
<XIcon className='size-4' />
|
||||
<span className='sr-only'>Close</span>
|
||||
<span className='sr-only'>{uiText('ui_closeLabel')}</span>
|
||||
</SheetPrimitive.Close>
|
||||
</SheetPrimitive.Content>
|
||||
</SheetPortal>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import * as React from 'react';
|
||||
import { Slot } from '@radix-ui/react-slot';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
@@ -164,6 +166,8 @@ function Sidebar({
|
||||
variant?: 'sidebar' | 'floating' | 'inset';
|
||||
collapsible?: 'offcanvas' | 'icon' | 'none';
|
||||
}) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
||||
|
||||
if (collapsible === 'none') {
|
||||
@@ -197,8 +201,10 @@ function Sidebar({
|
||||
side={side}
|
||||
>
|
||||
<SheetHeader className='sr-only'>
|
||||
<SheetTitle>Sidebar</SheetTitle>
|
||||
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
||||
<SheetTitle>{uiText('ui_sidebarLabel')}</SheetTitle>
|
||||
<SheetDescription>
|
||||
{uiText('ui_mobileSidebarDescription')}
|
||||
</SheetDescription>
|
||||
</SheetHeader>
|
||||
<div className='flex h-full w-full flex-col'>{children}</div>
|
||||
</SheetContent>
|
||||
@@ -261,6 +267,8 @@ function SidebarTrigger({
|
||||
onClick,
|
||||
...props
|
||||
}: React.ComponentProps<typeof Button>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
const { toggleSidebar } = useSidebar();
|
||||
|
||||
return (
|
||||
@@ -277,22 +285,24 @@ function SidebarTrigger({
|
||||
{...props}
|
||||
>
|
||||
<PanelLeftIcon />
|
||||
<span className='sr-only'>Toggle Sidebar</span>
|
||||
<span className='sr-only'>{uiText('ui_toggleSidebar')}</span>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
const { toggleSidebar } = useSidebar();
|
||||
|
||||
return (
|
||||
<button
|
||||
data-sidebar='rail'
|
||||
data-slot='sidebar-rail'
|
||||
aria-label='Toggle Sidebar'
|
||||
aria-label={uiText('ui_toggleSidebar')}
|
||||
tabIndex={-1}
|
||||
onClick={toggleSidebar}
|
||||
title='Toggle Sidebar'
|
||||
title={uiText('ui_toggleSidebar')}
|
||||
className={cn(
|
||||
'hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex',
|
||||
'in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize',
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
TriangleAlertIcon,
|
||||
} from 'lucide-react';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Toaster as Sonner, type ToasterProps, useSonner } from 'sonner';
|
||||
import { useBellRing } from '@/contexts/bell-ring-context';
|
||||
|
||||
@@ -34,6 +35,7 @@ function ToastObserver() {
|
||||
|
||||
const Toaster = ({ ...props }: ToasterProps) => {
|
||||
const { theme = 'system' } = useTheme();
|
||||
const t = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -41,6 +43,8 @@ const Toaster = ({ ...props }: ToasterProps) => {
|
||||
<Sonner
|
||||
theme={theme as ToasterProps['theme']}
|
||||
className='toaster group'
|
||||
containerAriaLabel={t('ui_toastRegion')}
|
||||
toastOptions={{ closeButtonAriaLabel: t('ui_closeToast') }}
|
||||
icons={{
|
||||
success: <CircleCheckIcon className='size-4' />,
|
||||
info: <InfoIcon className='size-4' />,
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Loader2Icon } from 'lucide-react';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
function Spinner({ className, ...props }: React.ComponentProps<'svg'>) {
|
||||
const uiText = useTranslations('runtime');
|
||||
|
||||
return (
|
||||
<Loader2Icon
|
||||
role='status'
|
||||
aria-label='Loading'
|
||||
aria-label={uiText('ui_loadingLabel')}
|
||||
className={cn('size-4 animate-spin', className)}
|
||||
{...props}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user