Skip to content

Commit

Permalink
313国际化
Browse files Browse the repository at this point in the history
  • Loading branch information
QwQ-wuwuwu committed Jun 18, 2024
1 parent 419443b commit 629e6d4
Show file tree
Hide file tree
Showing 8 changed files with 320 additions and 222 deletions.
48 changes: 45 additions & 3 deletions src/frontend/public/locales/en/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@
"maximum": "Up to",
"perMinute": "simultaneous online sessions",
"changeTime": "Modification Time",
"deleteGroup": "After deletion 【{{name}}】 will no longer exist, Do you want to delete it?"
"deleteGroup": "After deletion 【{{name}}】 will no longer exist, Do you want to delete it?",
"currentGroup": "Current UserGroup",
"defaultGroup": "DefaultGroup"
},
"skills": {
"manageTemplate": "Manage Skill Templates",
Expand Down Expand Up @@ -478,7 +480,7 @@
"skillsReplaced": "Skills replaced",
"allReplaced": "All replaced",
"basicConfiguration": "Basic configuration",
"modelConfiguration": "AI Model configuration",
"modelConfiguration": "AI Model Configuration",
"model": "Model",
"temperature": "Temperature",
"openingIntroduction": "Opening Introduction",
Expand Down Expand Up @@ -522,7 +524,28 @@
"cancel": "Cancel",
"confirm": "Confirm",
"forBetter": "For better assistant effect, the description needs to be greater than 20 words",
"forExample": "For example, the identity of an assistant, specific methods and steps for completing tasks, tone of voice when answering questions, and what issues to pay attention to, etc"
"forExample": "For example, the identity of an assistant, specific methods and steps for completing tasks, tone of voice when answering questions, and what issues to pay attention to, etc",
"contentSecurityR": "Content Security Review",
"errors": {
"selectAtLeastOneWordType": "At least one word type must be selected",
"autoReplyNotEmpty": "Auto-reply content cannot be empty"
},
"saveSuccess": "Saved successfully",
"contentSecurity": "Content Security",
"contentSecurityDesc": "Review session content for safety with a sensitive word list or API",
"contentSecuritySettings": "Content Security Review Settings",
"enableContentSecurityReview": "Enable Content Security Review",
"reviewType": "Review Type",
"sensitiveWordListMatch": "Sensitive Word List Match",
"modelReview": "Model Review",
"wordListType": "Word List Type",
"builtinWordList": "Built-in Word List",
"customWordList": "Custom Word List",
"autoReplyContent": "Auto-reply Content",
"useNewlineToSeparate": "Use newline to separate, each line one item",
"txtFile": "txt file",
"sensitiveWordMatch": "Sensitive Word Match",
"defaultAutoReply": "Enter the auto-reply content for when the safety review is triggered, e.g., 'The current conversation content violates relevant regulations, please modify and re-enter.'"
},
"tools": {
"addTool": "Add Tool",
Expand Down Expand Up @@ -583,5 +606,24 @@
"resetButton": "Reset Password",
"passwordResetSuccess": "Your password has been successfully reset.",
"resetFailed": "Pwd Reset Failed"
},
"log": {
"auditManagement": "Audit Management",
"searchButton": "Search",
"resetButton": "Reset",
"auditId": "Audit ID",
"username": "Username",
"operationTime": "Operation Time",
"systemModule": "System Module",
"operationAction": "Operation Action",
"objectType": "Operation Object Type",
"operationObject": "Operation Object",
"ipAddress": "IP Address",
"remark": "Remark",
"selectUser": "Select User",
"selectUserGroup": "Select User Group",
"startDate": "Start Date",
"endDate": "End Date",
"actionBehavior": "Action Behavior"
}
}
46 changes: 44 additions & 2 deletions src/frontend/public/locales/zh/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
"maximum": "最多",
"perMinute": "个同时在线会话",
"changeTime": "修改时间",
"deleteGroup": "删除后 【{{name}}】 将不再存在,是否删除?"
"deleteGroup": "删除后 【{{name}}】 将不再存在,是否删除?",
"currentGroup": "当前用户组",
"defaultGroup": "默认用户组"
},
"skills": {
"manageTemplate": "管理技能模板",
Expand Down Expand Up @@ -519,7 +521,28 @@
"cancel": "取消",
"confirm": "确认",
"forBetter": "为了更好的助手效果,描述需要大于20 个字",
"forExample": "例如助手的身份、完成任务的具体方法和步骤、回答问题时的语气以及应该注意什么问题等"
"forExample": "例如助手的身份、完成任务的具体方法和步骤、回答问题时的语气以及应该注意什么问题等",
"contentSecurityR": "内容安全审查",
"errors": {
"selectAtLeastOneWordType": "词表至少需要选择一个",
"autoReplyNotEmpty": "自动回复内容不可为空"
},
"saveSuccess": "保存成功",
"contentSecurity": "内容安全",
"contentSecurityDesc": "通过敏感词表或 API 对会话内容进行安全审查",
"contentSecuritySettings": "内容安全审查设置",
"enableContentSecurityReview": "开启内容安全审查",
"reviewType": "审查类型",
"sensitiveWordListMatch": "敏感词表匹配",
"modelReview": "模型审查",
"wordListType": "词表类型",
"builtinWordList": "内置词表",
"customWordList": "自定义词表",
"autoReplyContent": "自动回复内容",
"useNewlineToSeparate": "使用换行符进行分隔,每行一个",
"txtFile": "txt文件",
"sensitiveWordMatch": "敏感词匹配",
"defaultAutoReply": "填写命中安全审查时的自动回复内容,例如“当前对话内容违反相关规范,请修改后重新输入。"
},
"tools": {
"addTool": "添加工具",
Expand Down Expand Up @@ -580,5 +603,24 @@
"resetButton": "重置密码",
"passwordResetSuccess": "您的密码已成功重置。",
"resetFailed": "密码重置失败"
},
"log": {
"auditManagement": "审计管理",
"searchButton": "查询",
"resetButton": "重置",
"auditId": "审计ID",
"username": "用户名",
"operationTime": "操作时间",
"systemModule": "系统模块",
"operationAction": "操作行为",
"objectType": "操作对象类型",
"operationObject": "操作对象",
"ipAddress": "IP地址",
"remark": "备注",
"selectUser": "选择用户",
"selectUserGroup": "选择用户组",
"startDate": "开始日期",
"endDate": "结束日期",
"actionBehavior": "操作行为"
}
}
134 changes: 68 additions & 66 deletions src/frontend/src/components/Pro/security/AssistantSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,88 +12,90 @@ import { QuestionMarkCircledIcon } from "@radix-ui/react-icons";
import { Tooltip, TooltipProvider, TooltipContent, TooltipTrigger } from "@/components/bs-ui/tooltip";

