Skip to content
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

[i18n] Load translations from backend #2103

Closed
sissbruecker opened this issue Feb 22, 2024 · 1 comment · Fixed by #2168
Closed

[i18n] Load translations from backend #2103

sissbruecker opened this issue Feb 22, 2024 · 1 comment · Fixed by #2168
Assignees
Labels
enhancement New feature or request hilla Issues related to Hilla I18N

Comments

@sissbruecker
Copy link
Contributor

The client should load translations from the Java backend. This should happen:

  • When the client / I18n initializes, loading translations for the initially detected language
  • When the user changes the language, loading translations for the newly selected language

The backend should provide either a request handler, or a Hilla endpoint, for loading translations for a specific language. That handler would return the contents of the language specific properties file from the translations resource bundle already used by Flow apps. If there are no translations for the requested language, the backend should return a default set of translations, which should be the contents of the root resource bundle (translations.properties). The handler should somehow indicate to the client whether it was able to resolve translations for the requested language, or whether it returned the default as a fallback. Only if no fallback can be found, the handler should return an error status code, and the client should be able to show an error as well.

For now the client would load all translation strings stored in the translations resource bundle, which could include translation strings that are only used by the backend (email templates, report templates, etc.). A future enhancement could cover splitting translations, so that we only load the translations that are implicitly (automatic detection) or explicitly (developer managed) needed by the client. An alternative could be to configure filters in the backend which keys to send to the client.

@sissbruecker sissbruecker added enhancement New feature or request hilla Issues related to Hilla labels Feb 22, 2024
@sissbruecker
Copy link
Contributor Author

PR for adding a request handler for loading translations: vaadin/flow#18680

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hilla Issues related to Hilla I18N
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants