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,3 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
@@ -28,6 +31,7 @@ export function RankCard({
|
||||
color = '#3b82f6',
|
||||
valueFormatter,
|
||||
}: RankCardProps) {
|
||||
const t = useTranslations('dataComponents');
|
||||
return (
|
||||
<Card className='border-dashed shadow-none'>
|
||||
<CardHeader className='pb-3'>
|
||||
@@ -43,7 +47,7 @@ export function RankCard({
|
||||
items={items}
|
||||
color={color}
|
||||
valueFormatter={valueFormatter}
|
||||
emptyMessage={`暂无 ${title} 数据`}
|
||||
emptyMessage={t('noDataForTitle', { title })}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { getFormattingLocale } from '@/i18n/format';
|
||||
import { useMemo } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
@@ -24,16 +26,17 @@ const defaultFormatter = (value: number) => {
|
||||
if (value >= 1000) {
|
||||
return `${Number((value / 1000).toFixed(2))}k`;
|
||||
}
|
||||
return value.toLocaleString('zh-CN');
|
||||
return value.toLocaleString(getFormattingLocale());
|
||||
};
|
||||
|
||||
export function RankChart({
|
||||
items,
|
||||
color,
|
||||
valueFormatter = defaultFormatter,
|
||||
emptyMessage = '暂无分布数据',
|
||||
emptyMessage,
|
||||
className,
|
||||
}: RankChartProps) {
|
||||
const t = useTranslations('dataComponents');
|
||||
const maxValue = useMemo(
|
||||
() => Math.max(0, ...items.map((item) => item.value)),
|
||||
[items],
|
||||
@@ -47,7 +50,7 @@ export function RankChart({
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{emptyMessage}
|
||||
{emptyMessage ?? t('noDistribution')}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import type { EChartsOption } from 'echarts';
|
||||
import ReactECharts from 'echarts-for-react';
|
||||
@@ -59,6 +61,7 @@ export function TrendChart({
|
||||
summaryScope = 'last-point',
|
||||
summaryHint,
|
||||
}: TrendChartProps) {
|
||||
const t = useTranslations('dataComponents');
|
||||
const option = useMemo<EChartsOption>(() => {
|
||||
const axisFormatter = yAxisValueFormatter ?? defaultFormatter;
|
||||
const maxValue = calculateNiceAxisMax(
|
||||
@@ -184,7 +187,7 @@ export function TrendChart({
|
||||
if (labels.length === 0 || series.length === 0) {
|
||||
return (
|
||||
<div className='flex h-[220px] items-center justify-center rounded-3xl border border-dashed bg-muted/30 text-sm text-muted-foreground'>
|
||||
暂无趋势数据
|
||||
{t('noTrend')}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user