export default function AssistantSetting({ id, type }) {

const { t } = useTranslation()
const { t } = useTranslation();

const [open, setOpen] = useState(false);
const { toast, message } = useToast()
const { toast, message } = useToast();
const [form, setForm] = useState({
isCheck: false,
autoReply: "",
words: "",
wordsType: [],
})
});

// load
useEffect(() => {
id !== 3 && getSensitiveApi(id, type).then(res => {
const { is_check, auto_reply, words, words_type } = res
setForm({
isCheck: !!is_check,
autoReply: auto_reply,
words,
wordsType: Array.isArray(words_type) ? words_type : [words_type],
})
})
}, [id])

if (id !== 3) {
getSensitiveApi(id, type).then(res => {
const { is_check, auto_reply, words, words_type } = res;
setForm({
isCheck: !!is_check,
autoReply: auto_reply,
words,
wordsType: Array.isArray(words_type) ? words_type : [words_type],
});
});
}
}, [id, type]);

const handleFormChange = async (_form) => {
const errors = []
if (_form.wordsType.length === 0) errors.push('词表至少需要选择一个')
if (_form.autoReply === '') errors.push('自动回复内容不可为空')
const errors = [];
if (_form.wordsType.length === 0) errors.push(t('build.errors.selectAtLeastOneWordType'));
if (_form.autoReply === '') errors.push(t('build.errors.autoReplyNotEmpty'));
if (errors.length) {
return toast({ title: t('prompt'), variant: 'error', description: errors })
return toast({ title: t('prompt'), variant: 'error', description: errors.join(', ') });
}

setForm(_form)
await sensitiveSaveApi({ ..._form, id, type })
message({ title: t('prompt'), variant: 'success', description: '保存成功' })
}
setForm(_form);
await sensitiveSaveApi({ ..._form, id, type });
message({ title: t('prompt'), variant: 'success', description: t('build.saveSuccess') });
};

