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

Support 'deferred loading' #135

Closed
westlinkin opened this issue Apr 13, 2023 · 6 comments
Closed

Support 'deferred loading' #135

westlinkin opened this issue Apr 13, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@westlinkin
Copy link

When using Flutter Web, all the translations go into main.dart.js, making this file very big. So the web app loads very slowly the first time user opens it. But most users will only use one (two at most) translations.

Is Slang support deferred loading? making each translation into separate files, only loading them if needed

@westlinkin westlinkin added the enhancement New feature or request label Apr 13, 2023
@Tienisto
Copy link
Member

Tienisto commented Apr 13, 2023

Flutter has this feature but it seems that we cannot check if the library is loaded yet.

Only loadLibrary is not enough as all translation access is non-async so there needs to be a mechanism to fallback to the base translations.

The logic would be if <locale> is loaded, then use this, otherwise use <base locale>

@westlinkin
Copy link
Author

We can just load the and together, (if target locale === base locale, then only need to load one locale file). If the user switches to another locale, just load that file.

@Tienisto
Copy link
Member

yes, but what should String a = t.myTranslation return? This getter is not a future.

@westlinkin
Copy link
Author

the < base locale > is always loaded, just use the < base locale >'s tranlation. after other tranlsation's is downloaded, reload the correct translations. Is that ok?

@Tienisto
Copy link
Member

Thinking about this again, I think that this is technically possible. But don't expect this feature soon as I don't have much time for this.

@Tienisto Tienisto changed the title Is this support 'deferred loading' ? Support 'deferred loading' Apr 15, 2023
@Tienisto
Copy link
Member

Added in 4.0.0-dev.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants