-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Description
Describe The Problem To Be Solved
Currently, when a translation key does not exist in the dictionary, the translator returns undefined (resulting in UI blanks). This can be confusing because it silently fails, and developers might not realize they're missing a key. While the translator itself has type-checking to alert us about non-registered keys, it would be safer and more intuitive if the translator returned the missing key/path itself (e.g., "missing.key" as the fallback) when the entry is not found.
For reference, the relevant code is in index.ts line 267.
Current Behavior
- When a key is missing, the translator returns
undefined(resulting in UI blanks), which can go unnoticed during development.
Why This Is Important
- Helps developers catch missing translation keys more reliably.
- Prevents silent UI issues where
undefinedappears or is rendered blank. - A consistent fallback makes it easier to diagnose and fix translation gaps.
Additional Context
- This change would align with the behavior of many other i18n libraries that display an obvious placeholder (like the key itself) when a translation is missing.
- Developers often expect some clear indicator rather than a silent
undefined.
Suggest A Solution
Expected Behavior
- If a key is missing in the dictionary, return the key/path as the fallback instead of
undefined. - Example:
t("missing.key")should return"missing.key"rather thanundefined.
Possible Solutions
- Modify the logic at the mentioned line 267 to return the requested key/path when the lookup fails.
- Provide a configuration option (e.g., a
missingKeyHandler) for projects that might prefer a different fallback behavior.
Metadata
Metadata
Assignees
Labels
No labels