Skip to content

Commit a069169

Browse files
committed
♻️ refactor: refactor api key form locale
1 parent 02c4a75 commit a069169

File tree

26 files changed

+441
-955
lines changed

26 files changed

+441
-955
lines changed

src/app/settings/llm/Azure/index.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const useStyles = createStyles(({ css, token }) => ({
2828
const providerKey = ModelProvider.Azure;
2929

3030
const AzureOpenAIProvider = memo(() => {
31-
const { t } = useTranslation('setting');
31+
const { t } = useTranslation('modelProvider');
3232

3333
const { styles } = useStyles();
3434

@@ -50,17 +50,17 @@ const AzureOpenAIProvider = memo(() => {
5050
children: (
5151
<Input.Password
5252
autoComplete={'new-password'}
53-
placeholder={t('llm.azure.token.placeholder')}
53+
placeholder={t('azure.token.placeholder')}
5454
/>
5555
),
56-
desc: t('llm.azure.token.desc'),
57-
label: t('llm.azure.token.title'),
56+
desc: t('azure.token.desc'),
57+
label: t('azure.token.title'),
5858
name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
5959
},
6060
{
61-
children: <Input allowClear placeholder={t('llm.azure.endpoint.placeholder')} />,
62-
desc: t('llm.azure.endpoint.desc'),
63-
label: t('llm.azure.endpoint.title'),
61+
children: <Input allowClear placeholder={t('azure.endpoint.placeholder')} />,
62+
desc: t('azure.endpoint.desc'),
63+
label: t('azure.endpoint.title'),
6464
name: [LLMProviderConfigKey, providerKey, LLMProviderBaseUrlKey],
6565
},
6666
{
@@ -79,18 +79,18 @@ const AzureOpenAIProvider = memo(() => {
7979
),
8080
desc: (
8181
<Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
82-
{t('llm.azure.azureApiVersion.desc')}
82+
{t('azure.azureApiVersion.desc')}
8383
</Markdown>
8484
),
85-
label: t('llm.azure.azureApiVersion.title'),
85+
label: t('azure.azureApiVersion.title'),
8686
name: [LLMProviderConfigKey, providerKey, 'apiVersion'],
8787
},
8888
]}
8989
checkModel={checkModel}
9090
modelList={{
9191
azureDeployName: true,
92-
notFoundContent: t('llm.azure.empty'),
93-
placeholder: t('llm.azure.modelListPlaceholder'),
92+
notFoundContent: t('azure.empty'),
93+
placeholder: t('azure.modelListPlaceholder'),
9494
}}
9595
provider={providerKey}
9696
title={

src/app/settings/llm/Bedrock/index.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { LLMProviderConfigKey } from '../const';
1313
const providerKey: GlobalLLMProviderKey = 'bedrock';
1414

1515
const BedrockProvider = memo(() => {
16-
const { t } = useTranslation('setting');
16+
const { t } = useTranslation('modelProvider');
1717

1818
return (
1919
<ProviderConfig
@@ -22,22 +22,22 @@ const BedrockProvider = memo(() => {
2222
children: (
2323
<Input.Password
2424
autoComplete={'new-password'}
25-
placeholder={t(`llm.${providerKey}.accessKeyId.placeholder`)}
25+
placeholder={t(`${providerKey}.accessKeyId.placeholder`)}
2626
/>
2727
),
28-
desc: t(`llm.${providerKey}.accessKeyId.desc`),
29-
label: t(`llm.${providerKey}.accessKeyId.title`),
28+
desc: t(`${providerKey}.accessKeyId.desc`),
29+
label: t(`${providerKey}.accessKeyId.title`),
3030
name: [LLMProviderConfigKey, providerKey, 'accessKeyId'],
3131
},
3232
{
3333
children: (
3434
<Input.Password
3535
autoComplete={'new-password'}
36-
placeholder={t(`llm.${providerKey}.secretAccessKey.placeholder`)}
36+
placeholder={t(`${providerKey}.secretAccessKey.placeholder`)}
3737
/>
3838
),
39-
desc: t(`llm.${providerKey}.secretAccessKey.desc`),
40-
label: t(`llm.${providerKey}.secretAccessKey.title`),
39+
desc: t(`${providerKey}.secretAccessKey.desc`),
40+
label: t(`${providerKey}.secretAccessKey.title`),
4141
name: [LLMProviderConfigKey, providerKey, 'secretAccessKey'],
4242
},
4343
{
@@ -51,8 +51,8 @@ const BedrockProvider = memo(() => {
5151
placeholder={'us-east-1'}
5252
/>
5353
),
54-
desc: t(`llm.${providerKey}.region.desc`),
55-
label: t(`llm.${providerKey}.region.title`),
54+
desc: t(`${providerKey}.region.desc`),
55+
label: t(`${providerKey}.region.title`),
5656
name: [LLMProviderConfigKey, providerKey, 'region'],
5757
},
5858
]}

src/app/settings/llm/Ollama/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const OllamaProvider = memo(() => {
1616
<ProviderConfig
1717
checkerItem={{
1818
children: <Checker />,
19-
desc: t('llm.ollama.checker.desc'),
19+
desc: t('llm.checker.ollamaDesc'),
2020
label: t('llm.checker.title'),
2121
minWidth: undefined,
2222
}}

src/app/settings/llm/components/ProviderConfig/index.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const ProviderConfig = memo<ProviderConfigProps>(
4949
modelList,
5050
}) => {
5151
const { t } = useTranslation('setting');
52+
const { t: modelT } = useTranslation('modelProvider');
5253
const [form] = AntForm.useForm();
5354
const [toggleProviderEnabled, setSettings, enabled] = useGlobalStore((s) => [
5455
s.toggleProviderEnabled,
@@ -65,11 +66,11 @@ const ProviderConfig = memo<ProviderConfigProps>(
6566
children: (
6667
<Input.Password
6768
autoComplete={'new-password'}
68-
placeholder={t(`llm.${provider}.token.placeholder` as any)}
69+
placeholder={modelT(`${provider}.token.placeholder` as any)}
6970
/>
7071
),
71-
desc: t(`llm.${provider}.token.desc` as any),
72-
label: t(`llm.${provider}.token.title` as any),
72+
desc: modelT(`${provider}.token.desc` as any),
73+
label: modelT(`${provider}.token.title` as any),
7374
name: [LLMProviderConfigKey, provider, LLMProviderApiTokenKey],
7475
},
7576
];
@@ -78,10 +79,10 @@ const ProviderConfig = memo<ProviderConfigProps>(
7879
...apiKeyItem,
7980
showEndpoint && {
8081
children: (
81-
<Input allowClear placeholder={t(`llm.${provider}.endpoint.placeholder` as any)} />
82+
<Input allowClear placeholder={modelT(`${provider}.endpoint.placeholder` as any)} />
8283
),
83-
desc: t(`llm.${provider}.endpoint.desc` as any),
84-
label: t(`llm.${provider}.endpoint.title` as any),
84+
desc: modelT(`${provider}.endpoint.desc` as any),
85+
label: modelT(`${provider}.endpoint.title` as any),
8586
name: [LLMProviderConfigKey, provider, LLMProviderBaseUrlKey],
8687
},
8788
{

src/app/settings/tts/TTS/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const TTS = memo(() => {
5757
},
5858
],
5959
icon: Webhook,
60-
title: t('llm.openai.title'),
60+
title: t('settingTTS.openai.title'),
6161
};
6262

6363
return (

src/components/ModelSelect/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ interface ProviderItemRenderProps {
139139
}
140140

141141
export const ProviderItemRender = memo<ProviderItemRenderProps>(({ provider }) => {
142-
const { t } = useTranslation('common');
142+
const { t } = useTranslation('modelProvider');
143143

144144
return (
145145
<Flexbox align={'center'} gap={4} horizontal>
146146
<ModelProviderIcon provider={provider} />
147-
{t(`modelProvider.${provider}` as any)}
147+
{t(`${provider}.title` as any)}
148148
</Flexbox>
149149
);
150150
});

src/features/Conversation/Error/APIKeyForm/Anthropic.tsx

-40
This file was deleted.

src/features/Conversation/Error/APIKeyForm/Bedrock.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { modelConfigSelectors } from '@/store/global/selectors';
1313
import { FormAction } from '../style';
1414

1515
const BedrockForm = memo(() => {
16-
const { t } = useTranslation('error');
16+
const { t } = useTranslation('modelProvider');
1717
const [showRegion, setShow] = useState(false);
1818

1919
const [accessKeyId, secretAccessKey, region, setConfig] = useGlobalStore((s) => [
@@ -27,8 +27,8 @@ const BedrockForm = memo(() => {
2727
return (
2828
<FormAction
2929
avatar={<Aws.Color color={theme.colorText} size={56} />}
30-
description={t('unlock.apikey.Bedrock.description')}
31-
title={t('unlock.apikey.Bedrock.title')}
30+
description={t('bedrock.unlock.description')}
31+
title={t('bedrock.unlock.title')}
3232
>
3333
<Input.Password
3434
autoComplete={'new-password'}
@@ -70,7 +70,7 @@ const BedrockForm = memo(() => {
7070
}}
7171
type={'text'}
7272
>
73-
{t('unlock.apikey.Bedrock.customRegion')}
73+
{t('bedrock.unlock.customRegion')}
7474
</Button>
7575
)}
7676
</FormAction>

src/features/Conversation/Error/APIKeyForm/Google.tsx

-61
This file was deleted.

src/features/Conversation/Error/APIKeyForm/Groq.tsx

-60
This file was deleted.

0 commit comments

Comments
 (0)