Skip to content

fix: I18NProvider.translate return same as Component.translate - #22363

Merged
tltv merged 4 commits into
mainfrom
issues/19516-i18n-error
Oct 6, 2025
Merged

tltv merged 4 commits into
mainfrom
issues/19516-i18n-error

Conversation

@caalador

Copy link
Copy Markdown
Contributor

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

Fixes #19516

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

Fixes #19516
@caalador
caalador force-pushed the issues/19516-i18n-error branch from 9d49467 to e3d8efd Compare September 29, 2025 11:01
@github-actions

github-actions Bot commented Sep 29, 2025 •

Copy link
Copy Markdown
Contributor

Test Results

1 269 files  +  184  1 269 suites  +184   1h 15m 47s ⏱️ + 2m 36s
8 706 tests +2 045  8 639 ✅ +2 045  67 💤 +1  0 ❌  - 1 
9 159 runs  +2 055  9 082 ✅ +2 055  77 💤 +1  0 ❌  - 1 

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.
com.vaadin.flow.i18n.DefaultInstantiatorI18NTest ‑ translate_withoutInstantiator_throwsIllegalStateException
com.vaadin.base.devserver.AbstractDevServerRunnerTest ‑ shouldPassEncodedUrlToDevServer
com.vaadin.base.devserver.AbstractDevServerRunnerTest ‑ updateServerStartupEnvironment_preferIpv4_LocalhostIpAddressAddedToProcessEnvironment
com.vaadin.base.devserver.AbstractDevServerRunnerTest ‑ updateServerStartupEnvironment_preferIpv6_LocalhostIpAddressAddedToProcessEnvironment
com.vaadin.base.devserver.BrowserLiveReloadAccessorImplTest ‑ getLiveReload_devMode_contextHasNoReloadInstance_instanceIsCreated
com.vaadin.base.devserver.BrowserLiveReloadAccessorImplTest ‑ getLiveReload_devMode_contextHasReloadInstance_instanceIsReturned
com.vaadin.base.devserver.BrowserLiveReloadAccessorImplTest ‑ getLiveReload_liveReloadDisabled_instanceIsCreated
com.vaadin.base.devserver.BrowserLiveReloadAccessorImplTest ‑ getLiveReload_productionMode_nullIsReturned
com.vaadin.base.devserver.DebugWindowConnectionLicenseCheckTest ‑ checkLicense_invalidLicense_sendLicenseCheckFailed
com.vaadin.base.devserver.DebugWindowConnectionLicenseCheckTest ‑ checkLicense_noLicenseKeys_sendLicenseCheckFailed
com.vaadin.base.devserver.DebugWindowConnectionLicenseCheckTest ‑ checkLicense_validLicense_sendLicenseOk
…

♻️ This comment has been updated with latest results.

@mshabarov
mshabarov requested a review from tltv September 29, 2025 11:33
@tltv tltv changed the title fix: I18NProvider.translat return same as Component.translate fix: I18NProvider.translate return same as Component.translate Sep 30, 2025
.getTranslation(key, locale, params);
.map(i18n -> i18n.getTranslation(key, locale, params))
.orElseGet(() -> {
LoggerFactory.getLogger(I18NProvider.class).debug(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing for missing service or instantiator. Else just returning key as we do for component.

@vaadin-bot vaadin-bot added +1.0.0 and removed +0.0.1 labels Oct 2, 2025
@vaadin-bot vaadin-bot added +0.0.1 and removed +1.0.0 labels Oct 3, 2025
@sonarqubecloud

sonarqubecloud Bot commented Oct 3, 2025

Copy link
Copy Markdown

@caalador
caalador requested a review from tltv October 3, 2025 10:54
@tltv
tltv merged commit 143b9e3 into main Oct 6, 2025
8 checks passed
@tltv
tltv deleted the issues/19516-i18n-error branch October 6, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing translation files causes an error with translate

3 participants