perf: unify i18n text class in frontend

This commit is contained in:
Junyan Qin
2025-05-20 11:32:55 +08:00
parent ff335130ae
commit 7d34a2154b
5 changed files with 20 additions and 24 deletions
+5 -5
View File
@@ -2,7 +2,7 @@
import { ReactNode } from 'react';
import '@/i18n';
import { I18nText } from '@/app/infra/entities/api';
import { I18nLabel } from '@/app/infra/entities/common';
interface I18nProviderProps {
children: ReactNode;
@@ -11,10 +11,10 @@ interface I18nProviderProps {
export default function I18nProvider({ children }: I18nProviderProps) {
return <>{children}</>;
}
export function i18nObj(i18nText: I18nText): string {
export function i18nObj(i18nLabel: I18nLabel): string {
const language = localStorage.getItem('langbot_language');
if ((language === 'zh-Hans' && i18nText.zh_Hans) || !i18nText.en_US) {
return i18nText.zh_Hans;
if ((language === 'zh-Hans' && i18nLabel.zh_Hans) || !i18nLabel.en_US) {
return i18nLabel.zh_Hans;
}
return i18nText.en_US;
return i18nLabel.en_US;
}