Repository navigation
feat: add locale URL routing and tests for static locale files #8295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here are the issues and suggestions: Issues:
Suggestions:
No syntax irregularities; the diff itself is clean. The main concerns are global-state isolation and weak assertions. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,23 @@ def pro(): | |
| name="doc_chat", | ||
| ), | ||
| ) | ||
| # 暴露运行时生成的 UI 语言包 | ||
| urlpatterns.append( | ||
| re_path( | ||
| r"^static/admin/locales/(?P<path>.*)$", | ||
| static.serve, | ||
| {"document_root": os.path.join(settings.STATIC_ROOT, "admin", "locales")}, | ||
| name="admin_locales", | ||
| ), | ||
| ) | ||
| urlpatterns.append( | ||
| re_path( | ||
| r"^static/chat/locales/(?P<path>.*)$", | ||
| static.serve, | ||
| {"document_root": os.path.join(settings.STATIC_ROOT, "chat", "locales")}, | ||
| name="chat_locales", | ||
| ), | ||
| ) | ||
| # 暴露ui静态资源 | ||
| urlpatterns.append( | ||
| re_path( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Irregularities & Potential Issues
Suggested Refactor for sub in ("admin", "chat"):
urlpatterns.append(
re_path(
rf"^static/{sub}/locales/(?P<path>[^/]+(\.[^/]+)?)$",
static.serve,
{"document_root": os.path.join(str(settings.STATIC_ROOT), sub, "locales")},
name=f"{sub}_locales",
),
)And wrap the whole block in |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code you've provided appears to be only an empty diff line:
This is a unified‑diff hunk header (
@@ -0,0 +1 @@) followed by a single added blank line. There is no actual source code to review.Observations:
+line adds an empty/blank line.To give a meaningful review, please paste the actual code (e.g., the full file content, not just the diff header). If this is intentional, note that committing files with only a blank line is generally unnecessary and can be cleaned up.