diff --git a/apps/maxkb/tests/__init__.py b/apps/maxkb/tests/__init__.py new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/apps/maxkb/tests/__init__.py @@ -0,0 +1 @@ + diff --git a/apps/maxkb/tests/test_locale_urls.py b/apps/maxkb/tests/test_locale_urls.py new file mode 100644 index 00000000000..4a417c0a400 --- /dev/null +++ b/apps/maxkb/tests/test_locale_urls.py @@ -0,0 +1,20 @@ +from django.test import SimpleTestCase + +from maxkb.urls import pro + + +class LocaleUrlTests(SimpleTestCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + pro() + + def test_admin_locale_index_is_served_from_static_path(self): + response = self.client.get("/static/admin/locales/index.json") + + self.assertEqual(response.status_code, 200) + + def test_chat_locale_index_is_served_from_static_path(self): + response = self.client.get("/static/chat/locales/index.json") + + self.assertEqual(response.status_code, 200) diff --git a/apps/maxkb/urls/web.py b/apps/maxkb/urls/web.py index eadfb661467..16b275264fa 100644 --- a/apps/maxkb/urls/web.py +++ b/apps/maxkb/urls/web.py @@ -73,6 +73,23 @@ def pro(): name="doc_chat", ), ) + # 暴露运行时生成的 UI 语言包 + urlpatterns.append( + re_path( + r"^static/admin/locales/(?P.*)$", + static.serve, + {"document_root": os.path.join(settings.STATIC_ROOT, "admin", "locales")}, + name="admin_locales", + ), + ) + urlpatterns.append( + re_path( + r"^static/chat/locales/(?P.*)$", + static.serve, + {"document_root": os.path.join(settings.STATIC_ROOT, "chat", "locales")}, + name="chat_locales", + ), + ) # 暴露ui静态资源 urlpatterns.append( re_path(