feat: added translation support for non-english languages

This commit is contained in:
kangfenmao 2024-12-05 09:50:15 +08:00
parent c6dba95fbc
commit cbeb74d3dd
2 changed files with 16 additions and 11 deletions

View File

@ -53,7 +53,8 @@ const TranslateButton: FC<Props> = ({ text, onTranslated, disabled, style, isLoa
const message = getUserMessage({ const message = getUserMessage({
assistant, assistant,
topic: getDefaultTopic('default'), topic: getDefaultTopic('default'),
type: 'text' type: 'text',
content: text
}) })
const translatedText = await fetchTranslate({ message, assistant }) const translatedText = await fetchTranslate({ message, assistant })

View File

@ -35,7 +35,7 @@ interface Props {
const SettingsTab: FC<Props> = (props) => { const SettingsTab: FC<Props> = (props) => {
const { assistant, updateAssistantSettings, updateAssistant } = useAssistant(props.assistant.id) const { assistant, updateAssistantSettings, updateAssistant } = useAssistant(props.assistant.id)
const { messageStyle, codeStyle, fontSize } = useSettings() const { messageStyle, codeStyle, fontSize, language } = useSettings()
const [temperature, setTemperature] = useState(assistant?.settings?.temperature ?? DEFAULT_TEMPERATURE) const [temperature, setTemperature] = useState(assistant?.settings?.temperature ?? DEFAULT_TEMPERATURE)
const [contextCount, setContextCount] = useState(assistant?.settings?.contextCount ?? DEFAULT_CONTEXTCOUNT) const [contextCount, setContextCount] = useState(assistant?.settings?.contextCount ?? DEFAULT_CONTEXTCOUNT)
@ -330,15 +330,19 @@ const SettingsTab: FC<Props> = (props) => {
/> />
</SettingRow> </SettingRow>
<SettingDivider /> <SettingDivider />
<SettingRow> {!language.startsWith('en') && (
<SettingRowTitleSmall>{t('settings.input.auto_translate_with_space')}</SettingRowTitleSmall> <>
<Switch <SettingRow>
size="small" <SettingRowTitleSmall>{t('settings.input.auto_translate_with_space')}</SettingRowTitleSmall>
checked={autoTranslateWithSpace} <Switch
onChange={(checked) => dispatch(setAutoTranslateWithSpace(checked))} size="small"
/> checked={autoTranslateWithSpace}
</SettingRow> onChange={(checked) => dispatch(setAutoTranslateWithSpace(checked))}
<SettingDivider /> />
</SettingRow>
<SettingDivider />
</>
)}
<SettingRow> <SettingRow>
<SettingRowTitleSmall>{t('settings.messages.input.send_shortcuts')}</SettingRowTitleSmall> <SettingRowTitleSmall>{t('settings.messages.input.send_shortcuts')}</SettingRowTitleSmall>
<Select <Select