enhance(i18n): add more localization support for linked references view (#10643)

* Add more localization to the references UI, fix English grammar

* Version 2 which uses tongue properly!

* Fix bugs after testing!

* So sorry, missed one line

* Untested fixes

* Fix typo

---------

Co-authored-by: Gabriel Horner <97210743+logseq-cldwalker@users.noreply.github.com>
This commit is contained in:
Vivianne
2023-12-13 16:44:48 -05:00
committed by GitHub
parent b7ba2e8f7e
commit 73cc4e3aa5
3 changed files with 29 additions and 18 deletions

View File

@@ -62,18 +62,18 @@
[:div.mx-auto.flex-shrink-0.flex.items-center.justify-center.h-12.w-12.rounded-full.bg-gray-200.text-gray-500.sm:mx-0.sm:h-10.sm:w-10
(ui/icon "filter" {:size 20})]
[:div.mt-3.text-center.sm:mt-0.sm:ml-4.sm:text-left.pb-2
[:h3#modal-headline.text-lg.leading-6.font-medium "Filter"]
[:h3#modal-headline.text-lg.leading-6.font-medium (t :linked-references/filter-heading)]
[:span.text-xs
"Click to include and shift-click to exclude. Click again to remove."]]]
(t :linked-references/filter-directions)]]]
(when (seq filters)
[:div.cp__filters.mb-4.ml-2
(when (seq includes)
[:div.flex.flex-row.flex-wrap.center-items
[:div.mr-1.font-medium.py-1 "Includes: "]
[:div.mr-1.font-medium.py-1 (t :linked-references/filter-includes)]
(filtered-refs page-name filters filters-atom includes)])
(when (seq excludes)
[:div.flex.flex-row.flex-wrap
[:div.mr-1.font-medium.py-1 "Excludes: " ]
[:div.mr-1.font-medium.py-1 (t :linked-references/filter-excludes)]
(filtered-refs page-name filters filters-atom excludes)])])
[:div.cp__filters-input-panel.flex
(ui/icon "search")
@@ -133,14 +133,9 @@
*collapsed? (atom nil)]
(ui/foldable
[:div.flex.flex-row.flex-1.justify-between.items-center
[:h2.font-medium (str
(when (seq filters)
(str filter-n " of "))
total
" Linked Reference"
(when (> total 1) "s"))]
[:h2.font-medium (t :linked-references/reference-count (if (seq filters) filter-n nil) total)]
[:a.filter.fade-link
{:title "Filter"
{:title (t :linked-references/filter-heading)
:on-mouse-over (fn [_e]
(when @*collapsed? ; collapsed
;; expand
@@ -252,7 +247,7 @@
(rum/defc references
[page-name]
(ui/catch-error
(ui/component-error "Linked References: Unexpected error. Please re-index your graph first.")
(ui/component-error (t :linked-references/unexpected-error))
(ui/lazy-visible
(fn []
(references* page-name))
@@ -291,11 +286,7 @@
[:div.references.page-unlinked.mt-6.flex-1.flex-row
[:div.content.flex-1
(ui/foldable
[:h2.font-medium
(if @n-ref
(str @n-ref " Unlinked Reference" (when (> @n-ref 1)
"s"))
"Unlinked References")]
[:h2.font-medium (t :unlinked-references/reference-count @n-ref)]
(fn [] (unlinked-references-aux page-name n-ref))
{:default-collapsed? true
:title-trigger? true})]]))))

View File

@@ -283,7 +283,7 @@
"text-md px-3 py-2 cursor-default whiteboard-page-refs-count"
{:hover? true
:render-fn (fn [open? refs-count] [:span.whiteboard-page-refs-count-label
(if (> refs-count 1) "References" "Reference")
(t :whiteboard/reference-count refs-count)
(ui/icon (if open? "references-hide" "references-show")
{:extension? true})])})]]
(tldraw-app page-name block-id)]))

View File

@@ -221,6 +221,25 @@
:page/updated-at "Updated At"
:page/backlinks "Backlinks"
:linked-references/filter-search "Search in linked pages"
:linked-references/unexpected-error "Linked References: Unexpected error. Please re-index your graph first."
:linked-references/filter-heading "Filter"
:linked-references/filter-directions "Click to include and shift-click to exclude. Click again to remove."
:linked-references/filter-includes "Includes: "
:linked-references/filter-excludes "Excludes: "
:linked-references/reference-count (fn [filtered-count total]
;; 1 Linked Reference
;; 1 of 1 Linked Reference
;; 2 of 5 Linked References
(str
(when filtered-count
(str filtered-count " of "))
total
(if (= total 1) " Linked Reference" " Linked References")))
:unlinked-references/reference-count (fn [total]
;; 1 Unlinked Reference
;; 5 Unlinked References
(str total
(if (= total 1) " Unlinked Reference" " Unlinked References")))
:editor/block-search "Search for a block"
:text/image "Image"
:asset/show-in-folder "Show image in folder"
@@ -460,6 +479,7 @@
:whiteboard/toggle-grid "Toggle grid"
:whiteboard/snap-to-grid "Snap to grid"
:whiteboard/toggle-pen-mode "Toggle pen mode"
:whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Reference" "References"))
:flashcards/modal-welcome-title "Time to create a card!"
:flashcards/modal-welcome-desc-1 "You can add \"#card\" to any block to turn it into a card or trigger \"/cloze\" to add some clozes."
:flashcards/modal-welcome-desc-2 "You can "