slang
slang copied to clipboard
Support 'deferred loading'
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
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>
We can just load the
yes, but what should String a = t.myTranslation
return? This getter is not a future.
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?
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.