Skip to content

Commit

Permalink
allow setting disable history (#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy authored Mar 2, 2024
1 parent 77fd005 commit b4e0a5a
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 46 deletions.
3 changes: 2 additions & 1 deletion src/i18n/locales/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"title": "Allgemeine Einstellungen",
"auto_start": "Beim Start des Computers starten",
"check_update": "Beim Start Updates überprüfen",
"history_disable": "Verlauf deaktivieren",
"server_port": "Überwachungsport",
"server_port_change": "Überwachungsport wurde geändert, für Änderungen neu starten",
"app_language": "App Sprache",
Expand Down Expand Up @@ -470,4 +471,4 @@
"delete_space": "Leerzeichen löschen"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"title": "General Settings",
"auto_start": "Auto Startup",
"check_update": "Check Update",
"history_disable": "Disable History",
"server_port": "Listening Port",
"server_port_change": "The listening port has been changed, Please restart the application for the changes to take effect",
"app_language": "Application Language",
Expand Down Expand Up @@ -495,4 +496,4 @@
"delete_space": "Delete Space"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@
"server_port": "Puerto de escucha",
"proxy_error": "Por favor introduzca el host y el puerto",
"check_update": "Comprobar la actualización",
"history_disable": "Deshabilitar el historial",
"app_language": "Idioma de la aplicación",
"transparent": "Efecto de transparencia",
"title": "Ajustes generales",
"app_fallback_font": "Fuente alternativa"
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/fa_IR.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"server_port": "پورت شنونده",
"proxy_error": "لطفا هاست و پورت را پر کنید",
"check_update": "بررسی بروزرسانی",
"history_disable": "غیرفعال کردن تاریخچه",
"app_language": "زبان برنامه",
"transparent": "اثر شفافیت",
"title": "تنظیمات عمومی",
Expand Down Expand Up @@ -120,4 +121,4 @@
"copy_img": "کپی عکس"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"server_port": "Port d'écoute",
"proxy_error": "Veuillez compléter l'hôte et le port",
"check_update": "Vérifier les mises à jour",
"history_disable": "Désactiver l'historique",
"app_language": "Langue de l'application",
"transparent": "Effet de transparence",
"title": "Paramètres généraux",
Expand Down Expand Up @@ -472,4 +473,4 @@
"delete_space": "Supprimer l'espace"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@
"server_port": "Porta in ascolto",
"proxy_error": "Inserisci l'host e la porta",
"check_update": "Controlla aggiornamento",
"history_disable": "Disabilita cronologia",
"app_language": "Lingua dell'applicazione",
"transparent": "Effetto trasparente",
"title": "Impostazioni Generali",
Expand Down Expand Up @@ -444,4 +445,4 @@
"copy_img": "Copia immagine"
}
}
}
}
5 changes: 3 additions & 2 deletions src/i18n/locales/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"translate": "トランスレート",
"config": "コンフィグ"
},
"title": "ジェネラルせっち"
"title": "ジェネラルせっち",
"history_disable": "ひすとりーせっち"
},
"hotkey": {
"label": "ホットキー",
Expand Down Expand Up @@ -68,4 +69,4 @@
"save": "設定保存"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"title": "Configurações Gerais",
"auto_start": "Iniciar Automaticamente",
"check_update": "Checar por Atualização",
"history_disable": "Desabilitar Histórico",
"server_port": "Porta de Escuta",
"server_port_change": "A porta de escuta foi alterada. Reinicie o aplicativo para que as alterações tenham efeito",
"app_language": "Idioma do Aplicativo",
Expand Down Expand Up @@ -472,4 +473,4 @@
"delete_space": "Excluir Espaço"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
"server_port": "Porta de Escuta",
"proxy_error": "Por favor preencha o host e a porta",
"check_update": "Procurar Atualização",
"history_disable": "Desativar Histórico",
"app_language": "Idioma da Aplicação",
"transparent": "Efeito de Transparência",
"title": "Configurações Gerais",
Expand Down Expand Up @@ -456,4 +457,4 @@
"copy_img": "Copiar imagem"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"title": "Общие настройки",
"auto_start": "Автозагрузка",
"check_update": "Проверка обновлений",
"history_disable": "Отключить историю",
"server_port": "Порт прослушивания",
"server_port_change": "Порт прослушивания был изменён. Перезапустите приложение, чтобы изменения вступили в силу",
"app_language": "Язык приложения",
Expand Down Expand Up @@ -472,4 +473,4 @@
"delete_space": "Удалить пробелы"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/uk_UA.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"config": {
"general": {
"check_update": "Перевірити оновлення",
"history_disable": "Вимкнути історію",
"auto_start": "Автозапуск",
"label": "Загальні",
"title": "Загальні налаштування",
Expand Down Expand Up @@ -115,4 +116,4 @@
"delete_newline": "Видалити новий рядок"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"title": "常规设置",
"auto_start": "开机时启动应用",
"check_update": "启动时检查更新",
"history_disable": "禁用历史记录",
"server_port": "监听端口",
"server_port_change": "监听端口已更改,重启应用生效",
"app_language": "应用语言",
Expand Down Expand Up @@ -495,4 +496,4 @@
"delete_space": "删除空格"
}
}
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"title": "常規設定",
"auto_start": "開機時啟動應用程式",
"check_update": "啟動時檢查更新",
"history_disable": "禁用歷史記錄",
"server_port": "監聽埠號",
"server_port_change": "監聽埠號已更改,重啟應用程式生效",
"app_language": "應用語言",
Expand Down Expand Up @@ -420,4 +421,4 @@
"delete_space": "删除空格"
}
}
}
}
22 changes: 16 additions & 6 deletions src/window/Config/pages/General/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function General() {
const [autoStart, setAutoStart] = useState(false);
const [fontList, setFontList] = useState(null);
const [checkUpdate, setCheckUpdate] = useConfig('check_update', true);
const [historyDisable, setHistoryDisable] = useConfig('history_disable', false);
const [serverPort, setServerPort] = useConfig('server_port', 60828);
const [appLanguage, setAppLanguage] = useConfig('app_language', 'en');
const [appTheme, setAppTheme] = useConfig('app_theme', 'system');
Expand Down Expand Up @@ -108,6 +109,17 @@ export default function General() {
/>
)}
</div>
<div className='config-item'>
<h3>{t('config.general.history_disable')}</h3>
{historyDisable !== null && (
<Switch
isSelected={historyDisable}
onValueChange={(v) => {
setHistoryDisable(v);
}}
/>
)}
</div>
<div className='config-item'>
<h3 className='my-auto'>{t('config.general.server_port')}</h3>
{serverPort !== null && (
Expand Down Expand Up @@ -328,9 +340,8 @@ export default function General() {
aria-label='app font'
className='max-h-[50vh] overflow-y-auto'
onAction={(key) => {
document.documentElement.style.fontFamily = `"${
key === 'default' ? 'sans-serif' : key
}","${appFallbackFont === 'default' ? 'sans-serif' : appFallbackFont}"`;
document.documentElement.style.fontFamily = `"${key === 'default' ? 'sans-serif' : key
}","${appFallbackFont === 'default' ? 'sans-serif' : appFallbackFont}"`;
setAppFont(key);
}}
>
Expand Down Expand Up @@ -374,9 +385,8 @@ export default function General() {
aria-label='app font'
className='max-h-[50vh] overflow-y-auto'
onAction={(key) => {
document.documentElement.style.fontFamily = `"${
appFont === 'default' ? 'sans-serif' : appFont
}","${key === 'default' ? 'sans-serif' : key}"`;
document.documentElement.style.fontFamily = `"${appFont === 'default' ? 'sans-serif' : appFont
}","${key === 'default' ? 'sans-serif' : key}"`;
setAppFallbackFont(key);
}}
>
Expand Down
53 changes: 27 additions & 26 deletions src/window/Translate/components/TargetArea/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function TargetArea(props) {
const [autoCopy] = useConfig('translate_auto_copy', 'disable');
const [clipboardMonitor] = useConfig('clipboard_monitor', false);
const [hideWindow] = useConfig('translate_hide_window', false);
const [historyDisable] = useConfig('history_disable', false);
const { name, index, translateServiceList, pluginList, ...drag } = props;
const [translateServiceName, setTranslateServiceName] = useState(name);
const [result, setResult] = useState('');
Expand Down Expand Up @@ -156,13 +157,15 @@ export default function TargetArea(props) {
if (v !== '') {
setHide(false);
}
addToHistory(
sourceText.trim(),
detectLanguage,
newTargetLanguage,
translateServiceName,
typeof v === 'string' ? v.trim() : v
);
if (!historyDisable) {
addToHistory(
sourceText.trim(),
detectLanguage,
newTargetLanguage,
translateServiceName,
typeof v === 'string' ? v.trim() : v
);
}
if (index === 0 && !clipboardMonitor) {
switch (autoCopy) {
case 'target':
Expand Down Expand Up @@ -224,13 +227,15 @@ export default function TargetArea(props) {
if (v !== '') {
setHideOnce(false);
}
addToHistory(
sourceText.trim(),
detectLanguage,
newTargetLanguage,
translateServiceName,
typeof v === 'string' ? v.trim() : v
);
if (!historyDisable) {
addToHistory(
sourceText.trim(),
detectLanguage,
newTargetLanguage,
translateServiceName,
typeof v === 'string' ? v.trim() : v
);
}
if (index === 0 && !clipboardMonitor) {
switch (autoCopy) {
case 'target':
Expand Down Expand Up @@ -325,9 +330,8 @@ export default function TargetArea(props) {
>
<Toaster />
<CardHeader
className={`flex justify-between py-1 px-0 bg-content2 h-[30px] ${
hide ? 'rounded-[10px]' : 'rounded-t-[10px]'
}`}
className={`flex justify-between py-1 px-0 bg-content2 h-[30px] ${hide ? 'rounded-[10px]' : 'rounded-t-[10px]'
}`}
{...drag}
>
<div className='flex'>
Expand Down Expand Up @@ -474,9 +478,8 @@ export default function TargetArea(props) {
{index === 0 ? (
<>
<span
className={`text-[${
appFontSize - 2
}px] text-default-500 mr-[12px]`}
className={`text-[${appFontSize - 2
}px] text-default-500 mr-[12px]`}
>
{explanations['trait']}
</span>
Expand All @@ -489,9 +492,8 @@ export default function TargetArea(props) {
</>
) : (
<span
className={`text-[${
appFontSize - 2
}px] text-default-500 select-text mr-1`}
className={`text-[${appFontSize - 2
}px] text-default-500 select-text mr-1`}
key={nanoid()}
>
{explain}
Expand Down Expand Up @@ -562,9 +564,8 @@ export default function TargetArea(props) {
)}
</CardBody>
<CardFooter
className={`bg-content1 rounded-none rounded-b-[10px] flex px-[12px] p-[5px] ${
hide && 'hidden'
}`}
className={`bg-content1 rounded-none rounded-b-[10px] flex px-[12px] p-[5px] ${hide && 'hidden'
}`}
>
<ButtonGroup>
<Tooltip content={t('translate.speak')}>
Expand Down

0 comments on commit b4e0a5a

Please sign in to comment.