Skip to content

Commit

Permalink
enhance: convert hardcoded strings in the UI to be translatable (logs…
Browse files Browse the repository at this point in the history
…eq#9588)

* add some missing strings to en dict

* main/frontend/components/search: fix wrong title

* update namespaces according to file names

* update missing title with new namespace

* Revert translating developer logging

---------

Co-authored-by: Gabriel Horner <[email protected]>
  • Loading branch information
optimistic5 and logseq-cldwalker authored Jun 6, 2023
1 parent c3aa16d commit 9fcaebf
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/main/frontend/components/header.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
[{:keys [on-click]}]
(ui/with-shortcut :ui/toggle-left-sidebar "bottom"
[:button.#left-menu.cp__header-left-menu.button.icon
{:title "Toggle left menu"
{:title (t :header/toggle-left-sidebar)
:on-click on-click}
(ui/icon "menu-2" {:size ui/icon-size})]))

Expand Down Expand Up @@ -86,7 +86,7 @@
(fn [{:keys [toggle-fn]}]
[:button.button.icon.toolbar-dots-btn
{:on-click toggle-fn
:title "More"}
:title (t :header/more)}
(ui/icon "dots" {:size ui/icon-size})])
(->>
[(when (state/enable-editing?)
Expand Down Expand Up @@ -148,12 +148,12 @@

(ui/with-shortcut :go/backward "bottom"
[:button.it.navigation.nav-left.button.icon
{:title "Go back" :on-click #(js/window.history.back)}
{:title (t :header/go-back) :on-click #(js/window.history.back)}
(ui/icon "arrow-left" {:size ui/icon-size})])

(ui/with-shortcut :go/forward "bottom"
[:button.it.navigation.nav-right.button.icon
{:title "Go forward" :on-click #(js/window.history.forward)}
{:title (t :header/go-forward) :on-click #(js/window.history.forward)}
(ui/icon "arrow-right" {:size ui/icon-size})])])

(rum/defc updater-tips-new-version
Expand Down Expand Up @@ -218,13 +218,13 @@
(when-not (or (state/home?) custom-home-page? (state/whiteboard-dashboard?))
(ui/with-shortcut :go/backward "bottom"
[:button.it.navigation.nav-left.button.icon.opacity-70
{:title "Go back" :on-click #(js/window.history.back)}
{:title (t :header/go-back) :on-click #(js/window.history.back)}
(ui/icon "chevron-left" {:size 26})]))
;; search button for non-mobile
(when current-repo
(ui/with-shortcut :go/search "right"
[:button.button.icon#search-button
{:title "Search"
{:title (t :header/search)
:on-click #(do (when (or (mobile-util/native-android?)
(mobile-util/native-iphone?))
(state/set-left-sidebar-open! false))
Expand Down
10 changes: 5 additions & 5 deletions src/main/frontend/components/onboarding.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[:span.mr-1 (t :help/forum-community)]
(ui/icon "message-circle" {:style {:font-size 20}})]
list
[{:title "Usage"
[{:title (t :help/title-usage)
:children [[[:a
{:on-click (fn [] (state/sidebar-add-block! (state/get-current-repo) "shortcut-settings" :shortcut-settings))}
[:div.flex-row.inline-flex.items-center
Expand All @@ -26,21 +26,21 @@
[(t :help/start) "https://docs.logseq.com/#/page/tutorial"]
["FAQ" "https://docs.logseq.com/#/page/faq"]]}

{:title "Community"
{:title (t :help/title-community)
:children [[(t :help/awesome-logseq) "https://github.com/logseq/awesome-logseq"]
[(t :help/blog) "https://blog.logseq.com"]
[discourse-with-icon "https://discuss.logseq.com"]]}

{:title "Development"
{:title (t :help/title-development)
:children [[(t :help/roadmap) "https://trello.com/b/8txSM12G/roadmap"]
[(t :help/bug) "https://github.com/logseq/logseq/issues/new?labels=from:in-app&template=bug_report.yaml"]
[(t :help/feature) "https://discuss.logseq.com/c/feature-requests/"]
[(t :help/changelog) "https://docs.logseq.com/#/page/changelog"]]}

{:title "About"
{:title (t :help/title-about)
:children [[(t :help/about) "https://blog.logseq.com/about/"]]}

{:title "Terms"
{:title (t :help/title-terms)
:children [[(t :help/privacy) "https://blog.logseq.com/privacy-policy/"]
[(t :help/terms) "https://blog.logseq.com/terms/"]]}]]

Expand Down
19 changes: 8 additions & 11 deletions src/main/frontend/components/plugins.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@
(ui/admonition
:warning
[:p.text-md
"Plugins can access your graph and your local files, issue network requests.
They can also cause data corruption or loss. We're working on proper access rules for your graphs.
Meanwhile, make sure you have regular backups of your graphs and only install the plugins when you can read and
understand the source code."]))
(t :plugin/security-warning)]))

(rum/defc card-ctls-of-market < rum/static
[item stat installed? installing-or-updating?]
Expand Down Expand Up @@ -365,7 +362,7 @@
(.focus target))}
(ui/icon "x")])
[:input.form-input.is-small
{:placeholder "Search plugins"
{:placeholder (t :plugin/search-plugin)
:ref *search-ref
:auto-focus true
:on-key-down (fn [^js e]
Expand Down Expand Up @@ -585,11 +582,11 @@

(when (state/developer-mode?)
[{:hr true}
{:title [:span.flex.items-center (ui/icon "file-code") "Open Preferences"]
{:title [:span.flex.items-center (ui/icon "file-code") (t :plugin/open-preferences)]
:options {:on-click
#(p/let [root (plugin-handler/get-ls-dotdir-root)]
(js/apis.openPath (str root "/preferences.json")))}}
{:title [:span.flex.items-center (ui/icon "bug") "Open\u00A0" [:code "~/.logseq"]]
{:title [:span.flex.items-center (ui/icon "bug") (str (t :plugin/open-logseq-dir) "\u00A0") [:code "~/.logseq"]]
:options {:on-click
#(p/let [root (plugin-handler/get-ls-dotdir-root)]
(js/apis.openPath root))}}]))
Expand Down Expand Up @@ -730,7 +727,7 @@
[:p.flex.justify-center.py-20 svg/loading]

@*error
[:p.flex.justify-center.pt-20.opacity-50 "Remote error: " (.-message @*error)]
[:p.flex.justify-center.pt-20.opacity-50 (t :plugin/remote-error) (.-message @*error)]

:else
[:div.cp__plugins-marketplace-cnt
Expand Down Expand Up @@ -895,7 +892,7 @@
[:span.opacity-30.hover:opacity-80 (ui/icon "info-circle")]))]])]

;; all done
[:div.py-4 [:strong.text-4xl "\uD83C\uDF89 All updated!"]])
[:div.py-4 [:strong.text-4xl (str "\uD83C\uDF89 " (t :plugin/all-updated))]])

;; actions
(when (seq updates)
Expand Down Expand Up @@ -1183,7 +1180,7 @@
[sub-content, _set-sub-content!] (rum-utils/use-atom *updates-sub-content)
notify! (fn [content status]
(if auto-checking?
(println "Plugin Updates: " content)
(println (t :plugin/list-of-updates) content)
(let [cb #(plugin-handler/cancel-user-checking!)]
(try
(set-uid (notification/show! content status false uid nil cb))
Expand All @@ -1195,7 +1192,7 @@
(if check-pending?
(notify!
[:div
[:div (str "Checking for plugin updates ...")]
[:div (str (t :plugin/checking-for-updates))]
(when sub-content [:p.opacity-60 sub-content])]
(ui/loading ""))
(when uid (notification/clear! uid))))
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/components/right_sidebar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(when-not (util/sm-breakpoint?)
(ui/with-shortcut :ui/toggle-right-sidebar "left"
[:button.button.icon.toggle-right-sidebar
{:title "Toggle right sidebar"
{:title (t :right-side-bar/toggle-right-sidebar)
:on-click ui-handler/toggle-right-sidebar!}
(ui/icon "layout-sidebar-right" {:size 20})])))

Expand Down
8 changes: 4 additions & 4 deletions src/main/frontend/components/search.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@

:else
(do (log/error "search result with non-existing uuid: " data)
(str "Cache is outdated. Please click the 'Re-index' button in the graph's dropdown menu."))))])
(str (t :search/cache-outdated)))))])

:page-content
(let [{:block/keys [snippet uuid]} data ;; content here is normalized
Expand All @@ -327,7 +327,7 @@
(if page
(page-content-search-result-item repo uuid format snippet search-q search-mode)
(do (log/error "search result with non-existing uuid: " data)
(str "Cache is outdated. Please click the 'Re-index' button in the graph's dropdown menu."))))]))
(str (t :search/cache-outdated)))))]))

