Replies: 1 comment 2 replies
-
| Hi @jesperp, So you are saying that the  | 
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Thanks again for such a well thought through and useful framework! 🎉
This is sort of a continuation on discussion 306
I think I have found an issue that makes typesafe-i18n (still) not optimal with Sapper and I hope we can find another work around. It's not entirely straight forward to explain but let me try... 🙂
So if I look at the code I can see that the loaded translations are stored in a record on the module level:
Now say that we have a bunch of namespaced translations. On the server, the
loadedLocaleswill – eventually, after seeing some traffic to all pages – contain all possible translations including namespaced ones. This is great, we are caching things on the server by having this singleton.But, the problem now is that the way Sapper works is that the server will serialize data in
preloadinto HTML for use on the client. Looking at our workaround, that means that all server side rendered responses will eventually contain all translations for a specific locale, even namespaced ones that shouldn't be there. Sveltekit does not have this problem. Sveltekit's SSR content is translated but does not include serialized translation data so the client will have always start with a "fresh"loadedLocales.I wanted to start this discussion on a conceptual level, can try to make a minimal demo if needed.
Does this makes sense 😅 and how can we work around this limitation?
I'm thinking this could be solved somehow with Sapper sessions but that would require changing how the loading functions work...
Beta Was this translation helpful? Give feedback.
All reactions