Explorar o código

show partialContentWarnLabel

Yuki Takei hai 9 meses
pai
achega
a43fce72a4

+ 2 - 0
apps/app/public/static/locales/en_US/translation.json

@@ -511,6 +511,8 @@
     "budget_exceeded_for_growi_cloud": "You have reached your OpenAI API usage limit. To use the Knowledge Assistant again, please add credits from the GROWI.cloud admin page for Hosted users or from the OpenAI billing page for Owned users.",
     "error_message": "An error has occurred",
     "show_error_detail": "Show error details",
+    "editor_assistant_long_context_warn_with_unit_line": "The text is too long, so the Editor Assistant will reference approximately lines {{startPosition}} to {{endPosition}} for its response.",
+    "editor_assistant_long_context_warn_with_unit_char": "The text is too long, so the Editor Assistant will reference characters {{startPosition}} to {{endPosition}} for its response.",
     "discard": "Discard",
     "accept": "Accept",
     "use_assistant": "Use Assistant",

+ 3 - 1
apps/app/public/static/locales/fr_FR/translation.json

@@ -505,6 +505,8 @@
     "budget_exceeded_for_growi_cloud": "Vous avez atteint votre limite d'utilisation de l'API de l'OpenAI. Pour utiliser à nouveau l'assistant de connaissance, veuillez ajouter des crédits à partir de la page d'administration de GROWI.cloud pour les utilisateurs hébergés ou à partir de la page de facturation de l'OpenAI pour les utilisateurs propriétaires.",
     "error_message": "Erreur",
     "show_error_detail": "Détails de l'exposition",
+    "editor_assistant_long_context_warn_with_unit_line": "Le texte est trop long, l'Assistant de rédaction se référera approximativement aux lignes {{startPosition}} à {{endPosition}} pour sa réponse.",
+    "editor_assistant_long_context_warn_with_unit_char": "Le texte est trop long, l'Assistant de rédaction se référera aux caractères {{startPosition}} à {{endPosition}} pour sa réponse.",
     "discard": "Annuler",
     "accept": "Accepter",
     "use_assistant": "Utiliser l'assistant",
@@ -595,7 +597,7 @@
   "default_ai_assistant": {
     "not_set": "L'assistant par défaut n'est pas configuré"
   },
- "ai_assistant_tree": {
+  "ai_assistant_tree": {
     "add_assistant": "Ajouter un assistant",
     "my_assistants": "Mes assistants",
     "team_assistants": "Assistants d'équipe",

+ 2 - 0
apps/app/public/static/locales/ja_JP/translation.json

@@ -543,6 +543,8 @@
     "budget_exceeded_for_growi_cloud": "OpenAI の API の利用上限に達しました。ナレッジアシスタントを再度利用するには Hosted の場合は GROWI.cloud の管理画面から Owned の場合は OpenAI の請求ページからクレジットを追加してください。",
     "error_message": "エラーが発生しました",
     "show_error_detail": "詳細を表示",
+    "editor_assistant_long_context_warn_with_unit_line": "本文が長すぎるため、エディターアシスタントは {{startPosition}}行から{{endPosition}}行付近までを参照して回答します",
+    "editor_assistant_long_context_warn_with_unit_char": "本文が長すぎるため、エディターアシスタントは {{startPosition}}文字目から{{endPosition}}文字目までを参照して回答します",
     "discard": "破棄",
     "accept": "採用",
     "use_assistant": "アシスタントを使用する",

+ 19 - 17
apps/app/public/static/locales/zh_CN/translation.json

@@ -123,8 +123,8 @@
   "V5 Page Migration": "转换为V5的兼容性",
   "GROWI.5.0_new_schema": "GROWI.5.0 new schema",
   "See_more_detail_on_new_schema": "更多详情请见<a href='https://docs.growi.org/en/admin-guide/upgrading/50x.html#about-the-new-v5-compatible-format' target='_blank'> {{title}}</a> <span class='growi-custom-icons'>external_link</span> ",
-	"Markdown Settings": "Markdown设置",
-	"external_account_management": "外部账户管理",
+  "Markdown Settings": "Markdown设置",
+  "external_account_management": "外部账户管理",
   "UserGroup": "用户组",
   "ChildUserGroup": "儿童用户组",
   "Basic Settings": "基础设置",
@@ -192,12 +192,12 @@
   "custom_navigation": {
     "no_pages_under_this_page": "There are no pages under this page."
   },
-"author_info": {
-  "created_at": "创建日期",
-  "created_by": "创建者:",
-  "last_revision_posted_at": "最后更新日期",
-  "updated_by": "更新者:"
-},
+  "author_info": {
+    "created_at": "创建日期",
+    "created_by": "创建者:",
+    "last_revision_posted_at": "最后更新日期",
+    "updated_by": "更新者:"
+  },
   "installer": {
     "tab": "创建账户",
     "title": "安装",
@@ -321,9 +321,9 @@
       "no_deadline": "此页面没有到期日期",
       "not_indexed1": "此页面可能不会被全文搜索引擎索引。",
       "not_indexed2": "页面正文超过了{{threshold}}指定的阈值。"
-		}
-	},
-	"page_edit": {
+    }
+  },
+  "page_edit": {
     "input_channels": "频道名",
     "theme": "主题",
     "keymap": "键表",
@@ -336,12 +336,12 @@
     },
     "editor_config": "编辑器配置",
     "editor_assistant": "编辑助手",
