svelte-i18n
svelte-i18n copied to clipboard
Callback/event for missing messageIds
Is your feature request related to a problem? Please describe.
Currently if the $_(...)
cannot find the specified messageId
, it simply silently outputs the messageId
with no sort of indication of the failure. This can lead to less-than-ideal user experiences where something like category.subsection.header
gets shown to the user.
In our case, some of our message ids get assembled programmatically e.g. `${currentPage}.${loadingState}.title`
so it can be easy to overlook some combinations of the values.
Describe the solution you'd like
Add an event or callback that can be hooked into to report these errors back to use. I could imagine this being something like registerFormatError((locale, messageId, messageObject) => { sendToMyErrorReporter(...) })
so we can be alerted that a given messageId
is not properly defined for a given locale. I imagine this could be used in the case of messageId
being missing entirely, or missing token/values/etc.
Describe alternatives you've considered
Putting some sort of wrapper around $_(...)
to see if the value that comes out is the same as the messageId
passed in.
How important is this feature to you? Thoroughly a nice-to-have, but hopefully it's a relatively easy addition
Additional context Add any other context or screenshots about the feature request here.