nil)]))

Expand Down Expand Up @@ -396,11 +396,11 @@
[in-page-search?]
[:div.recent-search
[:div.wrap.px-4.pb-2.text-sm.opacity-70.flex.flex-row.justify-between.align-items.mx-1.sm:mx-0
[:div "Recent search:"]
[:div (t :search/recent)]
[:div.hidden.md:flex
(ui/with-shortcut :go/search-in-page "bottom"
[:div.flex-row.flex.align-items
[:div.mr-3.flex "Search blocks in page:"]
[:div.mr-3.flex (t :search/blocks-in-page)]
[:div.flex.items-center
(ui/toggle in-page-search?
(fn [_value]
Expand Down
25 changes: 25 additions & 0 deletions src/resources/dicts/en.edn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
:on-boarding/tour-whiteboard-home-description "Whiteboards have their own section in the app where you can see them at a glance, create new ones or delete them easily."
:on-boarding/tour-whiteboard-new "{1} Create new whiteboard"
:on-boarding/tour-whiteboard-new-description "There are multiple ways of creating a new whiteboard. One of them is always right here in the dashboard."
:help/title-usage "Usage"
:help/title-community "Community"
:help/title-development "Development"
:help/title-about "About"
:help/title-terms "Terms"
:help/start "Getting started"
:help/about "About Logseq"
:help/roadmap "Roadmap"
Expand All @@ -41,6 +46,9 @@
:search/result-for "Search result for "
:search/items "items"
:search/page-names "Search page names"
:search/recent "Recent search:"
:search/blocks-in-page "Search blocks in page:"
:search/cache-outdated "Cache is outdated. Please click the 'Re-index' button in the graph's dropdown menu."
:search-item/whiteboard "Whiteboard"
:search-item/page "Page"
:search-item/file "File"
Expand All @@ -67,6 +75,7 @@
:right-side-bar/new-page "New page"
:right-side-bar/show-journals "Show Journals"
:right-side-bar/separator "Right sidebar resize handler"
:right-side-bar/toggle-right-sidebar "Toggle right sidebar"
:left-side-bar/journals "Journals"
:left-side-bar/create "Create"
:left-side-bar/new-page "New page"
Expand Down Expand Up @@ -402,6 +411,7 @@
:plugin/found-updates "New updates"
:plugin/found-n-updates "Found {1} updates"
:plugin/update-all-selected "Update all of selected"
:plugin/all-updated "All updated!"
:plugin/updates-downloading "Downloading updates"
:plugin/refresh-lists "Refresh lists"
:plugin/enabled "Enabled"
Expand All @@ -424,6 +434,16 @@
:plugin/contribute "✨ Write and submit new plugin"
:plugin/up-to-date "It's up to date"
:plugin/custom-js-alert "Found the custom.js file, is it allowed to execute? (If you don't understand the content of this file, it is recommended not to allow execution, which has certain security risks.)"
:plugin/security-warning "Plugins can access your graph and your local files, issue network requests.
They can also cause data corruption or loss. We're working on proper access rules for your graphs.
Meanwhile, make sure you have regular backups of your graphs and only install the plugins when you can read and
understand the source code."
:plugin/search-plugin "Search plugins"
:plugin/open-preferences "Open Preferences"
:plugin/open-logseq-dir "Open"
:plugin/remote-error "Remote error: "
:plugin/checking-for-updates "Checking for plugin updates ..."
:plugin/list-of-updates "Plugin Updates: "
:plugin.install-from-file/menu-title "Install from plugins.edn"
:plugin.install-from-file/title "Install plugins from plugins.edn"
:plugin.install-from-file/notice "The following plugins will replace your plugins:"
Expand Down Expand Up @@ -473,6 +493,11 @@
:window/close "Close"
:window/exit-fullscreen "Exit full screen"

:header/toggle-left-sidebar "Toggle left sidebar"
:header/search "Search"
:header/more "More"
:header/go-back "Go back"
:header/go-forward "Go forward"
;; Commands are nested for now to stay in sync with the shortcuts system.
;; Other languages should not nest keys under :commands
:commands
Expand Down

0 comments on commit 9fcaebf

Please sign in to comment.