mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-17 16:00:59 +00:00
perf: unify i18n text class in frontend
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import styles from './HomeSidebar.module.css';
|
import styles from './HomeSidebar.module.css';
|
||||||
import { I18nText } from '@/app/infra/entities/api';
|
import { I18nLabel } from '@/app/infra/entities/common';
|
||||||
|
|
||||||
export interface ISidebarChildVO {
|
export interface ISidebarChildVO {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -7,7 +7,7 @@ export interface ISidebarChildVO {
|
|||||||
name: string;
|
name: string;
|
||||||
route: string;
|
route: string;
|
||||||
description: string;
|
description: string;
|
||||||
helpLink: I18nText;
|
helpLink: I18nLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SidebarChildVO {
|
export class SidebarChildVO {
|
||||||
@@ -16,7 +16,7 @@ export class SidebarChildVO {
|
|||||||
name: string;
|
name: string;
|
||||||
route: string;
|
route: string;
|
||||||
description: string;
|
description: string;
|
||||||
helpLink: I18nText;
|
helpLink: I18nLabel;
|
||||||
|
|
||||||
constructor(props: ISidebarChildVO) {
|
constructor(props: ISidebarChildVO) {
|
||||||
this.id = props.id;
|
this.id = props.id;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { i18nObj } from '@/i18n/I18nProvider';
|
import { i18nObj } from '@/i18n/I18nProvider';
|
||||||
import styles from './HomeTittleBar.module.css';
|
import styles from './HomeTittleBar.module.css';
|
||||||
import { I18nText } from '@/app/infra/entities/api';
|
import { I18nLabel } from '@/app/infra/entities/common';
|
||||||
|
|
||||||
export default function HomeTitleBar({
|
export default function HomeTitleBar({
|
||||||
title,
|
title,
|
||||||
@@ -9,7 +9,7 @@ export default function HomeTitleBar({
|
|||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
subtitle: string;
|
subtitle: string;
|
||||||
helpLink: I18nText;
|
helpLink: I18nLabel;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className={`${styles.titleBarContainer}`}>
|
<div className={`${styles.titleBarContainer}`}>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import HomeSidebar from '@/app/home/components/home-sidebar/HomeSidebar';
|
|||||||
import HomeTitleBar from '@/app/home/components/home-titlebar/HomeTitleBar';
|
import HomeTitleBar from '@/app/home/components/home-titlebar/HomeTitleBar';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { SidebarChildVO } from '@/app/home/components/home-sidebar/HomeSidebarChild';
|
import { SidebarChildVO } from '@/app/home/components/home-sidebar/HomeSidebarChild';
|
||||||
import { I18nText } from '@/app/infra/entities/api';
|
import { I18nLabel } from '@/app/infra/entities/common';
|
||||||
|
|
||||||
export default function HomeLayout({
|
export default function HomeLayout({
|
||||||
children,
|
children,
|
||||||
@@ -14,7 +14,7 @@ export default function HomeLayout({
|
|||||||
}>) {
|
}>) {
|
||||||
const [title, setTitle] = useState<string>('');
|
const [title, setTitle] = useState<string>('');
|
||||||
const [subtitle, setSubtitle] = useState<string>('');
|
const [subtitle, setSubtitle] = useState<string>('');
|
||||||
const [helpLink, setHelpLink] = useState<I18nText>({
|
const [helpLink, setHelpLink] = useState<I18nLabel>({
|
||||||
en_US: '',
|
en_US: '',
|
||||||
zh_Hans: '',
|
zh_Hans: '',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { IDynamicFormItemSchema } from '@/app/infra/entities/form/dynamic';
|
import { IDynamicFormItemSchema } from '@/app/infra/entities/form/dynamic';
|
||||||
import { PipelineConfigTab } from '@/app/infra/entities/pipeline';
|
import { PipelineConfigTab } from '@/app/infra/entities/pipeline';
|
||||||
|
import { I18nLabel } from '@/app/infra/entities/common';
|
||||||
|
|
||||||
export interface ApiResponse<T> {
|
export interface ApiResponse<T> {
|
||||||
code: number;
|
code: number;
|
||||||
@@ -7,11 +8,6 @@ export interface ApiResponse<T> {
|
|||||||
msg: string;
|
msg: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface I18nText {
|
|
||||||
en_US: string;
|
|
||||||
zh_Hans: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AsyncTaskCreatedResp {
|
export interface AsyncTaskCreatedResp {
|
||||||
task_id: number;
|
task_id: number;
|
||||||
}
|
}
|
||||||
@@ -26,8 +22,8 @@ export interface ApiRespProviderRequester {
|
|||||||
|
|
||||||
export interface Requester {
|
export interface Requester {
|
||||||
name: string;
|
name: string;
|
||||||
label: I18nText;
|
label: I18nLabel;
|
||||||
description: I18nText;
|
description: I18nLabel;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
spec: {
|
spec: {
|
||||||
config: IDynamicFormItemSchema[];
|
config: IDynamicFormItemSchema[];
|
||||||
@@ -84,8 +80,8 @@ export interface ApiRespPlatformAdapter {
|
|||||||
|
|
||||||
export interface Adapter {
|
export interface Adapter {
|
||||||
name: string;
|
name: string;
|
||||||
label: I18nText;
|
label: I18nLabel;
|
||||||
description: I18nText;
|
description: I18nLabel;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
spec: {
|
spec: {
|
||||||
config: AdapterSpecConfig[];
|
config: AdapterSpecConfig[];
|
||||||
@@ -94,7 +90,7 @@ export interface Adapter {
|
|||||||
|
|
||||||
export interface AdapterSpecConfig {
|
export interface AdapterSpecConfig {
|
||||||
default: string | number | boolean | Array<unknown>;
|
default: string | number | boolean | Array<unknown>;
|
||||||
label: I18nText;
|
label: I18nLabel;
|
||||||
name: string;
|
name: string;
|
||||||
required: boolean;
|
required: boolean;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -133,8 +129,8 @@ export interface ApiRespPlugin {
|
|||||||
export interface Plugin {
|
export interface Plugin {
|
||||||
author: string;
|
author: string;
|
||||||
name: string;
|
name: string;
|
||||||
description: I18nText;
|
description: I18nLabel;
|
||||||
label: I18nText;
|
label: I18nLabel;
|
||||||
version: string;
|
version: string;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
priority: number;
|
priority: number;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import '@/i18n';
|
import '@/i18n';
|
||||||
import { I18nText } from '@/app/infra/entities/api';
|
import { I18nLabel } from '@/app/infra/entities/common';
|
||||||
|
|
||||||
interface I18nProviderProps {
|
interface I18nProviderProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -11,10 +11,10 @@ interface I18nProviderProps {
|
|||||||
export default function I18nProvider({ children }: I18nProviderProps) {
|
export default function I18nProvider({ children }: I18nProviderProps) {
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
export function i18nObj(i18nText: I18nText): string {
|
export function i18nObj(i18nLabel: I18nLabel): string {
|
||||||
const language = localStorage.getItem('langbot_language');
|
const language = localStorage.getItem('langbot_language');
|
||||||
if ((language === 'zh-Hans' && i18nText.zh_Hans) || !i18nText.en_US) {
|
if ((language === 'zh-Hans' && i18nLabel.zh_Hans) || !i18nLabel.en_US) {
|
||||||
return i18nText.zh_Hans;
|
return i18nLabel.zh_Hans;
|
||||||
}
|
}
|
||||||
return i18nText.en_US;
|
return i18nLabel.en_US;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user