fix: improve page i18n

pull/991/head
Yukun Guo 2020-12-23 18:30:01 +08:00 committed by Tienson Qin
parent a346102a3f
commit 5a03d963d5
2 changed files with 65 additions and 65 deletions

View File

@ -11,8 +11,6 @@
[frontend.handler.editor :as editor-handler]
[frontend.state :as state]
[clojure.string :as string]
[frontend.db :as db]
[dommy.core :as d]
[frontend.components.block :as block]
[frontend.components.editor :as editor]
[frontend.components.reference :as reference]
@ -125,66 +123,68 @@
(defn delete-page-dialog
[page-name]
(fn [close-fn]
[:div
[:div.sm:flex.sm:items-start
[:div.mx-auto.flex-shrink-0.flex.items-center.justify-center.h-12.w-12.rounded-full.bg-red-100.sm:mx-0.sm:h-10.sm:w-10
[:svg.h-6.w-6.text-red-600
{:stroke "currentColor", :view-box "0 0 24 24", :fill "none"}
[:path
{:d
"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
:stroke-width "2"
:stroke-linejoin "round"
:stroke-linecap "round"}]]]
[:div.mt-3.text-center.sm:mt-0.sm:ml-4.sm:text-left
[:h3#modal-headline.text-lg.leading-6.font-medium.text-gray-900
"Are you sure you want to delete this page?"]]]
(rum/with-context [[t] i18n/*tongue-context*]
[:div
[:div.sm:flex.sm:items-start
[:div.mx-auto.flex-shrink-0.flex.items-center.justify-center.h-12.w-12.rounded-full.bg-red-100.sm:mx-0.sm:h-10.sm:w-10
[:svg.h-6.w-6.text-red-600
{:stroke "currentColor", :view-box "0 0 24 24", :fill "none"}
[:path
{:d
"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
:stroke-width "2"
:stroke-linejoin "round"
:stroke-linecap "round"}]]]
[:div.mt-3.text-center.sm:mt-0.sm:ml-4.sm:text-left
[:h3#modal-headline.text-lg.leading-6.font-medium.text-gray-900
(t :page/delete-confirmation)]]]
[:div.mt-5.sm:mt-4.sm:flex.sm:flex-row-reverse
[:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click (fn []
(delete-page! page-name))}
"Yes"]]
[:span.mt-3.flex.w-full.rounded-md.shadow-sm.sm:mt-0.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-gray-300.px-4.py-2.bg-white.text-base.leading-6.font-medium.text-gray-700.shadow-sm.hover:text-gray-500.focus:outline-none.focus:border-blue-300.focus:shadow-outline-blue.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click close-fn}
"Cancel"]]]]))
[:div.mt-5.sm:mt-4.sm:flex.sm:flex-row-reverse
[:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click (fn []
(delete-page! page-name))}
(t :yes)]]
[:span.mt-3.flex.w-full.rounded-md.shadow-sm.sm:mt-0.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-gray-300.px-4.py-2.bg-white.text-base.leading-6.font-medium.text-gray-700.shadow-sm.hover:text-gray-500.focus:outline-none.focus:border-blue-300.focus:shadow-outline-blue.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click close-fn}
(t :cancel)]]]])))
(rum/defcs rename-page-dialog-inner <
(rum/local "" ::input)
[state page-name close-fn]
(let [input (get state ::input)]
[:div
[:div.sm:flex.sm:items-start
[:div.mt-3.text-center.sm:mt-0.sm:text-left
[:h3#modal-headline.text-lg.leading-6.font-medium.text-gray-900
(str "Rename \"" page-name "\" to:")]]]
(rum/with-context [[t] i18n/*tongue-context*]
[:div
[:div.sm:flex.sm:items-start
[:div.mt-3.text-center.sm:mt-0.sm:text-left
[:h3#modal-headline.text-lg.leading-6.font-medium.text-gray-900
(t :page/rename-to page-name)]]]
[:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2
{:auto-focus true
:style {:color "#000"}
:on-change (fn [e]
(reset! input (util/evalue e)))}]
[:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2
{:auto-focus true
:style {:color "#000"}
:on-change (fn [e]
(reset! input (util/evalue e)))}]
[:div.mt-5.sm:mt-4.sm:flex.sm:flex-row-reverse
[:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click (fn []
(let [value @input]
(let [value (string/trim value)]
(when-not (string/blank? value)
(page-handler/rename! page-name value)
(state/close-modal!)))))}
"Submit"]]
[:span.mt-3.flex.w-full.rounded-md.shadow-sm.sm:mt-0.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-gray-300.px-4.py-2.bg-white.text-base.leading-6.font-medium.text-gray-700.shadow-sm.hover:text-gray-500.focus:outline-none.focus:border-blue-300.focus:shadow-outline-blue.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click close-fn}
"Cancel"]]]]))
[:div.mt-5.sm:mt-4.sm:flex.sm:flex-row-reverse
[:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click (fn []
(let [value @input]
(let [value (string/trim value)]
(when-not (string/blank? value)
(page-handler/rename! page-name value)
(state/close-modal!)))))}
(t :submit)]]
[:span.mt-3.flex.w-full.rounded-md.shadow-sm.sm:mt-0.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-gray-300.px-4.py-2.bg-white.text-base.leading-6.font-medium.text-gray-700.shadow-sm.hover:text-gray-500.focus:outline-none.focus:border-blue-300.focus:shadow-outline-blue.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click close-fn}
(t :cancel)]]]])))
(defn rename-page-dialog
[page-name]
@ -237,7 +237,7 @@
priority-page?
[:div.page
[:h1.title
(str "Priority \"" (string/upper-case page-name) "\"")]
(t :page/priority (string/upper-case page-name))]
[:div.ml-2
(reference/references page-name false true)]]

View File

@ -226,8 +226,8 @@ title: How to take dummy notes?
:page/edit-properties-placeholder "Click here to edit this page's properties"
:page/delete-success "Page {1} was deleted successfully!"
:page/delete-confirmation "Are you sure you want to delete this page?"
:page/rename-to "Rename {1}\" to:\""
:page/priority "Priority {1}\"\""
:page/rename-to "Rename \"{1}\" to:"
:page/priority "Priority \"{1}\""
:page/re-index "Re-index this page"
:page/copy-to-json "Copy the whole page as JSON"
:page/rename "Rename page"
@ -443,8 +443,8 @@ title: How to take dummy notes?
:page/presentation-mode "Mode présentation (avec Reveal.js)"
:page/delete-success "Page {1} supprimée !"
:page/delete-confirmation "Etes-vous sûr de vouloir supprimer la page ?"
:page/rename-to "Renommer {1}\" en:\""
:page/priority "Priorité {1}\"\""
:page/rename-to "Renommer \"{1}\" en:"
:page/priority "Priorité \"{1}\""
:page/re-index "Indexer à nouveau cette page"
:page/copy-to-json "Copier la page au format JSON"
:page/rename "Renommer la page"
@ -701,8 +701,8 @@ title: How to take dummy notes?
:page/presentation-mode "演讲模式 (由 Reveal.js 驱动)"
:page/delete-success "页面 {1} 删除成功!"
:page/delete-confirmation "您确定要删除此页面吗?"
:page/rename-to "重命名{1}\" 至:\""
:page/priority "优先级 {1}\""
:page/rename-to "重命名 \"{1}\" 至:"
:page/priority "优先级 \"{1}\""
:page/re-index "对此页面重新建立索引"
:page/copy-to-json "将整页以 JSON 格式复制"
:page/rename "重命名本页"
@ -963,8 +963,8 @@ title: How to take dummy notes?
:page/presentation-mode "演講模式 (由 Reveal.js 驅動)"
:page/delete-success "頁面 {1} 刪除成功!"
:page/delete-confirmation "您確定要刪除此頁面嗎?"
:page/rename-to "重命名{1}\" 至:\""
:page/priority "優先級 {1}\""
:page/rename-to "重命名 \"{1}\" 至:"
:page/priority "優先級 \"{1}\""
:page/re-index "對此頁面重新建立索引"
:page/copy-to-json "將整頁以 JSON 格式復制"
:page/rename "重命名本頁"
@ -1215,8 +1215,8 @@ title: How to take dummy notes?
:page/presentation-mode "Aanbiedings modus (gedryf deur Reveal.js)"
:page/delete-success "Bladsy {1} is suksesvol uitgevee!"
:page/delete-confirmation "Is jy seker jy wil die bladsy uitvee?"
:page/rename-to "Hernoem {1} na: \"\""
:page/priority "Prioriteit {1}\""
:page/rename-to "Hernoem \"{1}\" na:"
:page/priority "Prioriteit \"{1}\""
:page/re-index "Re-index this page"
:page/copy-to-json "Kopieer die hele bladsy as JSON"
:page/rename "Hernoem die bladsy"