Skip to content

[5.x] Add optional fallback for missing keys in {{ trans }} tag #11944

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

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

daun
Copy link
Contributor

@daun daun commented Jul 10, 2025

We're currently building a larger site with dynamic user-supplied translations. Lots of them are missing and we needed a mechanism for displaying a fallback translation if the requested key does not exist. Thought this might be useful to have in the core tag :)

Before

{{ trans key="messages.does_not_exist" }}
Output: messages.does_not_exist

After

{{ trans key="messages.does_not_exist" fallback="Literal fallback" }}
Output: Literal fallback

{{ trans key="messages.does_not_exist" fallback="messages.fallback_key" }}
Output: Fallback from existing key

@jasonvarga jasonvarga merged commit 2ef8bac into statamic:5.x Jul 10, 2025
25 checks passed
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