mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-11-16 14:54:23 +08:00
fix(i18n): use English runtime text and localize system UI
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useLocale } from 'next-intl';
|
||||
import { enUS, zhCN } from 'date-fns/locale';
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronLeftIcon,
|
||||
@@ -19,14 +21,18 @@ function Calendar({
|
||||
buttonVariant = 'ghost',
|
||||
formatters,
|
||||
components,
|
||||
locale: localeOverride,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayPicker> & {
|
||||
buttonVariant?: React.ComponentProps<typeof Button>['variant'];
|
||||
}) {
|
||||
const uiLocale = useLocale();
|
||||
const locale = localeOverride ?? (uiLocale === 'zh-CN' ? zhCN : enUS);
|
||||
const defaultClassNames = getDefaultClassNames();
|
||||
|
||||
return (
|
||||
<DayPicker
|
||||
locale={locale}
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn(
|
||||
'bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent',
|
||||
@@ -37,7 +43,7 @@ function Calendar({
|
||||
captionLayout={captionLayout}
|
||||
formatters={{
|
||||
formatMonthDropdown: (date) =>
|
||||
date.toLocaleString('default', { month: 'short' }),
|
||||
date.toLocaleString(locale.code ?? uiLocale, { month: 'short' }),
|
||||
...formatters,
|
||||
}}
|
||||
classNames={{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
import * as React from 'react';
|
||||
import { X } from 'lucide-react';
|
||||
|
||||
@@ -25,13 +26,16 @@ function normalizeTag(raw: string) {
|
||||
function TagsInput({
|
||||
value,
|
||||
onChange,
|
||||
placeholder = '输入后按 Enter 添加',
|
||||
placeholder = undefined,
|
||||
disabled = false,
|
||||
className,
|
||||
id,
|
||||
validateTag,
|
||||
'aria-invalid': ariaInvalid,
|
||||
}: TagsInputProps) {
|
||||
const rt = useTranslations('runtime');
|
||||
placeholder ??= rt('type_and_press_enter_to_add_e30b7b5f');
|
||||
|
||||
const [draft, setDraft] = React.useState('');
|
||||
const inputRef = React.useRef<HTMLInputElement>(null);
|
||||
|
||||
@@ -128,7 +132,7 @@ function TagsInput({
|
||||
<button
|
||||
type='button'
|
||||
className='hover:bg-muted rounded-sm p-0.5 outline-none focus-visible:ring-1 focus-visible:ring-ring'
|
||||
aria-label={`移除 ${tag}`}
|
||||
aria-label={rt('remove_value0_30c2158a', { value0: tag })}
|
||||
disabled={disabled}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
|
||||
Reference in New Issue
Block a user