From 1db5696bc14223d7d40176c40a7b68c33fe58d23 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 6 Feb 2025 16:04:37 +0800 Subject: [PATCH] fix: 1052009 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1052009 --user=王孝刚 [国际化]修改密码的验证码通知邮件未国际化 https://www.tapd.cn/57709429/s/1651094 --- apps/common/template/email_template_en.html | 122 +++++++++++++++++ ...l_template.html => email_template_zh.html} | 1 - .../template/email_template_zh_Hant.html | 123 ++++++++++++++++++ .../serializers/document_serializers.py | 2 +- apps/locales/en_US/LC_MESSAGES/django.po | 2 +- apps/locales/zh_CN/LC_MESSAGES/django.po | 2 +- apps/users/serializers/user_serializers.py | 10 +- 7 files changed, 254 insertions(+), 8 deletions(-) create mode 100644 apps/common/template/email_template_en.html rename apps/common/template/{email_template.html => email_template_zh.html} (98%) create mode 100644 apps/common/template/email_template_zh_Hant.html diff --git a/apps/common/template/email_template_en.html b/apps/common/template/email_template_en.html new file mode 100644 index 000000000..c0fe75e72 --- /dev/null +++ b/apps/common/template/email_template_en.html @@ -0,0 +1,122 @@ + + + + + + + + + + +
+ + + + + + + + + +
+
+ Intelligent Knowledge Q&A System +
+
+
+

+ + + + Dear user: + +

+ +

+ ${code}  This is your dynamic verification code. Please fill it in within 30 minutes. To protect the security of your account, please do not provide this verification code to anyone. +

+
+ +
+
+

Intelligent knowledge base project team

+
+

+ Please do not reply to this system email
+

+ +
+
+
+
+
+ + diff --git a/apps/common/template/email_template.html b/apps/common/template/email_template_zh.html similarity index 98% rename from apps/common/template/email_template.html rename to apps/common/template/email_template_zh.html index dff0ab305..29c1fc65d 100644 --- a/apps/common/template/email_template.html +++ b/apps/common/template/email_template_zh.html @@ -107,7 +107,6 @@

此为系统邮件,请勿回复
- Please do not reply to this system email

diff --git a/apps/common/template/email_template_zh_Hant.html b/apps/common/template/email_template_zh_Hant.html new file mode 100644 index 000000000..d54d40231 --- /dev/null +++ b/apps/common/template/email_template_zh_Hant.html @@ -0,0 +1,123 @@ + + + + + + + + + + +
+ + + + + + + + + +
+
+ + 智慧知識庫問答系統 +
+
+
+

+ + + + 尊敬的用戶: + +

+ +

+ ${code}  為您的動態驗證碼,請於30分鐘內填寫,為保障帳戶安全,請勿向任何人提供此驗證碼。 +

+
+ +
+
+

智慧知識庫專案組

+
+

+ 此為系統郵件,請勿回覆
+

+ +
+
+
+
+
+ + diff --git a/apps/dataset/serializers/document_serializers.py b/apps/dataset/serializers/document_serializers.py index c8c616df3..b711182bc 100644 --- a/apps/dataset/serializers/document_serializers.py +++ b/apps/dataset/serializers/document_serializers.py @@ -249,7 +249,7 @@ class DocumentSerializers(ApiMixin, serializers.Serializer): return HttpResponse(content, status=200, headers={'Content-Type': 'text/cxv', 'Content-Disposition': 'attachment; filename="csv_template.csv"'}) elif self.data.get('type') == 'excel': - file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', f'csv_template_{to_locale(language)}.xlsx'), "rb") + file = open(os.path.join(PROJECT_DIR, "apps", "dataset", 'template', f'excel_template_{to_locale(language)}.xlsx'), "rb") content = file.read() file.close() return HttpResponse(content, status=200, headers={'Content-Type': 'application/vnd.ms-excel', diff --git a/apps/locales/en_US/LC_MESSAGES/django.po b/apps/locales/en_US/LC_MESSAGES/django.po index b52a6f1b7..9d06f91b8 100644 --- a/apps/locales/en_US/LC_MESSAGES/django.po +++ b/apps/locales/en_US/LC_MESSAGES/django.po @@ -4981,7 +4981,7 @@ msgstr "" #: .\apps\setting\models_provider\impl\volcanic_engine_model_provider\volcanic_engine_model_provider.py:115 msgid "volcano engine" -msgstr "Volcano Engine" +msgstr "Volcengine" #: .\apps\setting\models_provider\impl\wenxin_model_provider\credential\llm.py:50 #, python-brace-format diff --git a/apps/locales/zh_CN/LC_MESSAGES/django.po b/apps/locales/zh_CN/LC_MESSAGES/django.po index 37390a150..8f0db08cf 100644 --- a/apps/locales/zh_CN/LC_MESSAGES/django.po +++ b/apps/locales/zh_CN/LC_MESSAGES/django.po @@ -3698,7 +3698,7 @@ msgstr "语音合成" #: .\apps\setting\models_provider\base_model_provider.py:156 msgid "Vision Model" -msgstr "图片理解" +msgstr "视觉模型" #: .\apps\setting\models_provider\base_model_provider.py:157 msgid "Image Generation" diff --git a/apps/users/serializers/user_serializers.py b/apps/users/serializers/user_serializers.py index 401fd165f..6bea8c1c4 100644 --- a/apps/users/serializers/user_serializers.py +++ b/apps/users/serializers/user_serializers.py @@ -39,8 +39,8 @@ from function_lib.models.function import FunctionLib from setting.models import Team, SystemSetting, SettingType, Model, TeamMember, TeamMemberPermission from smartdoc.conf import PROJECT_DIR from users.models.user import User, password_encrypt, get_user_dynamics_permission -from django.utils.translation import gettext_lazy as _ - +from django.utils.translation import gettext_lazy as _, gettext, to_locale +from django.utils.translation import get_language user_cache = cache.caches['user_cache'] @@ -393,8 +393,10 @@ class SendEmailSerializer(ApiMixin, serializers.Serializer): code = "".join(list(map(lambda i: random.choice(['1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ]), range(6)))) # 获取邮件模板 - file = open(os.path.join(PROJECT_DIR, "apps", "common", 'template', 'email_template.html'), "r", - encoding='utf-8') + language = get_language() + file = open( + os.path.join(PROJECT_DIR, "apps", "common", 'template', f'email_template{to_locale(language)}.html'), "r", + encoding='utf-8') content = file.read() file.close() code_cache_key = email + ":" + state