fix: frontend: file menu was not translatable #188

Massimo Melina committed Apr 2, 2023 at 08:45 UTC 71ed42688ab2b1616bea5301dcc129b72478c5ac
3 files changed +20 -10
frontend/src/BrowseFiles.ts
+5 -5
@@ -20,7 +20,7 @@ import useFetchList from './useFetchList'
20 import { useAuthorized } from './login'
21 import { acceptDropFiles, enqueue } from './upload'
22 import _ from 'lodash'
23 -import { useI18N } from './i18n'
23 +import { t, useI18N } from './i18n'
24 import { deleteFiles } from './menu'
25
26 export function usePath() {
@@ -224,15 +224,15 @@ const Entry = memo((entry: DirEntry & { midnight: Date, separator?: string }) =>
224 if (ev.altKey || ev.ctrlKey || ev.metaKey) return
225 ev.preventDefault()
226 const menu = [
227 - menuOnLink && { label: "Open", href, target: '_blank', icon: 'play' },
228 - { label: "Download", href: href + '?dl', icon: 'download' },
229 - can_delete && { label: "Delete", icon: 'trash', onClick: () => deleteFiles([href], base) }
227 + menuOnLink && { label: t('file_open', "Open"), href, target: '_blank', icon: 'play' },
228 + { label: t`Download`, href: href + '?dl', icon: 'download' },
229 + can_delete && { label: t`Delete`, icon: 'trash', onClick: () => deleteFiles([href], base) }
230 ]
231 const res = hfsEvent('fileMenu', { entry })
232 if (res)
233 menu.push(...res.flat())
234 const close = newDialog({
235 - title: "File menu",
235 + title: t`File menu`,
236 icon: () => ico,
237 position: isMobile() ? undefined
238 : [ev.pageX, ev.pageY - window.scrollY] as [number, number],
langs/hfs-lang-en.json
+7 -2
@@ -1,7 +1,7 @@
1 {
2 "author": "YOUR NAME HERE",
3 "version": 1.0,
4 - "hfs_version": "0.40.1",
4 + "hfs_version": "0.43.0",
5 "translate": {
6 "Select": "Select",
7 "n_files": "{n,plural,one{# file} other{# files}}",
@@ -102,6 +102,11 @@
102 "upload_errors": "{n} failed",
103 "upload_file_rejected": "Some files were not accepted",
104
105 - "download counter": "download counter"
105 + "download counter": "download counter",
106 +
107 + "File menu": "File menu",
108 + "Name: {name}": "Name: {name}",
109 + "file_open": "Open",
110 + "Download": "Download"
111 }
112 }
langs/hfs-lang-it.json
+8 -3
@@ -1,7 +1,7 @@
1 {
2 "author": "Massimo Melina",
3 - "version": 1.4,
4 - "hfs_version": "0.40.1",
3 + "version": 1.5,
4 + "hfs_version": "0.43.0",
5 "translate": {
6 "Select": "Seleziona",
7 "n_files": "{n} file",
@@ -96,6 +96,11 @@
96 "upload_errors": "{n,plural, one{# fallito} other{# falliti}}",
97 "upload_file_rejected": "Alcuni file non sono stati accettati",
98
99 - "download counter": "download conteggiati"
99 + "download counter": "download conteggiati",
100 +
101 + "File menu": "Menu file",
102 + "Name: {name}": "Nome: {name}",
103 + "file_open": "Apri",
104 + "Download": "Download"
105 }
106 }