-		"Show active line": "显示活动行",
-		"auto_format_table": "自动格式化表格",
-		"overwrite_scopes": "{{operation}和覆盖所有子体的作用域",
-		"notice": {
-			"conflict": "无法保存您所做的更改,因为其他人正在编辑此页。请在重新加载页面后重新编辑受影响的部分。"
-		},
+    "Show active line": "显示活动行",
+    "auto_format_table": "自动格式化表格",
+    "overwrite_scopes": "{{operation}和覆盖所有子体的作用域",
+    "notice": {
+      "conflict": "无法保存您所做的更改,因为其他人正在编辑此页。请在重新加载页面后重新编辑受影响的部分。"
+    },
     "changes_not_saved": "您所做的更改可能不会保存。你真的想继续前进吗?"
   },
   "page_comment": {
@@ -500,6 +500,8 @@
     "budget_exceeded_for_growi_cloud": "您已达到 OpenAI API 使用上限。如需再次使用知识助手,请从GROWI.cloud管理页面为托管用户添加点数,或从OpenAI计费页面为自有用户添加点数。",
     "error_message": "错误",
     "show_error_detail": "显示详情",
+    "editor_assistant_long_context_warn_with_unit_line": "文本过长,编辑助理将参考大约第 {{startPosition}} 行到第 {{endPosition}} 行来响应",
+    "editor_assistant_long_context_warn_with_unit_char": "文本过长,编辑助理将参考第 {{startPosition}} 个字符到第 {{endPosition}} 个字符来响应",
     "discard": "丢弃",
     "accept": "接受",
     "use_assistant": "使用助手",

+ 6 - 3
apps/app/src/features/openai/client/services/editor-assistant/use-editor-assistant.tsx

@@ -477,6 +477,7 @@ export const useEditorAssistant: UseEditorAssistant = () => {
       if (!doc) return 1;
 
       try {
+        // return line number if possible
         return doc.lineAt(index).number;
       }
       catch {
@@ -489,16 +490,18 @@ export const useEditorAssistant: UseEditorAssistant = () => {
     const startPosition = getPositionNumber(partialContentInfo.startIndex);
     const endPosition = getPositionNumber(partialContentInfo.endIndex);
 
-    const unit = isLineMode ? '行目' : '文字目';
+    const translationKey = isLineMode
+      ? 'sidebar_ai_assistant.editor_assistant_long_context_warn_with_unit_line'
+      : 'sidebar_ai_assistant.editor_assistant_long_context_warn_with_unit_char';
 
     return (
       <div className="alert alert-warning py-2 px-3 mb-3" role="alert">
         <small>
-          本文が長すぎるため、エディターアシスタントは {startPosition}{unit}から{endPosition}{unit}付近までを参照して回答します
+          {t(translationKey, { startPosition, endPosition })}
         </small>
       </div>
     );
-  }, [partialContentInfo, codeMirrorEditor]);
+  }, [partialContentInfo, t, codeMirrorEditor]);
 
   return {
     createThread,