feat(plugins): mark plugin user-facing strings for translation - #603
feat(plugins): mark plugin user-facing strings for translation#603hamza-56 wants to merge 1 commit into
Conversation
Covers the chat, slack, googledrive, canvas, and openedx plugins plus the RAG scanned-PDF ingestion message. DisplayInfo/SidebarEntry registrations are gettext_noop-marked, the Slack bot's canned replies become lazy_gettext constants rendered with str() at dispatch, and route details and the chat streaming error map are wrapped in _(). Throwaway underscore variables in googledrive routes are renamed so they cannot shadow the gettext alias. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@claude-review |
|
Claude finished @hamza-56's task in 6m 6s —— View job Review — mark plugin user-facing strings for translation
Solid, well-scoped i18n pass. The three marking strategies are applied correctly and consistently:
Placeholders were correctly converted to translator-friendly named form ( 🔴 High — invalid
|
| except SignatureExpired: | ||
| raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="OAuth state expired. Please try again.") | ||
| raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=_("OAuth state expired. Please try again.")) | ||
| except BadSignature, KeyError, ValueError, TypeError: |
There was a problem hiding this comment.
Invalid Python 3 exception syntax (pre-existing, but inside code this PR edits).
except BadSignature, KeyError, ValueError, TypeError: is Python 2 syntax. Under Python 3 this is a SyntaxError: multiple exception types must be parenthesized — the module cannot be imported as written. The same problem appears on line 91 (except KeyError, ValueError:) and line 139 (except ValueError, HTTPException:).
Notably, the sibling slack/routes/oauth.py touched in this very PR uses the correct parenthesized form (except (BadSignature, KeyError, ValueError, TypeError) as exc:), so the fix is a one-liner here too:
| except BadSignature, KeyError, ValueError, TypeError: | |
| except (BadSignature, KeyError, ValueError, TypeError): |
This is pre-existing (it's on main as well), so it predates this PR — but since the PR edits the detail= lines inside these blocks and the googledrive route tests patch sparkth.plugins.googledrive.routes.oauth.* (which requires the module to import), please double-check that uv run pytest sparkth/plugins/googledrive actually collects rather than erroring. If CI is green, this suite may be silently failing at collection.
Part of: Sparkth UI, emails, API errors, and AI-generated content are English-only
Third layer of the i18n stack (#601 → #602 → #603 → #604 → #606 → #607).
What
Marks the user-facing strings owned by the plugins and the RAG ingestion path, covering route error details, the chat streaming error map, the Slack bot's canned replies, and each plugin's frontend metadata.
Changes
gettext_noop-mark theDisplayInfo/SidebarEntryregistrations of all five pluginsstreaming_error_message/rag_retrieval_error_messagemaps wrapped in_()lazy_gettextconstants rendered withstr()at dispatch; OAuth and workspace route details marked_unpacking variables renamed so they cannot shadow the gettext aliasScannedPDFError.USER_MESSAGEbecomes a lazy translation rendered where the failure is storedHow to Test
uv run pytest sparkth/plugins/chat/tests/test_i18n.py sparkth/plugins/slack/tests/test_i18n.py tests/rag/test_extraction_scanned_pdf.pyuv run pytest(1760 passed on this layer)make mypyandmake lint.backendare cleanNotes
Deferred, per the phase-1 plan: the chat refusal message (lives in
scope_keywords.json, entangled with the LLM system prompt), LLM prompts, MCP tool descriptions, Slack webhook plumbing responses, and hand-rolled pagination-parameter validation messages.This PR description was written with the assistance of an LLM (Claude).