This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git

commit 8da81bae120ec0aeb7d649594eac13a0fe8b1f02
Author: robin <[email protected]>
AuthorDate: Thu May 30 17:00:15 2024 +0800

    feat(embed-basic): add i18n support for basic embed plugin
---
 embed-basic/Component.tsx   | 8 ++++++--
 embed-basic/i18n/en_US.yaml | 3 ++-
 embed-basic/i18n/zh_CN.yaml | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/embed-basic/Component.tsx b/embed-basic/Component.tsx
index b4ce9e1..4d920b7 100644
--- a/embed-basic/Component.tsx
+++ b/embed-basic/Component.tsx
@@ -19,15 +19,19 @@
 
 import { useState, useEffect } from 'react'
 import { Button } from 'react-bootstrap'
+import { useTranslation } from 'react-i18next'
 
 import EmbedModal from './modal'
 import { useRenderEmbed } from './hooks'
 
 const Component = ({ editor, previewElement }) => {
   const [show, setShowState] = useState(false)
-
+  const { t } = useTranslation('plugin', {
+    keyPrefix: 'basic_embed.frontend',
+  })
   useRenderEmbed(previewElement)
 
+
   useEffect(() => {
     if (!editor) return
     editor.addKeyMap({
@@ -55,7 +59,7 @@ const Component = ({ editor, previewElement }) => {
         variant="link"
         className="p-0 b-0 btn-no-border toolbar text-body"
         onClick={handleShow}
-        title="Embed (Ctrl+m)"
+        title={`${t('label')} (Ctrl+m)`}
       >
         <i className="bi bi-window" />
       </Button>
diff --git a/embed-basic/i18n/en_US.yaml b/embed-basic/i18n/en_US.yaml
index c47eb2a..c1bb817 100644
--- a/embed-basic/i18n/en_US.yaml
+++ b/embed-basic/i18n/en_US.yaml
@@ -55,4 +55,5 @@ plugin:
       add: Add
       required_title: Title is required 
       required_url: URL is required
-      invalid_url: Invalid URL
\ No newline at end of file
+      invalid_url: Invalid URL
+      label: Embed
\ No newline at end of file
diff --git a/embed-basic/i18n/zh_CN.yaml b/embed-basic/i18n/zh_CN.yaml
index f28ef41..65c4c10 100644
--- a/embed-basic/i18n/zh_CN.yaml
+++ b/embed-basic/i18n/zh_CN.yaml
@@ -56,3 +56,4 @@ plugin:
       required_title: 标题是必需的
       required_url: URL 是必需的
       invalid_url: 无效的 URL
+      label: 嵌入

Reply via email to