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

frontend: lazy-load languages #2993

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cstenglein
Copy link

@cstenglein cstenglein commented Oct 23, 2024

fixes #1547

Before

before

After

after

Shouldn't have that much impact though since the languages are loaded locally.

@thisconnect
Copy link
Collaborator

Very nice. This cuts the size of the main production JavaScript bundle by half (tested with make buildweb).

Somehow it doesn't initialize the language from the config correctly, but in the settings shows the correct lang.

Screenshot 2024-10-24 at 11 34 50

@thisconnect
Copy link
Collaborator

buildweb with master

master-buildweb

buildweb with this branch

lazy-load-buildweb

@thisconnect
Copy link
Collaborator

webdev is not good to test, in this PR I added vite preview so we can test prodcution build. I tested your branch

looks like this change reduced JS Heap and scripting time

current
profiling-master

with lazy-load branch
profiling-lazyload

@cstenglein
Copy link
Author

Fixed the loading of the language, but not that happy with the implementation with the changing boolean.

@cstenglein
Copy link
Author

Fixed the test and squashed my commits. Should work now.

@thisconnect
Copy link
Collaborator

Thank you so much @cstenglein !

One thing please change the prefix in the commit message from (web): to frontend: so it is consistent with other commits https://github.com/BitBoxSwiss/bitbox-wallet-app/commits/master/ 🙏

@cstenglein cstenglein changed the title (web): lazy-load languages frontend: lazy-load languages Nov 11, 2024
shonsirsha
shonsirsha previously approved these changes Nov 12, 2024
Copy link
Collaborator

@shonsirsha shonsirsha left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @cstenglein

// This is ok since we're just checking for a truthy value in the language detector.
return getNativeLocale().then((nativeLocale) => {
// load the default language first
loadLanguage(defaultLang);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I found a small bug in the Qt app:

When the userLanguage in config.json is an empty string (or not defined) the Qt BBApp will always start with English instead of using the native language.

We purposely store an empty string in case the user changes the language to be the same as the system.

How to test:

  • change system to something else than English, i.e. German
  • change userLanguage to empty string in ~/Library/Application\ Support/bitbox/config.json
  • open the Qt app, English loads, but expected is that the BBapp loads in German

I can't reproduce this well in webdev as native-locale gives me an empty string on webdev so it always goes to En for me in webdev.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I played a bit around and the 2nd commit in #3053 fixes the issue for me. Could you test with this and if it works for you squash it into your commit?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Your version actually partly tries to load to German (with de system and userlang empty string) but the UI is still in English:
Bildschirmfoto 2024-11-15 um 12 18 39

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

Successfully merging this pull request may close these issues.

Explore not loading all languages
3 participants