penpot/frontend/src/app/main/data/viewer/shortcuts.cljs
Andrey Antukh 4b978767ea
🌐 Clean up en translations (#11853)
Drop 277 keys nothing references from en.po (verified against
frontend/src and common/src) and let sync propagate the
deletions to every locale. Clear all 10 fuzzy entries: fill
the 5 empty translations, keep the 4 valid ones, and drop the
duplicated max-quote-reached in favor of max-quota-reached
(the backend code stays, the UI maps it to the quota text).

Recover 22 used-but-missing keys with translations: the 19
shortcuts section/subsection labels plus connected-to,
pixel-grid-color and tokens.add-set. Make the rest
statically visible to rehash instead: :label fns on shortcut
commands, sections and subsections (one debug-only and one
colorpicker-local id exempt); case branches in place of
dm/str-built keys (export modal, text decoration and
transform, undo history with raw-key fallback); hoist
conditionals out of tr calls; pre-translate modal props and
role labels; replace the lone (i18n/tr ...) site with tr.
Turn static :error/code data into eager :error/fn calls in
the common schemas and the auth/password forms. Rename the
two keys containing spaces and point team leave at
max-quota-reached. Backend-driven keys stay dynamic by
design, declared with (tr ...) comments: the five
weak-password details, team and organization notifications.

Tooling: rehash also scans common/src and no longer treats
a missing -l as no locale; new clj-kondo tr-dynamic warning
flags non-literal tr args (lint scripts use --fail-level
error so it never fails CI); tr docstring states the
literal-only rule. Tests cover the shortcut label wiring,
the undo-history fallback and the :error/fn schemas.
Translations memory rewritten to match; es check word list
gains three entries.

Rebased onto develop: adopt the register field-error UX
(the weak-password declarations move onto the :options
code), keep develop's newer keys (connection-error,
account-locked, save-retrying, tokens-source strings) with
fresh references, and reword the shortcuts.cljs prose
comment so rehash does not invent a "literal" key.

AI-assisted-by: muse-spark-1.3-contributor
2026-09-25 11:11:44 +02:00

113 lines
4.8 KiB
Clojure

;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns app.main.data.viewer.shortcuts
(:require
[app.main.data.common :as dcm]
[app.main.data.event :as ev]
[app.main.data.profile :as du]
[app.main.data.shortcuts :as ds]
[app.main.data.viewer :as dv]
[app.main.store :as st]
[app.util.i18n :refer [tr]]))
(def shortcuts
{:increase-zoom {:tooltip "+"
:label (fn [] (tr "shortcuts.increase-zoom"))
:command "+"
:subsections [:zoom-viewer]
:section [:viewer]
:fn #(st/emit! dv/increase-zoom)}
:toggle-theme {:tooltip (ds/alt "M")
:label (fn [] (tr "shortcuts.toggle-theme"))
:command (ds/a-mod "m")
:section [:viewer]
:subsections [:generic]
:fn #(st/emit! (with-meta (du/toggle-theme)
{::ev/origin "viewer:shortcuts"}))}
:decrease-zoom {:tooltip "-"
:label (fn [] (tr "shortcuts.decrease-zoom"))
:command "-"
:section [:viewer]
:subsections [:zoom-viewer]
:fn #(st/emit! dv/decrease-zoom)}
:select-all {:tooltip (ds/meta "A")
:label (fn [] (tr "shortcuts.select-all"))
:command (ds/c-mod "a")
:section [:viewer]
:subsections [:generic]
:fn #(st/emit! (dv/select-all))}
:reset-zoom {:tooltip (ds/shift "0")
:label (fn [] (tr "shortcuts.reset-zoom"))
:command "shift+0"
:section [:viewer]
:subsections [:zoom-viewer]
:fn #(st/emit! dv/reset-zoom)}
:toggle-zoom-style {:tooltip "F"
:label (fn [] (tr "shortcuts.toggle-zoom-style"))
:command "f"
:section [:viewer]
:subsections [:zoom-viewer]
:fn #(st/emit! dv/toggle-zoom-style)}
:toggle-fullscreen {:tooltip (ds/shift "F")
:label (fn [] (tr "shortcuts.toggle-fullscreen"))
:command ["shift+f" "alt+enter"]
:section [:viewer]
:subsections [:zoom-viewer]
:fn #(st/emit! dv/toggle-fullscreen)}
:prev-frame {:tooltip ds/left-arrow
:label (fn [] (tr "shortcuts.prev-frame"))
:command ["left" "up" "shift+enter" "pageup" "shift+space"]
:subsections [:generic]
:section [:viewer]
:fn #(st/emit! dv/select-prev-frame)}
:next-frame {:tooltip ds/right-arrow
:label (fn [] (tr "shortcuts.next-frame"))
:command ["right" "down" "enter" "pagedown" "space"]
:subsections [:generic]
:section [:viewer]
:fn #(st/emit! dv/select-next-frame)}
:open-inspect {:tooltip "G I"
:label (fn [] (tr "shortcuts.open-inspect"))
:command "g i"
:subsections [:navigation-viewer]
:section [:viewer]
:fn #(st/emit! (dv/go-to-section :inspect))}
:open-comments {:tooltip "G C"
:label (fn [] (tr "shortcuts.open-comments"))
:command "g c"
:subsections [:navigation-viewer]
:section [:viewer]
:fn #(st/emit! (dv/go-to-section :comments))}
:open-interactions {:tooltip "G V"
:label (fn [] (tr "shortcuts.open-interactions"))
:command "g v"
:subsections [:navigation-viewer]
:section [:viewer]
:fn #(st/emit! (dv/go-to-section :interactions))}
:open-workspace {:tooltip "G W"
:label (fn [] (tr "shortcuts.open-workspace"))
:command "g w"
:subsections [:navigation-viewer]
:section [:viewer]
:fn #(st/emit! (dcm/go-to-workspace))}})
(defn get-tooltip [shortcut]
(assert (contains? shortcuts shortcut) (str shortcut))
(get-in shortcuts [shortcut :tooltip]))