fix(web): optimize i18n name

This commit is contained in:
lcxadml
2024-02-21 10:39:32 +08:00
committed by GitHub
parent 32e1554282
commit 02abcb7218
32 changed files with 72 additions and 52 deletions

View File

@@ -207,7 +207,18 @@ const en = {
available_resources: ' Available Resources',
edit_new_applications: 'Edit new applications',
collect: 'Collect',
create: '创建',
collected: 'Collected',
create: 'Create',
Agents: 'Agents',
edit_application: 'edit application',
add_application: 'add application',
app_name: 'App Name',
LLM_strategy: 'LLM Strategy',
LLM_strategy_value: 'LLM Strategy Value',
resource: 'Resource',
operators: 'Operators',
Chinese: 'Chinese',
English: 'English',
} as const;
export type I18nKeys = keyof typeof en;
@@ -413,6 +424,7 @@ const zh: Resources['translation'] = {
add_resource: '添加资源',
team_modal: '工作模式',
App: '应用程序',
resource: '资源',
resource_name: '资源名',
resource_type: '资源类型',
resource_value: '参数',
@@ -421,7 +433,17 @@ const zh: Resources['translation'] = {
available_resources: '可用资源',
edit_new_applications: '编辑新的应用',
collect: '收藏',
collected: '已收藏',
create: '创建',
Agents: '智能体',
edit_application: '编辑应用',
add_application: '添加应用',
app_name: '应用名称',
LLM_strategy: '模型策略',
LLM_strategy_value: '模型策略参数',
operators: '算子',
Chinese: '中文',
English: '英文',
} as const;
i18n.use(initReactI18next).init({

View File

@@ -1,6 +1,5 @@
import { apiInterceptors, getAppStrategy, getAppStrategyValues, getResource } from '@/client/api';
import { Button, Card, Divider, Input, Select } from 'antd';
import { log } from 'console';
import { Button, Input, Select } from 'antd';
import React, { useEffect, useMemo, useState } from 'react';
import ResourceCard from './resource-card';
import { useTranslation } from 'react-i18next';
@@ -90,7 +89,7 @@ export default function AgentPanel(props: IProps) {
return (
<div>
<div className="flex items-center mb-6 mt-6">
<div className="mr-2 w-16 text-center">Prompt:</div>
<div className="mr-2 w-16 text-center">{t('Prompt')}:</div>
<Input
required
className="mr-6 w-1/4"
@@ -99,7 +98,7 @@ export default function AgentPanel(props: IProps) {
updateAgent(e.target.value, 'prompt_template');
}}
/>
<div className="mr-2">LLM Strategy:</div>
<div className="mr-2">{t('LLM_strategy')}:</div>
<Select
value={agent.llm_strategy}
options={strategyOptions}
@@ -111,7 +110,7 @@ export default function AgentPanel(props: IProps) {
/>
{strategyValueOptions && strategyValueOptions.length > 0 && (
<>
<div className="mr-2">LLM Strategy Value:</div>
<div className="mr-2">{t('LLM_strategy_value')}:</div>
<Select
value={formatStrategyValue(agent.llm_strategy_value)}
className="w-1/4"

View File

@@ -17,11 +17,6 @@ interface IProps {
const { confirm } = Modal;
const languageMap = {
en: '英文',
zh: '中文',
};
export default function AppCard(props: IProps) {
const { updateApps, app, handleEdit, isCollected } = props;
const { model } = useContext(ChatContext);
@@ -32,6 +27,11 @@ export default function AppCard(props: IProps) {
const { t } = useTranslation();
const languageMap = {
en: t('English'),
zh: t('Chinese'),
};
const showDeleteConfirm = () => {
confirm({
title: t('Tips'),

View File

@@ -33,11 +33,6 @@ interface IProps {
app?: any;
}
const languageOptions = [
{ value: 'zh', label: '中文' },
{ value: 'en', label: '英文' },
];
type TeamModals = 'awel_layout' | 'singe_agent' | 'auto_plan';
export default function AppModal(props: IProps) {
@@ -56,6 +51,11 @@ export default function AppModal(props: IProps) {
const [form] = Form.useForm();
const languageOptions = [
{ value: 'zh', label: t('Chinese') },
{ value: 'en', label: t('English') },
];
const onChange = (newActiveKey: string) => {
setActiveKey(newActiveKey);
};
@@ -302,7 +302,7 @@ export default function AppModal(props: IProps) {
<div>
<Modal
okText={t('Submit')}
title={type === 'edit' ? 'edit application' : 'add application'}
title={type === 'edit' ? t('edit_application') : t('add_application')}
open={open}
width={'65%'}
onCancel={handleCancel}
@@ -327,7 +327,7 @@ export default function AppModal(props: IProps) {
autoComplete="off"
onFinish={handleSubmit}
>
<Form.Item<FieldType> label={'App Name'} name="app_name" rules={[{ required: true, message: t('Please_input_the_name') }]}>
<Form.Item<FieldType> label={t('app_name')} name="app_name" rules={[{ required: true, message: t('Please_input_the_name') }]}>
<Input placeholder={t('Please_input_the_name')} />
</Form.Item>
<Form.Item<FieldType>
@@ -353,7 +353,7 @@ export default function AppModal(props: IProps) {
</div>
{curTeamModal !== 'awel_layout' ? (
<>
<div className="mb-5">Agents</div>
<div className="mb-5">{t('Agents')}</div>
<Tabs addIcon={renderAddIcon()} type="editable-card" onChange={onChange} activeKey={activeKey} onEdit={onEdit} items={agents} />
</>
) : (

View File

@@ -68,7 +68,7 @@ export default function ResourceCard(props: IProps) {
return (
<Card
className="mb-3 dark:bg-[#232734] border-gray-200"
title={`Resource ${index + 1}`}
title={`${t('resource')} ${index + 1}`}
extra={
<DeleteFilled
className="text-[#ff1b2e] !text-lg"

View File

@@ -100,14 +100,14 @@ const AddNodes: React.FC = () => {
<div className="w-[320px] overflow-hidden overflow-y-auto scrollbar-default">
<p className="my-2 font-bold">{t('add_node')}</p>
<Search placeholder="Search node" onSearch={searchNode} />
<h2 className="my-2 ml-2 font-semibold">Operatos</h2>
<h2 className="my-2 ml-2 font-semibold">{t('operators')}</h2>
<Collapse
className="max-h-[300px] overflow-hidden overflow-y-auto scrollbar-default"
size="small"
defaultActiveKey={['']}
items={operatorItems}
/>
<h2 className="my-2 ml-2 font-semibold">Resources</h2>
<h2 className="my-2 ml-2 font-semibold">{t('resource')}</h2>
<Collapse
className="max-h-[300px] overflow-hidden overflow-y-auto scrollbar-default"
size="small"

9
web/package-lock.json generated
View File

@@ -9067,9 +9067,8 @@
},
"node_modules/remark-gfm": {
"version": "3.0.1",
"resolved": "https://registry.npm.alibaba-inc.com/remark-gfm/download/remark-gfm-3.0.1.tgz",
"integrity": "sha1-CxgPCV4wNlRend2sDo3z+lz+5U8=",
"license": "MIT",
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz",
"integrity": "sha512-lEFDoi2PICJyNrACFOfDD3JlLkuSbOa5Wd8EPt06HUdptv8Gn0bxYTdbU/XXQ3swAPkEaGxxPN9cbnMHvVu1Ig==",
"dependencies": {
"@types/mdast": "^3.0.0",
"mdast-util-gfm": "^2.0.0",
@@ -17425,8 +17424,8 @@
},
"remark-gfm": {
"version": "3.0.1",
"resolved": "https://registry.npm.alibaba-inc.com/remark-gfm/download/remark-gfm-3.0.1.tgz",
"integrity": "sha1-CxgPCV4wNlRend2sDo3z+lz+5U8=",
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz",
"integrity": "sha512-lEFDoi2PICJyNrACFOfDD3JlLkuSbOa5Wd8EPt06HUdptv8Gn0bxYTdbU/XXQ3swAPkEaGxxPN9cbnMHvVu1Ig==",
"requires": {
"@types/mdast": "^3.0.0",
"mdast-util-gfm": "^2.0.0",

View File

@@ -89,12 +89,12 @@ export default function App() {
const items: TabsProps['items'] = [
{
key: 'app',
label: 'App',
label: t('App'),
children: renderAppList({ isCollected: false }),
},
{
key: 'collected',
label: 'Collected',
label: t('collected'),
children: renderAppList({ isCollected: true }),
},
];