Repository navigation
fix(notifications): translate notification emails and messages into recipient user locale (#11408) - #12944
Merged
SchrodingersGat merged 2 commits intoSep 29, 2026
Conversation
…ecipient user locale (inventree#11408)
xyz-is-best
requested review from
SchrodingersGat and
matmair
as code owners
September 28, 2026 11:12
✅ Deploy Preview for inventree-web-pui-preview canceled.
|
matmair
approved these changes
Sep 28, 2026
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #12944 +/- ##
==========================================
+ Coverage 87.31% 87.32% +0.01%
==========================================
Files 1508 1509 +1
Lines 103755 103880 +125
Branches 11790 11790
==========================================
+ Hits 90591 90711 +120
- Misses 13098 13103 +5
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
SchrodingersGat
approved these changes
Sep 29, 2026
Member
|
@xyz-is-best thanks for the contribution |
SchrodingersGat
added a commit
that referenced
this pull request
Nov 4, 2026
- The 'LANGUAGE" user setting does not exist - Introduced in #12944
SchrodingersGat
added a commit
that referenced
this pull request
Nov 4, 2026
- The 'LANGUAGE" user setting does not exist - Introduced in #12944 (cherry picked from commit ec5d632) Co-authored-by: Oliver <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Fixes #11408 by ensuring notification emails and UI messages are translated into each recipient user's configured language preference rather than being "baked in" with the server process default locale.
Root Cause
Previously, in
InvenTreeEmailNotifications.send_notification():html_message = render_to_string(...)andsubjectwere rendered once globally outside the user loop using whatever locale happened to be active on the worker process (typically English).user.profile.languageorInvenTreeUserSetting).Key Fixes
common/notifications.py):get_user_language(user)helper to inspect user language preferences in priority order:user.profile.language/user.user_profile.languageInvenTreeUserSetting.get_setting('LANGUAGE', user=user)settings.LANGUAGE_CODE.core_notifications.py):defaultdict(list)).django.utils.translation.override(user_lang).core_notifications.py):Verification & Testing
Added hermetic test suite in
src/backend/InvenTree/common/test_notifications.py:test_email_notifications_locale_translation: MocksInvenTree.helpers_email.send_emailand asserts:"Items Received")."Elemento ricevuto").test_email_notifications_single_locale_batching: Verifies recipients sharing a locale are dispatched in a single batch.test_ui_notifications_locale_translation: VerifiesNotificationMessagerecords are created with user-specific translations.test_email_notifications_no_recipients: Verifies edge-case handling for missing templates and empty recipient lists.Test Results:
pytest src/backend/InvenTree/common/test_notifications.py-> 5 passed, 0 faileduv run ruff check-> 0 errorsuv run ruff format --check-> Clean