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

Implement hot reloading for the locale files during development #5050

Merged
merged 6 commits into from May 14, 2024

Conversation

absidue
Copy link
Member

@absidue absidue commented May 2, 2024

Implement hot reloading for the locale files during development

Pull Request Type

  • Other - Development enhancement

Description

This pull request implements hot reloading for the locale files. I recommend reviewing this pull request by commit, so that it's easier to understand what changes are related to what.

Currently we have it setup to reload the entire app when a locale file is edited, which is not ideal for multiple reasons, a major one being that we have to load all the data from the databases again like we do at startup and all the caches get cleared.

What is hot reloading?
You know when you edit one of the Vue or JavaScript files and it only reloads the parts of the app that changed, that's hot reloading.

Please keep in mind that not all parts of the app react to changes to the locales, the same bits that don't automatically change when you change the language won't change here either, but you can just use the backwards and forwards arrows in the navigation bar, then which still avoids the full reload.

Testing

The easiest way to test that it works is to edit the Search / Go to URL: Search / Go to URL string in the language that you currently have selected, as that is the text that is shown in the search bar at the top of the window that is visible on all pages.

Desktop

  • OS: Windows
  • OS Version: 10
  • FreeTube version: 0.20.0

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 2, 2024 20:48
@github-actions github-actions bot added PR: dependencies Pull requests that update a dependency file PR: waiting for review For PRs that are complete, tested, and ready for review labels May 2, 2024
const message = JSON.parse(event.data)

if (message.type === 'freetube-locale-update') {
const i18n = document.getElementById('app').__vue__.$i18n
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's so much I don't know. This is so cool. Side tip I found from looking this up for @ChunkyProgrammer: the Vue 3 equivalent is apparently __vueParentComponent.ctx.

Copy link
Member

Choose a reason for hiding this comment

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

LGTM!

@FreeTubeBot FreeTubeBot merged commit 61820b1 into FreeTubeApp:development May 14, 2024
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label May 14, 2024
@absidue absidue deleted the hot-reload-locales branch May 14, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants