瀏覽代碼

fix(editor): new-page auto-completion under non-en environment

Fix #5965
Andelf 3 年之前
父節點
當前提交
d390842a07
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      src/main/frontend/handler/page.cljs

+ 7 - 4
src/main/frontend/handler/page.cljs

@@ -5,6 +5,7 @@
             [datascript.core :as d]
             [frontend.commands :as commands]
             [frontend.config :as config]
+            [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
             [logseq.db.schema :as db-schema]
@@ -716,8 +717,9 @@
       (fn [chosen _click?]
         (state/clear-editor-action!)
         (let [wrapped? (= "[[" (gp-util/safe-subs edit-content (- pos 2) pos))
-              chosen (if (string/starts-with? chosen "New page: ") ;; FIXME: What if a page named "New page: XXX"?
-                       (subs chosen 10)
+              prefix (str (t :new-page) ": ")
+              chosen (if (string/starts-with? chosen prefix) ;; FIXME: What if a page named "New page: XXX"?
+                       (string/replace-first chosen prefix "")
                        chosen)
               chosen (if (and (util/safe-re-find #"\s+" chosen) (not wrapped?))
                        (util/format "[[%s]]" chosen)
@@ -737,8 +739,9 @@
                                            :forward-pos forward-pos})))
       (fn [chosen _click?]
         (state/clear-editor-action!)
-        (let [chosen (if (string/starts-with? chosen "New page: ")
-                       (subs chosen 10)
+        (let [prefix (str (t :new-page) ": ")
+              chosen (if (string/starts-with? chosen prefix)
+                       (string/replace-first chosen prefix "")
                        chosen)
               page-ref-text (get-page-ref-text chosen)]
           (editor-handler/insert-command! id