Răsfoiți Sursa

improve(pdf): i18n

charlie 4 ani în urmă
părinte
comite
2b569604c0

+ 17 - 3
src/main/frontend/dicts.cljs

@@ -240,6 +240,7 @@
         :submit "Submit"
         :cancel "Cancel"
         :close "Close"
+        :delete "Delete"
         :re-index "Re-index"
         :unlink "unlink"
         :search (if config/publishing?
@@ -299,7 +300,10 @@
         :user/delete-your-account "Delete your account"
         :user/delete-account-notice "All your published pages on logseq.com will be deleted."
 
-        :help/shortcut-page-title "Keyboard shortcuts"}
+        :help/shortcut-page-title "Keyboard shortcuts"
+
+        :pdf/copy-ref "Copy ref"
+        :pdf/copy-text "Copy text"}
 
    :de {:help/about "Über Logseq"
         :help/bug "Fehlerbericht"
@@ -939,6 +943,8 @@
            :help-shortcut-title "点此查看快捷方式和更多有用帮助"
            :loading "加载中"
            :cloning "Clone 中"
+           :close "关闭"
+           :delete "删除"
            :parsing-files "正在解析文件"
            :loading-files "正在加载文件"
            :login-github "用 Github 登录"
@@ -956,7 +962,10 @@
            :open-a-directory "打开本地文件夹"
            :user/delete-account "删除帐号"
            :user/delete-your-account "删除你的帐号"
-           :user/delete-account-notice "你在 logseq.com 发布的页面(假如有的话)也会被删除。"}
+           :user/delete-account-notice "你在 logseq.com 发布的页面(假如有的话)也会被删除。"
+
+           :pdf/copy-ref "复制引用"
+           :pdf/copy-text "复制文本"}
 
 
    :zh-Hant {:on-boarding/title "你好,歡迎使用 Logseq!"
@@ -1036,6 +1045,8 @@
              :highlight "高亮"
              :strikethrough "刪除線"
              :code "代碼"
+             :close "關閉"
+             :delete "删除"
              :right-side-bar/help "幫助"
              :right-side-bar/switch-theme "主題模式"
              :right-side-bar/theme "{1}主題"
@@ -1185,7 +1196,10 @@
              :language "語言"
              :white "亮色"
              :dark "暗黑"
-             :remove-background "去除背景"}
+             :remove-background "去除背景"
+
+             :pdf/copy-ref "復製引用"
+             :pdf/copy-text "復製文本"}
 
    :af {:on-boarding/title "Hi, welcome to Logseq!"
         :on-boarding/sharing "meedeling"

+ 77 - 70
src/main/frontend/extensions/pdf/highlights.cljs

@@ -3,6 +3,7 @@
             [promesa.core :as p]
             [cljs-bean.core :as bean]
             [medley.core :as medley]
+            [frontend.context.i18n :as i18n]
             [frontend.handler.notification :as notification]
             [frontend.extensions.pdf.utils :as pdf-utils]
             [frontend.extensions.pdf.assets :as pdf-assets]
@@ -91,52 +92,55 @@
         id (:id highlight)
         content (:content highlight)]
 
