|
1 | 1 | import { useState, useEffect, useRef } from 'react' |
| 2 | +import { useTranslation } from 'react-i18next' |
2 | 3 | import { LuX, LuDownload } from 'react-icons/lu' |
3 | 4 | import { mediaUrl } from '../api' |
4 | 5 |
|
5 | | -const FORMATS = [ |
6 | | - { |
7 | | - id: 'zip', |
8 | | - label: 'ZIP', |
9 | | - ext: '.zip', |
10 | | - description: 'Compatible with all platforms. Best for sharing.', |
11 | | - }, |
12 | | - { |
13 | | - id: 'tar', |
14 | | - label: 'TAR', |
15 | | - ext: '.tar', |
16 | | - description: 'Uncompressed archive. Preserves Unix permissions.', |
17 | | - }, |
18 | | - { |
19 | | - id: 'tar.gz', |
20 | | - label: 'TAR.GZ', |
21 | | - ext: '.tar.gz', |
22 | | - description: 'Gzip-compressed tar. Standard on Linux / macOS.', |
23 | | - }, |
24 | | - { |
25 | | - id: 'tar.bz2', |
26 | | - label: 'TAR.BZ2', |
27 | | - ext: '.tar.bz2', |
28 | | - description: 'Bzip2-compressed tar. Slightly better compression than gzip.', |
29 | | - }, |
30 | | -] |
31 | | - |
32 | 6 | export default function DownloadArchiveModal({ title, params, onClose }) { |
| 7 | + const { t } = useTranslation() |
33 | 8 | const [fmt, setFmt] = useState('zip') |
34 | 9 | const firstRef = useRef(null) |
35 | 10 |
|
| 11 | + const FORMATS = [ |
| 12 | + { |
| 13 | + id: 'zip', |
| 14 | + label: t('download.zip.label'), |
| 15 | + ext: t('download.zip.ext'), |
| 16 | + description: t('download.zip.description'), |
| 17 | + }, |
| 18 | + { |
| 19 | + id: 'tar', |
| 20 | + label: t('download.tar.label'), |
| 21 | + ext: t('download.tar.ext'), |
| 22 | + description: t('download.tar.description'), |
| 23 | + }, |
| 24 | + { |
| 25 | + id: 'tar.gz', |
| 26 | + label: t('download.tarGz.label'), |
| 27 | + ext: t('download.tarGz.ext'), |
| 28 | + description: t('download.tarGz.description'), |
| 29 | + }, |
| 30 | + { |
| 31 | + id: 'tar.bz2', |
| 32 | + label: t('download.tarBz2.label'), |
| 33 | + ext: t('download.tarBz2.ext'), |
| 34 | + description: t('download.tarBz2.description'), |
| 35 | + }, |
| 36 | + ] |
| 37 | + |
36 | 38 | useEffect(() => { |
37 | 39 | firstRef.current?.focus() |
38 | 40 | const onKey = (e) => { if (e.key === 'Escape') onClose() } |
@@ -71,12 +73,12 @@ export default function DownloadArchiveModal({ title, params, onClose }) { |
71 | 73 | }}> |
72 | 74 | <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 4 }}> |
73 | 75 | <span id="dl-modal-title" style={{ fontSize: 15, fontWeight: 600 }}> |
74 | | - Download Archive |
| 76 | + {t('download.title')} |
75 | 77 | </span> |
76 | 78 | <button |
77 | 79 | onClick={onClose} |
78 | 80 | style={{ background: 'none', border: 'none', cursor: 'pointer', color: 'var(--text-muted)', display: 'flex', padding: 2 }} |
79 | | - aria-label="Close" |
| 81 | + aria-label={t('common.close')} |
80 | 82 | > |
81 | 83 | <LuX size={16} /> |
82 | 84 | </button> |
@@ -131,13 +133,13 @@ export default function DownloadArchiveModal({ title, params, onClose }) { |
131 | 133 | onClick={onClose} |
132 | 134 | style={{ padding: '7px 16px', borderRadius: 6, background: 'var(--bg-card)', border: '1px solid var(--border)', color: 'var(--text-dim)', fontSize: 14, cursor: 'pointer' }} |
133 | 135 | > |
134 | | - Cancel |
| 136 | + {t('download.cancel')} |
135 | 137 | </button> |
136 | 138 | <button |
137 | 139 | onClick={handleDownload} |
138 | 140 | style={{ padding: '7px 18px', borderRadius: 6, background: 'var(--gold-dim)', border: 'none', color: 'var(--bg-deep)', fontSize: 14, fontWeight: 600, cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 6 }} |
139 | 141 | > |
140 | | - <LuDownload size={14} /> Download |
| 142 | + <LuDownload size={14} /> {t('download.download')} |
141 | 143 | </button> |
142 | 144 | </div> |
143 | 145 | </div> |
|
0 commit comments