const onOff = (bln) => {
setForm({ ...form, isCheck: bln })
sensitiveSaveApi({ ...form, isCheck: bln, id, type })
if (bln) setOpen(true)
}
setForm({ ...form, isCheck: bln });
sensitiveSaveApi({ ...form, isCheck: bln, id, type });
if (bln) setOpen(true);
};

return <AccordionItem value="item-3">
<AccordionTrigger>
<div className="flex flex-1 items-center justify-between">
<div className="flex items-center space-x-2">
<span>内容安全审查</span>
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger>
<QuestionMarkCircledIcon />
</TooltipTrigger>
<TooltipContent>
<p>通过敏感词表或 API 对会话内容进行安全审查</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
<div className="h-[20px] flex items-center">
<Sheet open={open} onOpenChange={(bln) => setOpen(bln)}>
<SheetTrigger>
{form.isCheck && <SettingIcon onClick={(e) => { e.stopPropagation(); setOpen(!open) }} className="w-[32px] h-[32px]" />}
</SheetTrigger>
<SheetContent className="w-[500px]" onClick={(e) => e.stopPropagation()}>
<SheetTitle className="font-[500] pl-3 pt-2">内容安全审查设置</SheetTitle>
<FormSet data={form} onChange={handleFormChange} onSave={() => setOpen(false)} onCancel={() => setOpen(false)} />
</SheetContent>
</Sheet>
<Switch
className="mx-4"
onClick={(e) => e.stopPropagation()}
checked={form.isCheck}
onCheckedChange={onOff}
/>
return (
<AccordionItem value="item-3">
<AccordionTrigger>
<div className="flex flex-1 items-center justify-between">
<div className="flex items-center space-x-2">
<span>{t('build.contentSecurityR')}</span>
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger>
<QuestionMarkCircledIcon />
</TooltipTrigger>
<TooltipContent>
<p>{t('build.contentSecurityDesc')}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
<div className="h-[20px] flex items-center">
<Sheet open={open} onOpenChange={(bln) => setOpen(bln)}>
<SheetTrigger>
{form.isCheck && <SettingIcon onClick={(e) => { e.stopPropagation(); setOpen(!open) }} className="w-[32px] h-[32px]" />}
</SheetTrigger>
<SheetContent className="w-[500px]" onClick={(e) => e.stopPropagation()}>
<SheetTitle className="font-[500] pl-3 pt-2">{t('build.contentSecuritySettings')}</SheetTitle>
<FormSet data={form} onChange={handleFormChange} onSave={() => setOpen(false)} onCancel={() => setOpen(false)} />
</SheetContent>
</Sheet>
<Switch
className="mx-4"
onClick={(e) => e.stopPropagation()}
checked={form.isCheck}
onCheckedChange={onOff}
/>
</div>
</div>
</div>
</AccordionTrigger>
<AccordionContent className="mb-[-16px]">
{form.isCheck && <FormView data={form} />}
</AccordionContent>
</AccordionItem>
};
</AccordionTrigger>
<AccordionContent className="mb-[-16px]">
{form.isCheck && <FormView data={form} />}
</AccordionContent>
</AccordionItem>
);
}

0 comments on commit 629e6d4

Please sign in to comment.