Skip to content

Add fallback language support in get_template with try/catch error ha…#516

Open
yakov-sudo wants to merge 1 commit into
ui:masterfrom
yakov-sudo:fix/fallback-language-template
Open

Add fallback language support in get_template with try/catch error ha…#516
yakov-sudo wants to merge 1 commit into
ui:masterfrom
yakov-sudo:fix/fallback-language-template

Conversation

@yakov-sudo
Copy link
Copy Markdown

…ndling

Fixes #515

This PR wraps template retrieval logic in try/catch blocks so that:

  • If a translated template lookup fails via translated_templates.get(), the original template is kept
  • If get_email_template() fails for a specific language, it falls back to getting the template without language

This prevents the entire email sending operation from failing when a translation is unavailable.

…ndling

Fixes ui#515

This PR wraps template retrieval logic in try/catch blocks so that:
- If a translated template lookup fails via translated_templates.get(), the original template is kept
- If get_email_template() fails for a specific language, it falls back to getting the template without language

This prevents the entire email sending operation from failing when a translation is unavailable.
@selwin
Copy link
Copy Markdown
Collaborator

selwin commented Jan 25, 2026

Hey, sorry but I actually don't quite agree with this change. I think the current behavior of raising an exception is correct so the exception can be handled by the user. If you feel strongly, we can add an argument that alters the behavior such that it returns the original template if the translation is not found.

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.

Support fallback language in get_template with try/catch error handling

2 participants