mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-11-16 23:04:24 +08:00
fix(i18n): use English runtime text and localize system UI
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { isLogStorageDisabledMessage } from './log-storage-error';
|
||||
import {
|
||||
BarChart3,
|
||||
Globe,
|
||||
@@ -117,7 +118,7 @@ export function AccessAnalytics() {
|
||||
const errorInstance =
|
||||
err instanceof Error ? err : new Error(t('fetchFailed'));
|
||||
const errMsg = errorInstance.message || '';
|
||||
if (errMsg.includes('ClickHouse') || errMsg.includes('未启用')) {
|
||||
if (isLogStorageDisabledMessage(errMsg)) {
|
||||
setClickhouseDisabled(true);
|
||||
} else {
|
||||
setError(errorInstance);
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
'use client';
|
||||
|
||||
import { useMemo, useState } from 'react';
|
||||
import { isLogStorageDisabledMessage } from './log-storage-error';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { toast } from 'sonner';
|
||||
import { format } from 'date-fns';
|
||||
@@ -94,7 +95,7 @@ function statusVariant(status: number) {
|
||||
|
||||
function isClickhouseDisabledError(error: Error) {
|
||||
const errMsg = error.message || '';
|
||||
return errMsg.includes('ClickHouse') || errMsg.includes('未启用');
|
||||
return isLogStorageDisabledMessage(errMsg);
|
||||
}
|
||||
|
||||
export function AccessLogs() {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { getRuntimeTranslator } from '@/i18n/runtime';
|
||||
|
||||
export function isLogStorageDisabledMessage(message: string): boolean {
|
||||
const normalized = message.toLowerCase();
|
||||
return (
|
||||
message.includes('ClickHouse') ||
|
||||
(['en', 'zh-CN'] as const).some((locale) =>
|
||||
normalized.includes(
|
||||
getRuntimeTranslator(locale)('disabled_f95ea7f4').toLowerCase(),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user