kaori hace 3 años
padre
commit
aaf1097d89

+ 2 - 1
packages/app/public/static/locales/en_US/translation.json

@@ -387,7 +387,8 @@
     "overwrite_scopes": "{{operation}} and Overwrite scopes of all descendants",
     "notice": {
       "conflict": "Couldn't save the changes you made because someone else was editing this page. Please re-edit the affected section after reloading the page."
-    }
+    },
+    "changes_not_saved": "Changes you made may not be saved."
   },
   "page_comment": {
     "display_the_page_when_posting_this_comment": "Display the page when posting this comment",

+ 2 - 1
packages/app/public/static/locales/zh_CN/translation.json

@@ -366,7 +366,8 @@
 		"overwrite_scopes": "{{operation}和覆盖所有子体的作用域",
 		"notice": {
 			"conflict": "无法保存您所做的更改,因为其他人正在编辑此页。请在重新加载页面后重新编辑受影响的部分。"
-		}
+		},
+    "changes_not_saved": "您所做的更改可能不会保存。"
   },
   "page_comment": {
     "display_the_page_when_posting_this_comment": "Display the page when posting this comment",

+ 4 - 2
packages/app/src/pages/UnsavedAlertDialog.tsx

@@ -1,10 +1,12 @@
 import { useCallback, useEffect } from 'react';
 
 import { useRouter } from 'next/router';
+import { useTranslation } from 'react-i18next';
 
 import { useIsEnabledUnsavedWarning } from '~/stores/editor';
 
 const UnsavedAlertDialog = (): void => {
+  const { t } = useTranslation();
   const router = useRouter();
   const { data: isEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
 
@@ -22,10 +24,10 @@ const UnsavedAlertDialog = (): void => {
   const alertUnsavedWarningByNextRouter = useCallback(() => {
     if (isEnabledUnsavedWarning) {
     // eslint-disable-next-line no-alert
-      window.alert('Changes you made may not be saved.');
+      window.alert(t('page_edit.changes_not_saved'));
     }
     return;
-  }, [isEnabledUnsavedWarning]);
+  }, [isEnabledUnsavedWarning, t]);
 
   /*
   * Route changes by Browser