Skip to content
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

feat(i18n): add language support for registration, password recovery,… Integrated i18n support in MailService for email templates #1921

Closed
wants to merge 1 commit into from

Conversation

lifefloating
Copy link

@lifefloating lifefloating commented Mar 19, 2025

Email Internationalization (i18n) Implementation

Hi

Hi team, I hope you’re all doing well! I noticed in the project requirements that there’s a need to enhance internationalization support, so I’ve put together this PR to address that.

This PR adds complete internationalization support for the email system and optimizes the code implementation, making it more concise and maintainable.

I’d love to get your feedback on how this fits with our goals!

Source of Requirements

Functional Improvements

1. Internationalization Support

  • Support for internationalized text in all email templates
  • Currently supported languages: Ukrainian, English, Chinese, Spanish, French, German, Japanese, Russian, Portuguese, Arabic, Italian

2. Email Language Selection Logic

Implemented multi-level language selection logic:

  • First prioritize the language specified by the user in the request
  • Then use the language setting in the request header (x-custom-lang)
  • Finally fall back to the system default language

3. Code Optimization

  • Refactored MailService and MailerService to improve code readability and maintainability
  • Extracted common methods, reducing code duplication

Email Template Improvements

  • All email templates now support using the {{t 'key'}} syntax to retrieve translated text
  • Complete internationalization for three types of emails:
    • Account activation emails
    • Password reset emails
    • New email confirmation emails

Authentication Process and User Experience

  • Users can specify language preferences during registration
  • Password recovery process supports language selection
  • Support for obtaining language preferences from HTTP request headers

Testing

The internationalization functionality can be tested through the following methods:

  1. Using the API for user registration and specifying the language parameter in the request body
  2. Using the x-custom-lang request header to specify the language
  3. Not specifying any language parameters to test default language behavior

This PR improves the user experience by ensuring email content aligns with users' language preferences while adding support for new languages to the system.

Thanks, best regards

test screenshots

image

image

image

image

… and user updates

- Integrated i18n support in MailService for email templates
@lifefloating
Copy link
Author

lifefloating commented Mar 19, 2025

@Shchepotin @sars @akhedrane @quarryman @gornostal
Hi @maintainers, just wanted to check if there’s any feedback or updates on this PR. Happy to address any questions or make adjustments if needed! Thanks!

@Shchepotin
Copy link
Collaborator

@lifefloating Excuse me for the long answer. All functionalities related to i18n have already been implemented. All information you can find here https://github.com/brocoders/nestjs-boilerplate/blob/main/docs/translations.md

@Shchepotin Shchepotin closed this Apr 8, 2025
@lifefloating
Copy link
Author

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants