-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Implement Accept-Language middleware and German translations #89
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
Conversation
- Create SetLocaleFromHeader middleware to read Accept-Language header - Register middleware in api group to apply to all API routes - Support English (en) and German (de) locales with fallback - Handle quality values in Accept-Language header - Create lang/ directory structure for translations - Add 7 comprehensive PEST tests for middleware functionality - Translate password reset email template to German - Create German translation file (lang/de.json) with 11 strings - Add 5 comprehensive PEST tests for email localization - Update CHANGELOG.md with middleware and translation features Part of: #83 Fixes: #87
💡 Tip: Consider Using Draft PRsBenefits of opening PRs as drafts initially:
How to convert:
This is just a friendly reminder - feel free to continue as is! 😊 |
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.
Pull Request Overview
This PR adds internationalization (i18n) support for password reset emails, enabling German translations alongside English. The implementation includes locale detection via HTTP Accept-Language headers and comprehensive test coverage for both translation functionality and middleware behavior.
- Introduces
SetLocaleFromHeadermiddleware to automatically detect and set application locale based on Accept-Language HTTP headers - Adds German translations for all password reset email strings in
lang/de.json - Updates password reset email template to use Laravel's
__()translation helper
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
app/Http/Middleware/SetLocaleFromHeader.php |
New middleware to parse Accept-Language header and set application locale with fallback to configured default |
bootstrap/app.php |
Registers SetLocaleFromHeader middleware to API route group |
resources/views/emails/password-reset.blade.php |
Wraps all user-facing strings with __() helper for translation support |
lang/de.json |
German translations for all password reset email strings |
lang/de.json.license |
License header for German translation file |
lang/.translation_io |
Translation.io timestamp metadata |
lang/.translation_io.license |
License header for translation metadata |
tests/Feature/PasswordResetEmailLocalizationTest.php |
5 tests verifying translation strings exist and work correctly in both English and German |
tests/Feature/LocaleMiddlewareTest.php |
7 tests validating middleware locale detection, header parsing, and fallback behavior |
CHANGELOG.md |
Documents new i18n features and test additions |
- Remove redundant test 'middleware applies to all API routes' - Update CHANGELOG test count from 7 to 6 for locale middleware - 11 tests total (6 middleware + 5 translations) all passing
💡 Tip: Consider Using Draft PRsBenefits of opening PRs as drafts initially:
How to convert:
This is just a friendly reminder - feel free to continue as is! 😊 |
Summary
Implements Accept-Language header detection middleware and adds German translations for password reset emails.
Changes
Middleware Implementation
SetLocaleFromHeadermiddleware to automatically detect and set locale from HTTPAccept-Languageheaderde-DE,de;q=0.9,en;q=0.8)Translations
lang/de.json) with 11 translated strings__()helper for all user-facing strings in email template:minutesplaceholder)Testing
Quality Assurance
Testing
Example Usage
API Request with Accept-Language header
Password Reset Email
When a German-speaking user requests password reset:
Related Issues
Part of: #83
Fixes: #87
Checklist