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

Closed
sveinnetnordic opened this issue Oct 2, 2024 · 5 comments
Closed

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
@sveinnetnordic
Copy link
Author

FYI: Tried to patch 24.5.0.beta5 with TranslationFileRequestHandler. Did not work for Flow. Maybe patching will not work...
HOTSWAP AGENT: 08:24:17.649 INFO (org.hotswap.agent.plugin.spring.reload.SpringBeanReload) - try to add changed property 'file:/D:/NNDev/studd2/studd-vaadin/target/classes/vaadin-i18n/translations_no.properties' into org.springframework.beans.factory.support.DefaultListableBeanFactory@67efd2c2

@Artur-
Copy link
Member

Artur- commented Oct 7, 2024

The latest version of #20142 is supposed to fix it for Flow

@mcollovati
Copy link
Collaborator

Side note: TranslationFileRequestHandler requires a DefaultI18NProvider, that in turn does not rely on Spring, but directly uses ResourceBundle, so the reported log might not indicate that there's something wrong in Flow.

mshabarov pushed a commit that referenced this issue Oct 7, 2024
* fix: HMR for translation files

* 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

* format

* trigger Flow UIs refresh

* flow support

* detect correct refresh stragety per UI

---------

Co-authored-by: Marco Collovati <[email protected]>
vaadin-bot pushed a commit that referenced this issue Oct 7, 2024
* fix: HMR for translation files

* 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

* format

* trigger Flow UIs refresh

* flow support

* detect correct refresh stragety per UI

---------

Co-authored-by: Marco Collovati <[email protected]>
mshabarov pushed a commit that referenced this issue Oct 7, 2024
* fix: HMR for translation files

* 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

* format

* trigger Flow UIs refresh

* flow support

* detect correct refresh stragety per UI

---------

Co-authored-by: Artur <[email protected]>
Co-authored-by: Marco Collovati <[email protected]>
@mshabarov mshabarov moved this to ⚒️ In progress in Vaadin Flow ongoing work (Vaadin 10+) Oct 8, 2024
@mshabarov
Copy link
Contributor

Waits for vaadin/hilla#2795.

@github-project-automation github-project-automation bot moved this from ⚒️ In progress to Done in Vaadin Flow ongoing work (Vaadin 10+) Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

4 participants