Enhance: Add more translations, remove unused ones and add linter for unused (#8568)

* chore: remove unused dictionary keys

* wip: add dictionary keys for hardcoded strings

* resolve conflicts

* Add linter to detect :en ui translation keys match used ones

- Fix a couple entries caught by linter
- Copy :command.editor/open-link-in-sidebar entries to
  :help/open-link-in-sidebar as translation keys shouldn't be reused in
  multiple contexts, especially when it's across ui and shortcut dicts

* fix: remove dead keys

* chore: reuse dict keys

* chore: reintroduce useful keys

---------

Co-authored-by: Gabriel Horner <gabriel@logseq.com>
This commit is contained in:
Konstantinos
2023-02-24 16:21:57 +02:00
committed by GitHub
parent ec157b8f2c
commit 2cace8894c
15 changed files with 145 additions and 1539 deletions

View File

@@ -33,7 +33,7 @@
(ui/menu-link
{:key "cut"
:on-click #(editor-handler/cut-selection-blocks true)}
"Cut"
(t :content/cut)
nil)
(ui/menu-link
{:key "delete"
@@ -44,7 +44,7 @@
(ui/menu-link
{:key "copy"
:on-click editor-handler/copy-selection-blocks}
"Copy"
(t :content/copy)
nil)
(ui/menu-link
{:key "copy as"
@@ -236,7 +236,7 @@
{:key "Cut"
:on-click (fn [_e]
(editor-handler/cut-block! block-id))}
"Cut"
(t :content/cut)
nil)
(ui/menu-link
@@ -400,7 +400,7 @@
[:div {:id id}
(if hiccup
hiccup
[:div.cursor "Click to edit"])])
[:div.cursor (t :content/click-to-edit)])])
(rum/defc non-hiccup-content < rum/reactive
[id content on-click on-hide config format]
@@ -422,7 +422,7 @@
{:id id
:on-click on-click}
(if (string/blank? content)
[:div.cursor "Click to edit"]
[:div.cursor (t :content/click-to-edit)]
content)]))))
(defn- set-draw-iframe-style!

View File

@@ -14,7 +14,7 @@
[]
(when-let [current-repo (state/get-current-repo)]
[:div.export
[:h1.title "Export"]
[:h1.title (t :export)]
[:ul.mr-1
[:li.mb-4
[:a.font-medium {:on-click #(export/export-repo-as-edn-v2! current-repo)}

View File

@@ -104,7 +104,7 @@
[:td.text-left (t :help/block-reference)]
[:td.text-right [:code block-ref/left-and-right-parens]]]
[:tr
[:td.text-left (t :command.editor/open-link-in-sidebar)]
[:td.text-left (t :help/open-link-in-sidebar)]
[:td.text-right (ui/render-keyboard-shortcut ["shift" "click"])]]
[:tr
[:td.text-left (t :help/context-menu)]

View File

@@ -11,7 +11,8 @@
[frontend.components.settings :as settings]
[frontend.rum :refer [use-mounted]]
[frontend.storage :as storage]
[rum.core :as rum]))
[rum.core :as rum]
[frontend.context.i18n :refer [t]]))
(rum/defc container
[{:keys [route theme on-click current-repo nfs-granted? db-restoring?
@@ -60,7 +61,7 @@
(rum/use-effect!
#(let [db-restored? (false? db-restoring?)]
(if db-restoring?
(util/set-title! "Loading")
(util/set-title! (t :loading))
(when (or nfs-granted? db-restored?)
(route-handler/update-page-title! route))))
[nfs-granted? db-restoring? route])

View File

@@ -214,7 +214,7 @@
has-checked? (not-empty checked-page-names)]
[:<>
[:h1.select-none.flex.items-center.whiteboard-dashboard-title.title
[:div "All whiteboards"
[:div (t :all-whiteboards)
[:span.opacity-50
(str " · " total-whiteboards)]]
[:div.flex-1]

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,8 @@
[goog.object :as gobj]
[goog.functions :refer [debounce]]
[rum.core :as rum]
[frontend.mobile.util :as mobile-util]))
[frontend.mobile.util :as mobile-util]
[frontend.context.i18n :refer [t]]))
(def excalidraw (r/adapt-class Excalidraw))
@@ -148,7 +149,7 @@
(cond
db-restoring?
[:div.ls-center
(ui/loading "Loading")]
(ui/loading (t :loading))]
(false? loading?)
(draw-inner data option)

View File

@@ -6,7 +6,8 @@
[frontend.util :as util]
[frontend.handler.plugin :refer [hook-extensions-enhancer-by-type] :as plugin-handler]
[promesa.core :as p]
[goog.dom :as gdom]))
[goog.dom :as gdom]
[frontend.context.i18n :refer [t]]))
;; TODO: extracted to a rum mixin
(defn loaded? []
@@ -61,7 +62,7 @@
[id s block? _display?]
(let [loading? (rum/react *loading?)]
(if loading?
(ui/loading "Loading")
(ui/loading (t :loading))
(let [element (if block?
:div.latex
:span.latex-inline)]

View File

@@ -11,7 +11,8 @@
[frontend.state :as state]
[frontend.util :as util]
[logseq.graph-parser.text :as text]
[reitit.frontend.easy :as rfe]))
[reitit.frontend.easy :as rfe]
[frontend.context.i18n :refer [t]]))
(defn redirect!
"If `push` is truthy, previous page will be left in history."
@@ -102,13 +103,13 @@
:repo-add
"Add another repo"
:graph
"Graph"
(t :graph)
:all-files
"All files"
(t :all-files)
:all-pages
"All pages"
(t :all-pages)
:all-journals
"All journals"
(t :all-journals)
:file
(str "File " (:path path-params))
:new-page

View File

@@ -7,7 +7,8 @@
[frontend.handler.search :as search-handler]
[frontend.handler.notification :as notification]
[frontend.components.onboarding.quick-tour :as quick-tour]
[frontend.handler.plugin :as plugin-handler]))
[frontend.handler.plugin :as plugin-handler]
[frontend.context.i18n :refer [t]]))
(rum/defc route-view
[view route-match]
@@ -38,39 +39,38 @@
[:div.ls-center
[:div.icon-box.p-1.rounded.mb-3 (ui/icon "bug" {:style {:font-size ui/icon-size}})]
[:div.text-xl.font-bold
"Sorry. Something went wrong!"]
[:div.mt-2.mb-2 "Logseq is having a problem. To try to get it back to a
working state, please try the following safe steps in order:"]
(t :page/something-went-wrong)]
[:div.mt-2.mb-2 (t :page/logseq-is-having-a-problem)]
[:div
;; TODO: Enable once multi-window case doesn't result in possible data loss
#_[:div.flex.flex-row.justify-between.align-items.mb-2
[:div.flex.flex-col.items-start
[:div.text-2xs.uppercase "STEP 1"]
[:div.text-2xs.uppercase (t :page/step "1")]
[:div [:span.font-bold "Reload"] " the app"]]
[:div (ui/icon "command") (ui/icon "letter-r")]]
[:div.flex.flex-row.justify-between.align-items.mb-2.items-center.py-4
[:div.flex.flex-col.items-start
[:div.text-2xs.font-bold.uppercase.toned-down "STEP 1"]
[:div.text-2xs.font-bold.uppercase.toned-down (t :page/step "1")]
[:div [:span.highlighted.font-bold "Rebuild"] [:span.toned-down " search index"]]]
[:div
(ui/button "Try"
(ui/button (t :page/try)
:small? true
:on-click (fn []
(search-handler/rebuild-indices! true)))]]
[:div.flex.flex-row.justify-between.align-items.mb-2.items-center.separator-top.py-4
[:div.flex.flex-col.items-start
[:div.text-2xs.font-bold.uppercase.toned-down "STEP 2"]
[:div.text-2xs.font-bold.uppercase.toned-down (t :page/step "2")]
[:div [:span.highlighted.font-bold "Relaunch"][:span.toned-down " the app"]]
[:div.text-xs.toned-down "Quit the app and then reopen it."]]
[:div (ui/icon "command" {:class "rounded-md p-1 mr-2 bg-quaternary"})
(ui/icon "letter-q" {:class "rounded-md p-1 bg-quaternary"})]]
[:div.flex.flex-row.justify-between.align-items.mb-4.items-center.separator-top.py-4
[:div.flex.flex-col.items-start
[:div.text-2xs.font-bold.uppercase.toned-down "STEP 3"]
[:div.text-2xs.font-bold.uppercase.toned-down (t :page/step "3")]
[:div [:span.highlighted.font-bold "Clear"] [:span.toned-down " local storage"]]
[:div.text-xs.toned-down "This does delete minor preferences like dark/light theme preference."]]
[:div
(ui/button "Try"
(ui/button (t :page/try)
:small? true
:on-click (fn []
(.clear js/localStorage)