From d390842a07fbbdbda60ec332b0874c40e1c3b5a4 Mon Sep 17 00:00:00 2001 From: Andelf Date: Fri, 8 Jul 2022 11:05:26 +0800 Subject: [PATCH] fix(editor): new-page auto-completion under non-en environment Fix #5965 --- src/main/frontend/handler/page.cljs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/frontend/handler/page.cljs b/src/main/frontend/handler/page.cljs index 900b6190f..2cfdcf63e 100644 --- a/src/main/frontend/handler/page.cljs +++ b/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