-
-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement hot reloading for the locale files during development (#5050)
* Stop using deprecated additionalAssets hook * Watch locale files without webpack-watch-external-files-plugin * Use Maps instead of objects * Use webpack's file timestamps instead of checking the files ourselves * Add hot reloading * Inject hot reload code snippet
- Loading branch information
Showing
7 changed files
with
138 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const websocket = new WebSocket('ws://localhost:9080/ws') | ||
|
||
websocket.onmessage = (event) => { | ||
const message = JSON.parse(event.data) | ||
|
||
if (message.type === 'freetube-locale-update') { | ||
const i18n = document.getElementById('app').__vue__.$i18n | ||
|
||
for (const [locale, data] of message.data) { | ||
// Only update locale data if it was already loaded | ||
if (i18n.availableLocales.includes(locale)) { | ||
const localeData = JSON.parse(data) | ||
|
||
i18n.setLocaleMessage(locale, localeData) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.