-    [:ul.extensions__pdf-hls-ctx-menu
-     {:style    {:top top :left left}
-      :on-click (fn [^js/MouseEvent e]
-                  (when-let [action (.. e -target -dataset -action)]
-                    (case action
-                      "ref"
-                      (pdf-assets/copy-hl-ref! highlight)
+    (rum/with-context
+      [[t] i18n/*tongue-context*]
 
-                      "copy"
-                      (do
-                        (front-utils/copy-to-clipboard! (:text content))
-                        (pdf-utils/clear-all-selection))
+      [:ul.extensions__pdf-hls-ctx-menu
+       {:style    {:top top :left left}
+        :on-click (fn [^js/MouseEvent e]
+                    (when-let [action (.. e -target -dataset -action)]
+                      (case action
+                        "ref"
+                        (pdf-assets/copy-hl-ref! highlight)
+
+                        "copy"
+                        (do
+                          (front-utils/copy-to-clipboard! (:text content))
+                          (pdf-utils/clear-all-selection))
 
-                      "del"
-                      (do
-                        (del-hl! highlight)
-                        (pdf-assets/del-ref-block! highlight))
+                        "del"
+                        (do
+                          (del-hl! highlight)
+                          (pdf-assets/del-ref-block! highlight))
 
-                      ;; colors
-                      (let [properties {:color action}]
-                        (if-not id
-                          ;; add highlight
-                          (let [highlight (merge highlight
-                                                 {:id         (pdf-utils/gen-uuid)
-                                                  :properties properties})]
-                            (add-hl! highlight)
-                            (pdf-utils/clear-all-selection)
-                            (pdf-assets/copy-hl-ref! highlight))
+                        ;; colors
+                        (let [properties {:color action}]
+                          (if-not id
+                            ;; add highlight
+                            (let [highlight (merge highlight
+                                                   {:id         (pdf-utils/gen-uuid)
+                                                    :properties properties})]
+                              (add-hl! highlight)
+                              (pdf-utils/clear-all-selection)
+                              (pdf-assets/copy-hl-ref! highlight))
 
-                          ;; update highlight
-                          (do
-                            (upd-hl! (assoc highlight :properties properties)))))))
+                            ;; update highlight
+                            (do
+                              (upd-hl! (assoc highlight :properties properties)))))))
 
-                  (clear-ctx-tip!))}
+                    (clear-ctx-tip!))}
 
-     [:li.item-colors
-      (for [it ["yellow", "blue", "green", "red", "purple"]]
-        [:a {:key it :data-color it :data-action it} it])]
+       [:li.item-colors
+        (for [it ["yellow", "blue", "green", "red", "purple"]]
+          [:a {:key it :data-color it :data-action it} it])]
 
 
-     (and id [:li.item {:data-action "ref"} "Copy ref"])
+       (and id [:li.item {:data-action "ref"} (t :pdf/copy-ref)])
 
-     [:li.item {:data-action "copy"} "Copy text"]
+       [:li.item {:data-action "copy"} (t :pdf/copy-text)]
 
-     (and id [:li.item {:data-action "del"} "Delete"])
-     ]))
+       (and id [:li.item {:data-action "del"} (t :delete)])
+       ])))
 
 (rum/defc pdf-highlights-text-region
   [^js viewer vw-hl hl
@@ -479,40 +483,43 @@
           #(js-delete (. el -dataset) "theme")))
       [viewer-theme])
 
-    [:div.extensions__pdf-toolbar
-     [:div.inner
-      [:div.r.flex
-
-       ;; appearance
-       [:a.button
-        {:on-click #(set-settings-visible! (not settings-visible?))}
-        (svg/adjustments 18)]
-
-       ;; zoom
-       [:a.button
-        {:on-click (partial pdf-utils/zoom-out-viewer viewer)}
-        (svg/zoom-out 18)]
-
-       [:a.button
-        {:on-click (partial pdf-utils/zoom-in-viewer viewer)}
-        (svg/zoom-in 18)]
-
-       [:a.button
-        {:on-click #(set-outline-visible! (not outline-visible?))}
-        (svg/view-list 16)]
-
-       [:a.button
-        {:on-click #(state/set-state! :pdf/current nil)}
-        "close"]]]
-
-     ;; contents outline
-     (pdf-outline viewer outline-visible? #(set-outline-visible! false))
-     ;; settings
-     (and settings-visible? (pdf-settings
-                              viewer
-                              viewer-theme
-                              {:hide-settings! #(set-settings-visible! false)
-                               :select-theme!  #(set-viewer-theme! %)}))]))
+    (rum/with-context
+      [[t] i18n/*tongue-context*]
+
+      [:div.extensions__pdf-toolbar
+       [:div.inner
+        [:div.r.flex
+
+         ;; appearance
+         [:a.button
+          {:on-click #(set-settings-visible! (not settings-visible?))}
+          (svg/adjustments 18)]
+
+         ;; zoom
+         [:a.button
+          {:on-click (partial pdf-utils/zoom-out-viewer viewer)}
+          (svg/zoom-out 18)]
+
+         [:a.button
+          {:on-click (partial pdf-utils/zoom-in-viewer viewer)}
+          (svg/zoom-in 18)]
+
+         [:a.button
+          {:on-click #(set-outline-visible! (not outline-visible?))}
+          (svg/view-list 16)]
+
+         [:a.button
+          {:on-click #(state/set-state! :pdf/current nil)}
+          (t :close)]]]
+
+       ;; contents outline
+       (pdf-outline viewer outline-visible? #(set-outline-visible! false))
+       ;; settings
+       (and settings-visible? (pdf-settings
+                                viewer
+                                viewer-theme
+                                {:hide-settings! #(set-settings-visible! false)
+                                 :select-theme!  #(set-viewer-theme! %)}))])))
 
 (rum/defc pdf-viewer
   [url initial-hls ^js pdf-document ops]