jan/web-app/src/containers/dialogs/AppUpdater.tsx
Sam Hoang Van c32dd092d0
Enhance i18n and add missing i18n for all component (#5314)
* Refactor translation imports and update text for localization across settings and system monitor routes

- Changed translation import from 'react-i18next' to '@/i18n/react-i18next-compat' in multiple files.
- Updated various text strings to use translation keys for better localization support in:
  - Local API Server settings
  - MCP Servers settings
  - Privacy settings
  - Provider settings
  - Shortcuts settings
  - System Monitor
  - Thread details
- Ensured consistent use of translation keys for all user-facing text.

Update web-app/src/routes/settings/appearance.tsx

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

Update web-app/src/routes/settings/appearance.tsx

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

Update web-app/src/locales/vn/settings.json

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

Update web-app/src/containers/dialogs/DeleteMCPServerConfirm.tsx

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

Update web-app/src/locales/id/common.json

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Add Chinese (Simplified and Traditional) localization files for various components

- Created `tools.json`, `updater.json`, `assistants.json`, `chat.json`, `common.json`, `hub.json`, `logs.json`, `mcp-servers.json`, `provider.json`, `providers.json`, `settings.json`, `setup.json`, `system-monitor.json`, `tool-approval.json` in both `zh-CN` and `zh-TW` locales.
- Added translations for tool approval, updater notifications, assistant management, chat interface, common UI elements, hub interactions, logging messages, MCP server configurations, provider management, settings options, setup instructions, and system monitoring.

* Refactor localization strings for improved clarity and consistency in English, Indonesian, and Vietnamese settings files

* Fix missing key and reword

* fix pr comment

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 15:33:54 +07:00

147 lines
4.6 KiB
TypeScript

import { useAppUpdater } from '@/hooks/useAppUpdater'
import { IconDownload } from '@tabler/icons-react'
import { Button } from '@/components/ui/button'
import { useState, useEffect } from 'react'
import { useReleaseNotes } from '@/hooks/useReleaseNotes'
import { RenderMarkdown } from '../RenderMarkdown'
import { cn, isDev } from '@/lib/utils'
import { isNightly, isBeta } from '@/lib/version'
import { useTranslation } from '@/i18n/react-i18next-compat'
const DialogAppUpdater = () => {
const { t } = useTranslation()
const {
updateState,
downloadAndInstallUpdate,
checkForUpdate,
setRemindMeLater,
} = useAppUpdater()
const [showReleaseNotes, setShowReleaseNotes] = useState(false)
const handleUpdate = () => {
downloadAndInstallUpdate()
setRemindMeLater(true)
}
const { release, fetchLatestRelease } = useReleaseNotes()
useEffect(() => {
if (!isDev()) {
fetchLatestRelease(isBeta)
}
}, [fetchLatestRelease])
// Check for updates when component mounts
useEffect(() => {
checkForUpdate()
}, [checkForUpdate])
const [appUpdateState, setAppUpdateState] = useState({
remindMeLater: false,
isUpdateAvailable: false,
})
useEffect(() => {
setAppUpdateState({
remindMeLater: updateState.remindMeLater,
isUpdateAvailable: updateState.isUpdateAvailable,
})
}, [updateState])
if (appUpdateState.remindMeLater) return null
return (
<>
{appUpdateState.isUpdateAvailable && (
<div
className={cn(
'fixed z-50 w-[400px] bottom-3 right-3 bg-main-view text-main-view-fg flex items-center justify-center border border-main-view-fg/10 rounded-lg shadow-md'
)}
>
<div className="px-0 py-4">
<div className="px-4">
<div className="flex items-start gap-2">
<IconDownload
size={20}
className="shrink-0 text-main-view-fg/60 mt-1"
/>
<div>
<div className="text-base font-medium">
{t('updater:newVersion', {
version: updateState.updateInfo?.version,
})}
</div>
<div className="mt-1 text-main-view-fg/70 font-normal mb-2">
{t('updater:updateAvailable')}
</div>
</div>
</div>
</div>
{showReleaseNotes && (
<div className="max-h-[500px] p-4 w-[400px] overflow-y-scroll text-sm font-normal leading-relaxed">
{isNightly && !isBeta ? (
<p className="text-sm font-normal">
{t('updater:nightlyBuild')}
</p>
) : (
<RenderMarkdown
components={{
a: ({ ...props }) => (
<a
{...props}
target="_blank"
rel="noopener noreferrer"
/>
),
h2: ({ ...props }) => (
<h2 {...props} className="!text-xl !mt-0" />
),
}}
content={release?.body}
/>
)}
</div>
)}
<div className="pt-3 px-4">
<div className="flex gap-x-4 w-full items-center justify-between">
<Button
variant="link"
className="px-0 text-main-view-fg/70"
onClick={() => setShowReleaseNotes(!showReleaseNotes)}
>
{showReleaseNotes
? t('updater:hideReleaseNotes')
: t('updater:showReleaseNotes')}
</Button>
<div className="flex gap-x-5">
<Button
variant="link"
className="px-0 text-main-view-fg/70 remind-me-later"
onClick={() => setRemindMeLater(true)}
>
{t('updater:remindMeLater')}
</Button>
<Button
onClick={handleUpdate}
disabled={updateState.isDownloading}
>
{updateState.isDownloading
? t('updater:downloading')
: t('updater:updateNow')}
</Button>
</div>
</div>
</div>
</div>
</div>
)}
</>
)
}
export default DialogAppUpdater