chore: add i18n support for ai confirm modal (#8116)
This commit is contained in:
@@ -410,17 +410,25 @@ const AISettings = () => {
|
|||||||
const onToggleAI = useCallback(
|
const onToggleAI = useCallback(
|
||||||
(checked: boolean) => {
|
(checked: boolean) => {
|
||||||
openConfirmModal({
|
openConfirmModal({
|
||||||
title: checked ? 'Enable AI?' : 'Disable AI?',
|
title: checked
|
||||||
description: `Are you sure you want to ${checked ? 'enable' : 'disable'} AI?`,
|
? t['com.affine.settings.editorSettings.general.ai.enable.title']()
|
||||||
confirmText: checked ? 'Enable' : 'Disable',
|
: t['com.affine.settings.editorSettings.general.ai.disable.title'](),
|
||||||
cancelText: 'Cancel',
|
description: checked
|
||||||
|
? t[
|
||||||
|
'com.affine.settings.editorSettings.general.ai.enable.description'
|
||||||
|
]()
|
||||||
|
: t[
|
||||||
|
'com.affine.settings.editorSettings.general.ai.disable.description'
|
||||||
|
](),
|
||||||
|
confirmText: checked ? t['Enable']() : t['Disable'](),
|
||||||
|
cancelText: t['Cancel'](),
|
||||||
onConfirm: () => onAIChange(checked),
|
onConfirm: () => onAIChange(checked),
|
||||||
confirmButtonOptions: {
|
confirmButtonOptions: {
|
||||||
variant: checked ? 'primary' : 'error',
|
variant: checked ? 'primary' : 'error',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[openConfirmModal, onAIChange]
|
[openConfirmModal, t, onAIChange]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ConfirmModal, NotificationCenter, notify } from '@affine/component';
|
import { ConfirmModal, NotificationCenter, notify } from '@affine/component';
|
||||||
import { events } from '@affine/electron-api';
|
import { events } from '@affine/electron-api';
|
||||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
|
import { useI18n } from '@affine/i18n';
|
||||||
import {
|
import {
|
||||||
GlobalContextService,
|
GlobalContextService,
|
||||||
useLiveData,
|
useLiveData,
|
||||||
@@ -185,6 +186,7 @@ export const SignOutConfirmModal = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const AIReloadConfirmModal = () => {
|
export const AIReloadConfirmModal = () => {
|
||||||
|
const t = useI18n();
|
||||||
const editorSettingService = useService(EditorSettingService);
|
const editorSettingService = useService(EditorSettingService);
|
||||||
const enableAI = useLiveData(
|
const enableAI = useLiveData(
|
||||||
editorSettingService.editorSetting.settings$.selector(s => s.enableAI)
|
editorSettingService.editorSetting.settings$.selector(s => s.enableAI)
|
||||||
@@ -208,12 +210,14 @@ export const AIReloadConfirmModal = () => {
|
|||||||
confirmButtonOptions={{
|
confirmButtonOptions={{
|
||||||
variant: 'primary',
|
variant: 'primary',
|
||||||
}}
|
}}
|
||||||
title={'You need to reload the page'}
|
title={t['com.affine.settings.editorSettings.general.ai.reload.title']()}
|
||||||
description={
|
description={t[
|
||||||
'AI settings have been updated. Please reload the page to apply the changes.'
|
'com.affine.settings.editorSettings.general.ai.reload.description'
|
||||||
}
|
]()}
|
||||||
cancelText={'Cancel'}
|
cancelText={t['Cancel']()}
|
||||||
confirmText={'Reload'}
|
confirmText={t[
|
||||||
|
'com.affine.settings.editorSettings.general.ai.reload.confirm'
|
||||||
|
]()}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user