Repository navigation
fix: I18NProvider.translate return same as Component.translate - #22363
Conversation
The I18NProvider.translate should return the same as Component.translate when no provider can be found. Fixes #19516
9d49467 to
e3d8efd
Compare
Test Results1 269 files + 184 1 269 suites +184 1h 15m 47s ⏱️ + 2m 36s Results for commit 3bda5b0. ± Comparison against base commit 3113fad. This pull request removes 1 and adds 2046 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
| .getTranslation(key, locale, params); | ||
| .map(i18n -> i18n.getTranslation(key, locale, params)) | ||
| .orElseGet(() -> { | ||
| LoggerFactory.getLogger(I18NProvider.class).debug( |
There was a problem hiding this comment.
If we reach this due to VaadinService or Instantiator being null, then exception would make more sense since it's fatal issue. LocaleUtil.getI18NProvider() is just chain of Optional mapping, so I suggest checking for null first for VaadinService and Instantiator, and throw exception if null.
If VaadinService and Instantiator are not null but we still reach here, then just logging that I18NProvider is null is enough. It could be null if all translation files are missing, like in the ticket.
Message could say "I18NProvider is not available. Missing all translation files can cause this with default I18NProvider."
There was a problem hiding this comment.
Throwing for missing service or instantiator. Else just returning key as we do for component.
|



The I18NProvider.translate should return the
same as Component.translate when no provider
can be found.
Fixes #19516