vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
922 stars 58 forks source link

Handle i18n translate calls when i18n is not configured #2300

Open tomivirkki opened 7 months ago

tomivirkki commented 7 months ago

Describe your motivation

If you use the translate API from @vaadin/hilla-react-i18n without having called i18n.configure() before, the given key is passed as such as a result, even if you have the default translation file in place.

Describe the solution you'd like

It would be nice if the default translation file was used by default. If this isn't an option, a console error with additional instructions would be helpful for the user.

Describe alternatives you've considered

No response

Additional context

No response

Legioth commented 7 months ago

It would be nice if the default translation file was used by default.

I don't see how that could be done consistently since we wouldn't want to load it eagerly and it's too late to lazy load it when translate is called (unless we do nasty things with throwing a promise as an exception and expecting the infrastructure around React's <Suspense> to catch it).

For this reason, I think a helpful error would be the best course of action.