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

Hotswap of translations does not work using Hotswap Agent plugin #20118

Open
sveinnetnordic opened this issue Oct 2, 2024 · 1 comment
Open

Comments

@sveinnetnordic
Copy link

Description of the bug

Using hotswapagent 2.0.1 with watchResources=src/main/resources/vaadin-i18n. Seems to work, but UI/Vaadin does not load/refresh translations. Need a full restart.

HOTSWAP AGENT: 11:10:14.384 INFO (org.hotswap.agent.plugin.spring.reload.SpringBeanReload) - try to add changed property 'file:/D:/vaadin/src/main/resources/vaadin-i18n/translations_no.properties' into org.springframework.beans.factory.support.DefaultListableBeanFactory@17273273

Expected behavior

Should show new translation text on hotswap

Minimal reproducible example

H1 heading1 = new H1(translate("h1.element-1.text"));

h1.element-1.text=Hello

Versions

Hilla: 24.5.0.beta4
Flow: 24.5.0.beta3
Vaadin: 24.5.0.beta4
Copilot: 24.5.0.beta3
Frontend Hotswap: Enabled, using Vite
OS: amd64 Windows 11 10.0
Java: JetBrains s.r.o. 21.0.3
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Java Hotswap: false
IDE Plugin: ☑ 1.9.9

https://github.com/HotswapProjects/HotswapAgent/releases/tag/RELEASE-2.0.1

@mshabarov mshabarov self-assigned this Oct 2, 2024
@Artur-
Copy link
Member

Artur- commented Oct 3, 2024

ResourceBundle.getBundle used by DefaultI18NProvider at least caches the bundle lookup and returns the old version. This caching is probably unnecessary in development mode

@mshabarov mshabarov removed their assignment Oct 3, 2024
Artur- added a commit that referenced this issue Oct 4, 2024
Allows translations to be reloaded in development mode

For #20118
Artur- added a commit that referenced this issue Oct 4, 2024
* Clears resource bundle cache on translation resource redeployment
* Fires a HMR event to the browser when translations are reloaded

Limitation: Only supports DefaultI18NHandler where the paths are known. If you have a custom I18N handler, you might need a custom HMR supporting HotswapListener.

For #20118
Requires vaadin/hilla#2795 to fully fix the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants