kaisermann / svelte-i18n

Internationalization library for Svelte

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Callback/event for missing messageIds

pzcfg opened this issue · comments

commented

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.